11 ms·
Would take an expressive language any day, with some restrictions on templating / macros enforced on junior developers, rather than writing tedious for loops in
by higerordermap 6y ago
Would take an expressive language any day, with some restrictions on templating / macros enforced on junior developers, rather than writing tedious for loops in Go.
- jahaja 6y agoWhy? The writing part of this job is the easy part. Furthermore, if you think that this problem is solved by just hassling junior devs a bit you're painfully wrong. Some people with great experience are still prone to this, some times as a matter of style.
- higerordermap 6y agoGo makes it easy to understand what is happening at a micro per-statement level and not a macro level. For me, readability is about expressing __intent__ and not about every machine detail. Writing all that boilerplate is also more error prone. My favourite example: see the following code in Go containsVal = false for _,i := range array { if (i == val) { containsVal = true } } This is one statement in any language with reasonable abstraction capabilities: python: `val in array` Javascript: `array.includes(val)` Java: `array.indexOf(val) != -1` C++: `std::find(array.begin(), array.end(), val) != array.end()` (Actually C++ one is already quite verbose and little distracting, but sure you can implement it better in C++) Go is only so-called modern language in which standard library cannot provide trivial abstractions to convey intent. Instead you have to use interface{} escape hatch or use codegen. The 'Go is readable' meme is misguided.
- jahaja 6y agoStuff like this just isn't important compared to the benefits. One has to focus on the positives and negatives and each of their proportional importance overall. In that particular case, it's just fine to workaround these things with interface{} and move on to more important stuff. Or perhaps consider to use a map if you find yourself constantly needing to pick out an entry from a slice.