7 ms·
As I've said before, Go has the advantage of mediocrity. It's boring as a language, but it does automatically most of the things you need for web back-end stuff
by Animats 6y ago
As I've said before, Go has the advantage of mediocrity. It's boring as a language, but it does automatically most of the things you need for web back-end stuff. It's garbage-collected and does subscript checking, so you're covered on memory safety. There are stable libraries for most things you need in a web server, and those are mostly the same libraries Google is using internally, so they're well tested. The green thread/goroutine approach means you don't have the problems which come from "async" and threads in the same program; there's only one concurrent task construct.
There's a lot to be said for that. You can put junior programmers on something and they'll probably get it more or less right.
Rust is very clever. The borrow checker was a huge step forward. It changed programming. Now, everybody gets ownership semantics. Any new language that isn't garbage collected will probably have ownership semantics. Before Rust, only theorists discussed ownership semantics much. Ownership was implicit in programs, and not talked about much.
Tying locking to ownership seems to have worked in Rust. A big problem with locking has been that languages didn't address which lock covers what data. Java approached that with "synchronized", but that seems to have been a flop. (Why?) Ada had the "rendezvous", a similar idea. Rust seems to have made forward progress in that area.
I used to say that the big problems in C are "How big is it?", "Who owns it for deletion purposes?", and "Who locks it?" At last, with Rust we see strong solutions to those problems in wide use.
Much work has gone into Rust, and it will have much influence on the design of later languages. We're finding out what happens with that model, what's useful, what's missing, and what's cruft.
In the next round of languages, we'll probably have to deal directly with non-shared memory.
Totally shared memory in multiprocessors is an illusion maintained by elaborate cache interlocking and huge inter-cache bandwidth. That has scaling limits. Future languages will probably have to track which CPUs can access which data. "Thread local" and "immutable" are a start.
- pjmlp 6y agoI am looking forward that the generics 2020 edition actually make it, as Go is becoming anyway harder to avoid on my domain. I think ultimately the biggest Rust contribution will be for GC languages (tracing GC | RC) to also adopt some kind of early reclamation, similarly to Swift's ongoing approach, and we will reach a good enough situation and that will be it.
- kodkuce 6y agoHmm, go sux, i personally love Nim. Rust is bad cuz you need to write 10x more but its good for multythreading and only reason i gona learn it proper is Bevy :)
- kccqzy 6y ago> You can put junior programmers on something and they'll probably get it more or less right. I see junior programmers screw up Go catastrophically. Thinking green threads are magical, they forget the existence of mutexes and the resulting code has data races left and right. Languages like Haskell combine green threads with carefully controlled mutation (be it IORef or STM) to avoid this. Go doesn't, so you still need low-level knowledge like how to avoid deadlocks. As I've said before, Go gives you the veneer of an easy language when it's in fact full of traps for those who aren't experts.
- Animats 6y agoYes. Go's locking is really no better than C/C++. There are queues, and there are mutexes. Everybody has those now. Go just has a new story for them. The whole "share by communicating" thing tends to lead to people just putting "tokens" on queues, not the actual data. But Go does have a run-time race condition checker.
- torgian 6y agoI learned three new terms today. Green threads, data races, mutexes.
- _5yoy 6y agoMost companies, in my experience, want tools that are easy to get right in 80% of cases, and in 20% of cases require experts. Go has the benefit of most benign work is deadass simple to get right. The things you referenced in your post are obviously the remaining 20%. Rust, as an example, is a pretty difficult language to become productive in. Sure, once you've invested the time, you're equipped to handle a wider array of problems, but most organizations don't particularly care about the top. They care about becoming relatively productive relatively quickly. Go's approach to certain problems require expertise, it is not a silver bullet. But there are no silver bullets, and the examples you gave require expertise in any language. The issue is that you've kind of just cherry picked those three concepts as proof of complexity, ignoring the boatloads of other examples in which Go's simplicity does add value.
- 6y ago
- zozbot234 6y ago> It's garbage-collected and does subscript checking, so you're covered on memory safety. Go is only memory safe in sequential code, or concurrent code that never accesses shared data from multiple threads. It does not protect against data races as Rust does.
- erik_seaberg 6y agoGo needs synchronized and immutable collections, or at least to start trusting users to roll their own. Concurrent slice appends will overwrite each other unpredictably, and concurrent map writes and reads can panic.
- throwaway894345 6y agoI’ve always found it better to avoid concurrent mutability as much as possible. That has worked very well for me, and I don’t generally have the negative experiences other Go programmers have complained about. Not as nice as static type system guarantees, but it’s available today.
- tapirl 6y agoIt is not always feasible. Even if sometimes it is possible, it isn't without any cost.
- throwaway894345 6y agoYeah, you’re absolutely right that there is always some situation where some amount of shared mutable state is necessary, but there’s still a lot of fat to trim in most cases.
- tapirl 6y agoWhat you say is prone to make people who are not familiar with Go think there will not a safe way to accesses shared data from multiple threads in Go. This is not the truth. In Go, multiple threads could access shared data safely. When the code is implemented correctly (which is easy), these threads will never access the shared data at the same time. Rust just makes this guarantee in the syntax level (at compiling time), which is different from most other languages, but with the cost of slow code complication, rigid, and not easy to learn. BTW, what you say shows you don't understand basic Go knowledge at all.
- dom96 6y ago> In the next round of languages, we'll probably have to deal directly with non-shared memory. Totally shared memory in multiprocessors is an illusion maintained by elaborate cache interlocking and huge inter-cache bandwidth. That has scaling limits. Future languages will probably have to track which CPUs can access which data. "Thread local" and "immutable" are a start. Interesting prediction. It is precisely the model of threading which Nim follows, global variables are thread local and sharing them is restricted. I'm not sure if the Nim designer thought of it in the terms you've described, but I will certainly point this out to him :)
- nicoburns 6y agoIt's the route JavaScript is taking too. JavaScript has traditionally been single threaded, so all the existing types are single-thread only. Multi-threading is being introduced (still very experimental atm) and the only way to have shared memory is through dedicated "shared" types.
- anderspitman 6y agoI've settled into sort of a hierarchy. If I really want to hack out a small prototype quickly, I use NodeJS. Not having types helps me change things around quickly. If I already have a pretty good idea of my data model but still want to develop quickly, I'll use Go. If it's something 1.0.0+ and I want to make it as reliable as possible, I'd use Rust. My problem seems to be few of my projects ever get to that stage, so I'm mostly writing Go these days...
- jjnoakes 6y agoI never really understood this. You still program with types when hacking out a small project with NodeJS. How does moving type errors from compile time to run time help you move faster? It always made me move slower. Honest question.
- anderspitman 6y agoTo each their own. For small projects, I feel faster with a scripting language. When prototyping with Go, I constantly have to move back and forth between the type definition and the places I'm using the type. With JS you just use it. Lots of things like manipulating JSON or sending requests have less boilerplate as well. Like I said, once the data model is more firm I move faster with a typed language.
- jjnoakes 6y ago> When prototyping with Go, I constantly have to move back and forth between the type definition and the places I'm using the type. I do the same but I don't feel slower doing it. I mean I have to move around between function bodies and callers, for example, when I'm hacking in python, so the two don't feel that different to me (moving between a user and a provider or definition of something when hacking on code). But what does feel different to me is if I hack up some go and get a compile error, that feels MUCH faster and nicer to me than hacking up some python, running for a minute, and half way through hitting a runtime type error.
- 6y ago
- tengbretson 6y agoThe type system of rust makes doing some "dumb" things impossible. The type system of go makes doing some "smart" things impossible. The choice comes down to whether or not you view depending on the expertise of your employees as a liability or an asset.
- hu3 6y agoThat's an interesting point of view. I don't have pleasant memories of deciphering third-party macro and templates in a previous consulting contract. Pretty sure my client wasn't delighted either in having to pay expensive extra hours for me to cleanup the project.
- sagichmal 6y agoBeyond a certain scale there are by definition no good programmers or bad programmers, there are only average programmers. So it seems pretty clear to me that depending on them to be experts is a losing proposition.
- SrslyJosh 6y ago> As I've said before, Go has the advantage of mediocrity. It's boring as a language, but it does automatically most of the things you need for web back-end stuff. Given that Go is essentially a safer, smarter C, it boggles my mind to see it being used for applications where getting the business logic right is much, much more important than performance or complicated bit-twiddling.
- paulryanrogers 6y agoWhat language should be used in those business-first cases?
- spamizbad 6y agoHigh-level, easy to read languages with large, robust ecosystems that your team has a high degree of proficiency coding.
- deleted 6y ago[deleted]
- llimllib 6y agoI have written a _lot_ of business logic in go, and I can say that imo it is a superb language for doing so. Vastly better than C, and I’m coming around to it being better even than my beloved python.
- bshanks 6y agoI'd be interested to hear your thoughts on why Go might be better than Python for business logic.
- llimllib 6y agoMainly that it’s just so aggressively boring (which I love). No exceptions means you have to deal with your errors all the time, and it’s just generally very easy, when dropped into a random spot in the code, to figure out what’s happening. Very little magic.
- tapirl 6y ago> Go has the advantage of mediocrity. This is true in many aspects. Go shares many common feelings with other popular languages. However, there are also something in Go those are not mediocrity. Being an almost static language but also as flexible as (sometimes even more flexible than) many dynamic languages is one of those not-mediocrity things in Go.
- pjmlp 6y agoThis is a feature of most static language with reflection support, already available in the 80's.
- Matthias247 6y ago> Tying locking to ownership seems to have worked in Rust I'm not sure whether I would call it "locking to ownership". But the thread safety guarantees that Rust provides through the type system (`Send/Sync`) are probably the main reason why I would consider using it also for applications which would otherwise favor something along C#, Java or Kotlin to be used. Those languages are for me super productive, and by using them you don't have to worry about memory safety either. However they provide no safety net against threading issues. And unfortunately threading issues are far too commmon - basically everytime I see an entry to mid-level engineer using threads there will exist at least one issue which will cause some pain later on (because it's invisible, will break in weird ways, and will be hard to find). With Rust the compiler will tell people that something is lacking synchronization. There will obviously still be issues - e.g. if someone tries to be clever with atomics and misses the correct dependencies and ordering. Or just because some architecture is not perfect and things deadlock. But there are a lot less of the "oh, I didn't knew this required synchronization at all" issues.
- amboo7 6y agoSDL had an ownership extension in the 90s: http://sens.cse.msu.edu/Software/Telelogic-3.5/locale/english/help/htmlhlp/sdlextensions.html http://sens.cse.msu.edu/Software/Telelogic-3.5/locale/englis...
- erik_seaberg 6y ago> Future languages will probably have to track which CPUs can access which data. Sounds like the https://en.wikipedia.org/wiki/Actor_model https://en.wikipedia.org/wiki/Actor_model with actors/virtual threads pinned to cores. But which vendor is going to convince the industry to produce software that doesn't depend on the legacy cache coherence stuff so they can leave it off the die? I'm reminded of Itanium where "sufficiently smart compilers" to take advantage of VLIW seemed plausible but never really arrived.
- pjmlp 6y agoItanium only died because Intel was a victim of its cross license deal with AMD. Had AMD not been allowed to produce x86 clones and Intel would have pushed those Itaniums everywhere they could, while ramping down x86 production.
- erik_seaberg 6y agoIt doesn’t speak well for Itanium if they shipped before they could deliver better bang/buck (even after customers’ porting costs) than the commodity architecture.
- pjmlp 6y agoAgile product development.