←back to thread

1455 points nromiun | 9 comments | | HN request time: 0s | source | bottom
Show context
exclipy ◴[] No.45077894[source]
This was my main takeaway from A Philosophy Of Software Design by John Ousterhout. It is the best book on this subject and I recommend it to every software developer.

Basically, you should aim to minimise complexity in software design, but importantly, complexity is defined as "how difficult is it to make changes to it". "How difficult" is largely determined by the amount of cognitive load necessary to understand it.

replies(11): >>45077906 #>>45077954 #>>45078135 #>>45078497 #>>45078728 #>>45078760 #>>45078826 #>>45078970 #>>45079961 #>>45080019 #>>45082718 #
YZF ◴[] No.45078760[source]
The problem is no set of rules can replace taste, judgement, experience and intuition. Every rule can be used to argue anything.

You can't win architecture arguments.

I like the article but the people who need it won't understand it and the people who don't need it already know this. As we say, it's not a technical problem, it's always a people and culture problem. Architecture just follows people and culture. If you have Rob Pike and Google you'll get Go. You can't read some book and make Go. (whether you like it or not is a different question).

replies(9): >>45078947 #>>45079055 #>>45079393 #>>45079903 #>>45079931 #>>45079994 #>>45080208 #>>45080993 #>>45083102 #
1. bb88 ◴[] No.45079903[source]
> Every rule can be used to argue anything.

Unless it's a rule prohibiting complexity by removing technologies. Here's a set of rules I have in my head.

1. No multithreading. (See Mozilla's "You must be this high" sign)

2. No visitor pattern. (See grug oriented development)

3. No observer pattern. (See django when signals need to run in a particular order)

4. No custom DSL's. (I need to add a new operator, damnit, and I can't parse your badly written LALR(1) schema).

5. No XML. (Fight me, I have battle scars.)

replies(2): >>45079983 #>>45080703 #
2. ferguess_k ◴[] No.45079983[source]
> 2. No visitor pattern. (See grug oriented development)

This one is my particular pet-peeve. But I often think that the reason is because I suck. I'm going to read "grug".

I also hate one-liner functions.

replies(1): >>45080047 #
3. bb88 ◴[] No.45080047[source]
The real geniuses of our times can convert complexity into simplicity. The subgeniuses use complexity to flex over the common developer.

Sometimes things need to be complex -- well that's okay. The real trick is to not put complexity into places it doesn't belong.

replies(1): >>45088932 #
4. cyberax ◴[] No.45080703[source]
Visitor pattern is extremely useful in some areas, such as compiler development.
replies(1): >>45081398 #
5. brabel ◴[] No.45081398[source]
That’s only true in languages that do not have Algebraic Data Types and pattern matching, which nowadays is a minority of languages (even Java has it).
replies(1): >>45081544 #
6. cyberax ◴[] No.45081544{3}[source]
Visitors additionally allow you to decouple graph traversal from the processing. It is still needed even in the languages with pattern matching.

There's also the question of exhaustiveness checking. With visitors, you can typically opt-in to either checking that you handle everything. Or use the default no-ops for anything that you're not interested in.

So if you look at compilers for languages with pattern matching (e.g. Rust), you still see... visitors! E.g.: https://github.com/rust-lang/rust/blob/64a99db105f45ea330473...

replies(1): >>45082244 #
7. brabel ◴[] No.45082244{4}[source]
The example you posted is very interesting as it used both a visitor and ADTs. It seems the need for the Visitor comes from the generics in this case? Probably a Rust specific limitation. I don’t understand why you mention exhaustiveness though, it’s obviously easy have comprehensive or partial matching with ADT.
replies(1): >>45084559 #
8. cyberax ◴[] No.45084559{5}[source]
No. The code can be rewritten without visitors using iterators for traversal, for example). But it'll look badly.

Visitors in the linked example are real classic visitors. The code _within_ the visitor methods, of course, uses pattern matching, but the pattern itself is not materially different from C++.

Exhaustiveness checking for pattern matching is also "best effort" for complex matching.

9. chanux ◴[] No.45088932{3}[source]
Complexity has to live somewhere. The genius is in putting in places that make things manageable, I guess.

https://ferd.ca/complexity-has-to-live-somewhere.html