6 ms·
There is no language that writes code as beautiful code as go, at a lower level. C comes close, but C++/Rust are plain ugly, while C is older than some HN users
by rventure 5y ago
There is no language that writes code as beautiful code as go, at a lower level. C comes close, but C++/Rust are plain ugly, while C is older than some HN users and requires a lot of third-party dependencies for basic operations (e.g http requests).
- timcavel 5y ago
- pjmlp 5y agoObject Pascal, Modula-2, Active Oberon. Just for starters.
- mirceal 5y agoif err != nil { return nil, err } code poetry right there. it's so good that you have to repeat this over and over again!
- esprehn 5y agoTo be fair in rust you get to write .into() or Ok a lot. I do find Go's error handling annoying but rust seems similar for line noise. It's more compact noise, but it's all there.
- avgcorrection 5y ago> To be fair in rust you get to write .into() or Ok a lot. Sure. If “fair” means “not comparable at all”. if-condition-return using two variables is not comparable to one function/macro call.
- maleldil 5y agoThose are for the cases where you're creating or transforming an error. In those scenarios, Go's handling isn't that bad. The issue is having to write `if err != nil { return nil, err }` versus `func()?`. The former gets old really fast. Not to mention the other benefits of monadic error handling when compared to glorified error codes.
- mcronce 5y agoEven transforming an error is taken care of by ? func()? desugars to (more or less) match func() { Ok(v) => v, Err(e) => return Err(e.into()) } I'm also not really sure what the complaint is. Go doesn't do any more implicit type conversion than Rust does. There are numerous solid arguments for Go over Rust, but error handling and automatic type punning aren't on the list.
- socialdemocrat 5y agoIt sucks a bit, but I find the tradeoff quite good. The Go folks have managed to make a language which is quite low level and with a small fairly transparent feature set which still manages to produce code which is not too verbose. Java and C# for instance despite being much higher level languages tend to require far more verbose code. I have played with some crypto code and concurrency in all languages to compare and was pleasantly surprised by how much more compact Go code ended up being while also being easy to read and using fairly simple constructs. You can often get smaller Java and C# code but at the expense of using far more complex and abstract concepts. There is a sense of good balanced taste in how Go featured and libraries are made which often lacks in many other languages.
- doctor_eval 5y agoYeah, the fact that I can write a production capable JSON API server in about 5 lines of code with no external dependencies is golden. Compile and start times are tiny. Native executables are brilliant. The ergonomics of Go go well beyond just LOC.
- mirceal 5y agoi think go (as any other language) shines in some use cases, is meh in some use cases and straight-up sucks in others. the problem i'm seeing is the cargo cult where basically go is the ultimate answer and everything has to be rewritten in it.
- burnished 5y agoyeah errors appear to be a wart
- tialaramex 5y agoBeauty is of course necessarily in the eye of the beholder, but Rust doesn't look ugly to me. One of the first things that jumps out is how little boiler plate Rust's canonical Hello World program has, Go doesn't do badly here either (certainly compared to C, C++ or Java), but it does introduce a bunch of ancillary stuff like packages and importing that are peripheral to our purpose in writing Hello, World!
- esprehn 5y agoSpin showed up on HN recently as an interesting example of Go vs Rust hello world: (Rust) https://spin.fermyon.dev/ https://spin.fermyon.dev/ Vs (Go) https://spin.fermyon.dev/go-components/ https://spin.fermyon.dev/go-components/ The Go example seems a lot simpler without the Ok/Some/.into()/? That are unrelated to sending hello world. There's also no macro magic to understand. In general my observation is the ancillary stuff (and in general number of things you need to understand) is greater in rust. That's paired of course with greater expressivity.
- mustache_kimono 5y agoI've never really understood why the lack of Result/Option types are somehow spun as a good thing. Other things about Rust can be complex and can require some diligence to learn, but Result/Option types over golang's way of handling the same thing? Seriously? That's the argument for golang?
- doctor_eval 5y agoI don’t think that’s the argument for Go. It’s a decision that Go developers accept as a trade off for other things that are nice about Go. I haven’t learned Rust yet, maybe one day I will, but it looks a lot more complex to me, and it’s hard to see how the extra complexity will help me write better web servers. It’s OK for Rust and Go to solve different problems with different trade offs.
- mustache_kimono 5y ago
- tehnub 5y agoZig