6 ms·
I like Go, but I'm finding array operations leave a lot to be desired. It feels weird to use global functions (like append) to perform operations on array, and
by dimgl 5y ago
I like Go, but I'm finding array operations leave a lot to be desired. It feels weird to use global functions (like append) to perform operations on array, and I miss having easy map, reduce and filter functions that are accessible from within the array itself. I guess things are getting better, but idk.
- lsferreira42 5y agoThis is really annoying, every time i code in go i miss python's list.append method
- mariusor 5y agoThat is weird because append is one of the five associated helper functions on slices that's actually in the Go specification. https://go.dev/ref/spec#Appending_and_copying_slices https://go.dev/ref/spec#Appending_and_copying_slices
- lsferreira42 5y agoYes, it's a helper function, not a list method like it is in python. The result is the same, its just weird
- mariusor 5y agoOh, I understand what you mean now. I thought you meant the functionality, not the idiom of calling it as a method. I dare say that it didn't occur to me that this difference would be great enough for someone to complain about it on the internet. :P
- IshKebab 5y agoPython also puts what should be methods as global functions, e.g. len, filter, reduce.
- hsn915 5y agoWhenever I read "modern" javascript code, I'm irritated by the prolifiration of map/filter/reduce. It makes code harder to read and modify. A straight for loop is infinitely better in every way.
- hiptobecubic 5y agoThis debate is basically just "I learned C first" vs "I learned a higher level language first."
- konart 5y agoMy learning path was Logo->Basic->Pascal\Delphi->PHP->Python->Ruby and then Go. With some of js here and there. I don't really think it has much to do with you language path but rather with the field you are working most of the time. People who are building Rails startups for sale will have opinion different from people who build some sort of integration systems.
- silisili 5y agoDisagree. I used Python heavily before Go, and Go is much, much easier to read. I've never seen Go code in any codebase I couldn't immediately follow. I can't say the same about Python, and that's supposedly an easier HLL. Then again, I learned BASIC first technically, so my brain probably isn't quite right :).
- hiptobecubic 5y agoNeither Go nor Python are languages that encourage composing functionality out of higher order functions, so I think the point stands.
- pjmlp 5y agoC is high level, many just think it isn't. DDJ had quite a few articles on how to do Lisp-in-C kind of thing.
- 5y ago
- ryanar 5y agoAgreed. Doing Advent of Code in Go and it is so verbose to do simple things like filtering. I agree that for loops can be easier to read, but when it takes 4 LOC to express what a 1 LOC filter function can do and you have 3+ maps or filters you need to do it seems far less readable because it is so noisy. Sure you can understand it, but it is a mess and takes too long to parse for the importance it actually has.
- azth 5y agoThis shortcoming of golang really shows when writing non trivial programs.
- svnpenn 5y agoI think its important to understand that big parts of the software community over-rely on this type of programming. In my opinion, over use of higher order functions is a cancer on programming languages, and should be used at the absolute minimum, or even omitted from a language entirely. https://github.com/golang/go/issues/45955#issuecomment-832355311 https://github.com/golang/go/issues/45955#issuecomment-83235...
- w-j-w 5y ago
- kitd 5y agoI miss having easy map, reduce and filter functions that are accessible from within the array itself Those are be the sort of things that generics will enable.