11 ms·
Yeah, it seems like a lot of the criticisms of go boil down to "I don't like writing simple loops".
by NateDad 12y ago
Yeah, it seems like a lot of the criticisms of go boil down to "I don't like writing simple loops".
- rtpg 12y agomaps and filters are things that have existed for a long time, and are extremely commonplace. They are also very representative of common operations in programming. Not having generics means we can't properly build these ourselves, and Go doesn't offer list comprehensions, so instead we're forced to for loop.
- NateDad 12y agoYes, loops, just like we learned in CS101.
- wtf_is_up 12y agoBut writing a loop takes up at least 3 lines in my editor!
- frowaway001 12y agoI used to play with a small plastic hammer when I was in kindergarden thirty years ago! I will be very irritated if people laugh at me for trying to build my new house with this hammer now. -- Golangers
- gnuvince 12y agoLoops are basically just compares + labels + jumps, yet we abstracted away from those, because we saw that it was common to want to execute a block of code a given number of times (for loop) or as long as a condition held (while and do/while loops). In recent years, more languages (C++, Java) have added a construct for doing an operation on every element of a collection (for each). Why then can't we have more abstractions of patterns programmers write over and over again? It makes a lot of sense to have an operation to apply a function to every element of a collection (map) or to remove elements of a collection based on a predicate function (filter). Saying that we can write those with loops is the same as saying we can write loop with jumps: true, but have a specialized construct makes the intent of the programmer a lot more clear.
- nine_k 12y agoRather, I don't like to copy-paste and slightly modify simple loops over and over again. Abstraction is a basic tool of programming; where has it gone?
- NateDad 12y agoThey're simple loops. You don't need to copy and paste, you just write them out because it's just ridiculously simple logic. Just like you don't copy and paste if statements.
- nine_k 12y agoRidiculously simple and wordy. Exactly the stuff the computer should do for me.
- jasonkostempski 12y agoI think editors solve that problem pretty well. I usually only have to type something like "fo"<TAB> part of my collection name and another <TAB> or 2 before I get down to business, no matter what language I'm using.
- nine_k 12y agoYou only write source code once. You read and edit it many times, and your colleagues, users of your library, etc, read it many more times. The longer the piece of code one has to read, the easier it is to read it incorrectly, miss a bug, or introduce a bug.
- NateDad 12y agoThis is just not true. Many simple lines are easier to read than fewer more complex lines. It's hard to miss a bug in x = x + 1 foo[x] But easier to miss a bug in foo[x++]
- 12y ago
- jacques_chester 12y agoYeah, it seems like a lot of the criticisms of go boil down to "I don't like doing everything with assembler".