←back to thread

Go subtleties

(harrisoncramer.me)
240 points darccio | 1 comments | | HN request time: 0.222s | source
Show context
valzam ◴[] No.45666643[source]
Great list of why one can love and hate Go. I really did enjoy writing it but you never get the sense that you can be truly certain your code is robust because of subtle behaviour around nil.
replies(3): >>45666654 #>>45667227 #>>45671606 #
valzam ◴[] No.45666654[source]
I guess as a corollary, Go really rewards writing the dumbest code possible. No advanced type shenanigans, no overuse of interfaces, no complex composition of types. Then you will end up with a very fast, resource light system that just runs forever.
replies(5): >>45666706 #>>45666893 #>>45669853 #>>45671891 #>>45672663 #
theshrike79 ◴[] No.45666706[source]
And code with zero ability to do fancy trickery ("expressive" as some people like to say) is easy to read even if the codebase - or even the language - is unfamiliar.

Which is really handy when shit's on fire and you need to find the error yesterday. You can just follow what happens instead of trying to figure out the cool tricks the original programmer put in with their super-expressive language.

Yes, the bug is on line 42, but it does two dozen things on the single line...

replies(3): >>45667256 #>>45672153 #>>45673868 #
ErroneousBosh ◴[] No.45672153[source]
> And code with zero ability to do fancy trickery ("expressive" as some people like to say) is easy to read even if the codebase - or even the language - is unfamiliar.

A mate of mine did Comp Sci back in uni when First Years were taught Turbo Pascal showed me some, when I was still doing stuff in ZX Spectrum BASIC and Z80 assembler in high school. It was immediately clear what was going on, even if the syntax was a bit unfamiliar.

By contrast I've had to sit and pick apart things with strings and strings of ternary operators in the same expression, as part of case structures that relied on fallthrough, because someone wanted to show how clever they were.

My Pascal-using mate called stuff like that "Yngwie Malmsteen Programming". It's a phrase that's stuck with me, over 30 years later.

Don't do that "WEEDLYWEEDLYWEEDLY" shit. You're just showing off.

replies(1): >>45673514 #
theshrike79 ◴[] No.45673514[source]
I always reiterate to junior programmers that you write as clever code as you want.

On your own time.

When you're writing code for work, stuff that other people have to eventually read and understand, you be as boring as possible. Skip all the tricks and make code readable, not cute. Someone might have to understand and fix it at 3 in the morning while everything is on fire.

  > Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
replies(1): >>45680027 #
1. ErroneousBosh ◴[] No.45680027[source]
I worked with a guy who hated comments. Twice a week or so he'd be "working from home" for some damn reason or another, and he'd spend the day removing all the comments from a massive and tangled PHP codebase. PHP4, at that, to give you a sense of how long ago.

Anyway his argument was "but the code should be obvious! You shouldn't need comments to explain what the code does!"

Yes Robert, but you need comments to explain what the code expects to do stuff to, and why you want that.

Turns out that removing the "Development Manager" as he styled himself's write access to the Subversion repository causes ripples in the fabric of reality right up to the C suite, but I could back my decision up with solid evidence that he was causing more problems than he was solving.