6 ms·
Unrelated thoughts: > Structs do not explicitly declare which interfaces they implement. This is done implicitly by matching the method signatures. This design
by _bxg1 7y ago
Unrelated thoughts:
> Structs do not explicitly declare which interfaces they implement. This is done implicitly by matching the method signatures. This design makes a fundamental error: It assumes that if two methods have the same signature, then they have the same contract.
Isn't this just duck typing? Don't other languages renowned for their type systems do this?
> There’s no ternary (?:) operator. Every C-like language has had this, and I miss it every day that I program in Go. The language is removing functional idioms right when everyone is agreeing that these are useful.
Expressive if/else is much more readable. Of course if Go doesn't have that, removing the ternary operator is a bad call.
> The tried and true approach of providing a compare method works great and has none of these drawbacks.
Hmm... except in anonymous cases. This author clearly has some Java stockholm syndrome.
> The append() function modifies the array in-place when it can, and only returns a different array if it has no place left.
That's horrifying.
- networkimprov 7y agoMy one-line workaround. (Yes, I ban go fmt.) v := a; if t { v = b } Sadly, this doesn't work well if a is a function call :-(
- _bxg1 7y agoOut of curiosity, what's the motivating case for using Go in 2019's programming landscape? Edit: I didn't mean this as an insult, I meant it as a genuine question. I don't know much about the Go ecosystem, and I meant to find out what Go's killer feature is in 2019, when other languages now have strong and elegant concurrency, C-like performance with higher-level syntax and without manual memory management, etc.
- blablabla123 7y agoWriting any type of network server from scratch is quite straight-forward if you know how to do it. Obviously concurrency is also available to the fullest.
- 886 7y agoyou make it sound like Go is not top tier in the 2019's programming landscape and there is a good alternative. Can you elaborate?
- meddlepal 7y agoYes it's called Java.
- dang 7y agoMaybe so, but please don't post unsubstantive comments here.
- bluquark 7y agoKotlin and Swift are both currently encroaching on Go's server-side use cases. For example, Go's star feature, goroutines, has recently been cloned by Kotlin. They are at least as equally pleasant to program in, and they're hitched to major client platforms which means they improve faster and will definitely have a pool of trained developers in the long term.
- apta 7y agoJava is getting a fiber implementation by means of project Loom, which will make golang even less appealing. The good thing is that because the fiber implementation will be built into the JVM, Kotlin and other languages can use them seamlessly.
- 886 7y agoPoints taken. I am full time on Go since few years ago and before that I was 100% Java. Haven't really kept myself up-to-date with the Java land. But from my experience with Java, Go, and Python, I find Go a very versatile programming language. Being able to compile binaries means it's great for infrastructure deployments and CLI tools. Goroutines, concurrency, and etc make it a great choice for server/micro service use cases as well. Some can say that not having a JVM is a plus as well. However, developers do have to be disciplined with error handling and dependency management. But one can argue that this is the case for software development in general.
- weberc2 7y agoProductivity. There just aren't other languages that let me build things quickly with confidence that those projects will also scale well into the future. You don't need to employ people to set up the build system, you don't need to recruit for people who already know the language, you don't need to quibble about which features to use or what style to use or what IDE to use, deployment is a breeze, etc.
- mhh__ 7y agoSunk cost (In a good way). I do not like Go the language but I can begrudgingly admire the ecosystem
- LanceH 7y agoI use Ruby and Go in a complementary way. I find myself choosing Go for: - concurrency - memory footprint management - cpu speed - that nebulous feeling I want a program etched in stone (strongly typed) I've written a lot of Api based clients. Read from a queue and update AWS permissions. Receive a callout from something and passing it along to somewhere else. Come to think of it, I've written a lot of queue-reading workers, some replaced existing Ruby workers for CPU or concurrency reasons. I think in the space of having computers talk to computers Go is highly successful because it handles nearly everything with the standard library. So I find a lot of sdk's for specific platforms written in go that can get something going with the standard library and a single package for the platform.
- randallsquared 7y agoGo's star feature is straightforwardness. Some people call this simplicity. The upshot is that it is very easy to use Go within teams of inconsistent expertise. Since there is a fairly low ceiling to cleverness, Go rewards just getting started rather than spending time making the code smaller, or more general. Of course, this is not as good for having fun programming, unless the programmer feels having written something is more fun than writing it.
- _bxg1 7y agoThis seems similar to one of the main virtues of using Java - there's pretty much just one way to do any given thing and there's a "low ceiling to cleverness". Of course, Go's other features stand out much more when we're comparing to Java specifically.
- pdmccormick 7y agoI happen to love the C language, and my brain is very much tuned to how it works and the world view that it embodies. Go feels to me like veteran C language experts made a thoughtful evolutionary step forward. It's certainly not on the cutting edge of programming language theory, but it has solidly moved the baseline ahead. It's a highly opinionated language, but if you approach those opinions with an open mind, you'll find it has a sense of internal coherence that is both tasteful and pragmatic. Fast compilation speed, easy integration with C, and the "one large static binary" are probably my favourite features, although I do wish those binary sizes weren't quite so large...
- holy_city 7y agoTo be fair that's generally good practice since it eliminates a branch in the code, depending on the type of v and overhead of assignment.
- DuskStar 7y agoSounds like the sort of thing your compiler should choose for you.
- DuskStar 7y agoBanning go fmt gets rid of one of the best parts of the go ecosystem, and I am horrified that you would do so. go fmt may not be anyone's favorite code style, but having go fmt is so much better than dealing with everyone else's favorite (incompatible!) styles.
- networkimprov 7y agoThere is no spec for go fmt. Its behavior has changed across releases. It has no switches to disable features. It destroys many nice single-line constructs, e.g. if err != nil { return err } Much of my code would be painful to read without that one. On the bright side, it artificially inflates your line count, so you appear more productive!
- DuskStar 7y agoI think we're going to have to disagree there, then - yes that oneliner might reduce your LOC count and help you win at code golf, but it doesn't actually make things more readable and certainly isn't worth breaking from the rest of the community. The ecosystem-wide consistency of go fmt is its biggest strength. Adding switches to disable features would eliminate that.
- networkimprov 7y agoThere is a lot more to effective code style than whitespace, and most Go code I've seen doesn't consider that, including the stdlib. I've put a lot of thought into my style guide, and anyone who hasn't done the same has no useful insight on whether go fmt is a help or a hindrance.
- _bxg1 7y ago> one of the best parts of the go ecosystem Is it more powerful in some way than the auto-formatters that exist for nearly every other language?
- DuskStar 7y ago
- weberc2 7y ago> Isn't this just duck typing? Don't other languages renowned for their type systems do this? It's "structural subtyping", which is the type-safe equivalent of duck typing. It's a feature that allows implementations to exist without needing to know exactly every interface they implement. TFA's concern is purely theoretical. > That's horrifying. append() doesn't operate on arrays, it operates on slices. Arrays are fixed-length, contiguous blocks of memory that can't be appended to. Slices are backed by arrays, and if you append to a slice whose backing array is full, it will "grow" by allocating a bigger array elsewhere and copying the original data into it. This is a pretty standard data structure in most languages.
- gerbilly 7y ago> append() doesn't operate on arrays, it operates on slices. [...] This is a pretty standard data structure in most languages. If you say so. I know I should go read the docs more carefully, but this whole slice thing is confusing to me, and often yields surprises like this. I'm not a big fan of how this was implemented.
- weberc2 7y agoHow would you prefer it be implemented?
- gerbilly 7y agoI don't know, I'll go and read up on it more. The feature leaves me 'meh'. I don't find slices as awesome as everyone is always saying, especially without negative indices. I guess part of it it that it isn't always clear to me when you're dealing with a slice, or an array, or whatever. I know, when it's confusing, there's always some reasonable sounding explanation after the fact, sure, but the whole thing feels like a confusing mess.
- Boxxed 7y agoDo you know any other systems languages, like C or C++? This kind of thing makes a lot more sense when you have some surrounding context.
- lmm 7y ago> Isn't this just duck typing? Yes > Don't other languages renowned for their type systems do this? No. In languages with good type systems, nominal types are very valuable. E.g. "known-immutable list" and "read-only view onto a mutable list" are very different types, but offer the same set of methods.