25 ms·
If you've coded in Python for years then you probably haven't been exposed to the problems that Go was designed to solve. It's a systems programming language, l
by Philip-J-Fry 5y ago
If you've coded in Python for years then you probably haven't been exposed to the problems that Go was designed to solve. It's a systems programming language, like C. It's designed to be high performance and highly concurrent without sacrificing readability or overcomplicating the syntax.
You can think of it as C with type safety and easy concurrency. That's it really.
Python is very "hackable", as in you throw something together very quickly. If that's what simplicity is to you then Python is simple. I don't think Python is that simple though, there's a lot of hidden behaviours due to things like operator overloading. It's not type safe and type hints are relatively new. Shipping a Python application is an exercise in itself. What's worse is downloading a Python project, running it, and then getting a random crash 10 minutes later at runtime only to find that you're using the wrong version of Python.
I can code Go as fast as I could code Python. I find Go simpler than Python. There's very little hidden behaviour and the behaviour that does feel weird is easily explainable. Shipping a Go application is as easy as sharing an executable. I'd pick Go over Python for all of my problems today because it's what I like, and there's many tasks where Python would be slightly better, but I don't think Python is well suited/well-rounded to all the tasks Go is good at. Like I wouldn't program a high performance websocket server in Python.
- mozey 5y ago> Shipping a Python application is an exercise in itself This, good cross platform support and single file executables. I use https://www.py2exe.org https://www.py2exe.org, and it works great once you've figured out how to set it up. However, doing the same thing in go is simply `GOOS=windows GOARCH=amd64 go build ./cmd/...`
- nickd2001 5y agoPython I find a lot nicer to deploy on *nix. When on Windows I agree it could be painful ;)
- nickd2001 5y agoThanks for the helpful explanation :). C++ was my "first love" that I got paid to code in and enjoyed, and I really felt shocked at lack of classes in Go. With C++ you could happily code C style without classes if that suited better, but you could use classes nicely (e:g like in Qt, well IMHO anyway..) or badly as I'm sure many people did. Regarding deployment, I've never found that too bad with Python, but I only use *nix. Agree Python seems pita to deploy on Windows (like many things on windows), I generally use docker, have used conda in the past, so don't particularly feel a lot of effort difference deploying Python vs Go , but different people have different skills and backgrounds, perhaps I'm better at jumping through hoops for Python so don't even notice.
- hbogert 5y agoemphasis on "easy concurrency", yet hardly simple. What C messed up with memory, Go seems to mess up with concurrency primitives. The ease with which you can introduce thread leaks and race conditions is just ridiculous. Sure, they say use the race detector. But then I say: sure, but I need to run it first. Of course the race detector isn't holy either. Thread leaks are a thing and there's probably a detector for that somewhere too. But surely the parallel to messing up memory with C and its detectors (valgrind?) can be made, and I thought we were all pretty done with that. I never shot myself in the foot with Java and Scala as easily compared to go, yet you almost get ridiculed for mentioning those 2 former languages.
- jstx1 5y agoIs this really the right way to think about Go? My impression was that it doesn't really compete with C at all - it just can't given that it's garbage collected. How many projects that actually need to be written in C can be successfully rewritten in Go? I see Go more as a replacement for Python that's compiled, statically typed, performant and has better concurrency. Great for backend, web APIs, CLI tools etc but you wouldn't build an OS kernel with it.
- _ph_ 5y agoMy impression was that it doesn't really compete with C at all - it just can't given that it's garbage collected. How many projects that actually need to be written in C can be successfully rewritten in Go? That is the wrong way to ask the question. Almost no C program had to be written in C. The right way to phrase the question would be more like: how many C program could be successfully rewritten in Go? And I think the answer is: most of them. The main speed difference between a C program and the same program written in Go is that the Go compiler is less good at optimizing the assembly output. There are very few tasks where the presence of a GC is prohibitive - if you don't generate garbage, it won't run. The Go GC is even written in Go, carefully scrutinized to not allocate dynamic memory.
- Philip-J-Fry 5y agoI never said it competes with C, it's just almost syntactically C with type safety and concurrency primitives. It's a good way to think of the language as that's where its simplicity comes from. Also, pretty sure most things that "need" to be written in C can be written in Go, except things like real-time operating systems. They might not be as performant in a lot of cases, but there's nothing stopping them. The other thing is you're saying _need_ to be written in C. Out of the millions of C applications out there, do you actually think the majority need to be written in C? C is good in a lot of places, like kernels, or very constrained systems, but would something like cURL need to be written in C? I'd argue not. A lot of developers swear by C because they like how basic it is. Go gives you almost the same levels of basic syntax and then stops you corrupting memory accidentally. The other strength of Go is that it's trivial to target so many different platforms. I can take an application that runs on Windows and then run it on Linux. And then run that same application on an Arduino or ESP32 microcontroller with minor changes. Maybe you wouldn't build an OS kernel to challenge Linux in Go. But people have built kernels in Go. There's nothing that prevents you from doing that other than the aims of your kernel. It's not stopped people writing kernels in Java or C# before.
- tharne 5y ago> Shipping a Python application is an exercise in itself I love programming in python, so long as I don't have to ship it. That part is painful enough that it's worth considering other languages to avoid that headache alone.