Live data from Hacker News

Learn Go in five minutes

gist.github.com

71–80 of 137 posts

Re: Learn Go in five minutes

#71

My 2 cents without seeming harsh with the author. Articles with a title `Learn in 5 minutes` are misleading. They should be renamed `Discover in 5 minutes`. Replace the verb Discover by Introduce or something similar if you like. There is a lot of difference between learning a new programming language and discovering one. You will not learn any programming language in 5 minutes. This introduction to Go is quite nice,…

Way less clicks for "Discover" than "Learn"

My expectations were low enough because of the "5 minutes" part, and I actually found it to be better than expected.

Re: Learn Go in five minutes

#72
post #32
post #11

Earlier quoted context omitted.

If I would have to replace C with anything, I would choose Rust and not Go.

To me Rust is more like "C++ done right". It's massively bigger, more complicated and slower to compile than C. The C ABI is also the de-facto lingua franca for language interop, something that's not easily achievable with Rust or C++ (or Go, for that matter).

Have you tried Rust?

The ABI in Rust is doable: https://people.gnome.org/~federico/blog/rust-stable-abi.html

And it doesn't feel like C++ when writing it. The syntax and language features are nice and feel modern.

It does require more attention because of what it compiles down to, but the compiler is there to help with it.

I haven't been excited about any programming languages in years, but Rust has certainly taken my attention lately.

Re: Learn Go in five minutes

#73

Go can be understood as an improved C that keeps much of C's simplicity but adds small, powerful features like interfaces and channels and garbage collection Go fixes C's well-understood flaws (declaration resembling use, unintuitive operator precedence, unrestricted address math, silent casting, zero-terminated strings, etc.) Go puts essential C idioms directly into the language (pointer/length is formalized as slic…

I thought this sounded familiar

https://news.ycombinator.com/item?id=25622389

https://news.ycombinator.com/item?id=25555457

https://news.ycombinator.com/item?id=25531118

Re: Learn Go in five minutes

#74

Go can be understood as an improved C that keeps much of C's simplicity but adds small, powerful features like interfaces and channels and garbage collection Go fixes C's well-understood flaws (declaration resembling use, unintuitive operator precedence, unrestricted address math, silent casting, zero-terminated strings, etc.) Go puts essential C idioms directly into the language (pointer/length is formalized as slic…

I'd like to chime in and say that I also like C but really dislike Go.

C is simple, to what today is nearly an absurd degree, but it at least integrates well with an enormous ecosystem of existing tooling and libraries. Go, by contrast, feels the need to re-invent every possible wheel, often with a seemingly intentional effort to be different just because.

C ABIs are rock solid on every platform. Any language or tooling in the world can load functions from a C library. By contrast, try calling Go from another language. You will quickly give up and use network protocols or subprocesses instead.

The converse is true too: on major platforms, the C library defines the operating system more than the kernel does. (I mean, in a Unix sytem, the entire libc is documented in the man pages. Documentation for writing C is literally built into the operating system.) By contrast, Go decides to avoid the standard platform ways of calling every operating system function, and instead implements syscalls directly into the kernel, basically just because Go hates interoperating with anything that's not Go.

C is a good language not because it is a good language, but because it is a good ecosystem. Unix and C are closely intertwined. (Even Win32 and C are pretty closely intertwined!) I could imagine a Go-based Plan9-like system -- if that existed, and had decades of engineering behind it, I could see the argument being made that Go's ecosystem compares to C's. But while Go may aspire to that, it isn't anywhere near there yet.

And when you start comparing Go with other languages on the basis of language features, I think Go fails laughably more often than not. (I'll give you "C++ is a clumsy mess", though.) But compare Go with Rust, with C#, with Haskell -- for that matter, compare Go with Java and I think Go is a less powerful, less useful language to write real code in.

If I want a lightweight, quick-and-dirty program, I'll use Python. If I want to write a reusable library that gets plugged into other software, I'd go with C (or at least write the interop layer in C). If I want a high-performance server, these days I would probably go with Rust. If I want a pragmatic, well-rounded language to write a large project in, I think C# would probably be my first choice.

What space does that leave for Go? Outside of microservices (where I contend that Rust is a much better choice, and there are lots of other options), Go's niche seems to be command-line tools. I sort of understand that, because Go's static linking makes redistributing binaries relatively easy (although Go by no means has a monopoly on that). But in the space of command-line tools, Go's argument handling is frankly bizarre: it looks at decades of precedent about what users expect from argument syntax and behavior and decides to throw it all away and reinvent the wheel.

I guess that means this comment (rant?) has ended up where it started: Go defies convention, basically "just because". By contrast, C defines convention. "If you like C, you will love Go"? Nope, not at all.

Re: Learn Go in five minutes

#75
post #12

This is neat, and a testament to the simplicity of Go. I normally point people to this tutorial if they want to learn Go quickly, it is interactive (able to navigate straight to go playground) and very well done in my opinion. https://gobyexample.com/

> the simplicity of Go As someone who's not written any Go, I found fasterthanlime's critique of the language[0] damning enough that I likely won't ever touch the thing. Maybe he's cherry-picked examples, but his article was thorough and technical enough to convince me that the Go mantra of simplicity is just surface-level. [0] https://fasterthanli.me/articles/i-want-off-mr-golangs-wild-...

Thanks for sharing this. I'm halfway through it, and it is indeed damning, if only mildly so (compared to, say, phpsadness). As the author says, the specifics are not the point, rather the overall picture they build: that simplicity in language design has its own price, and sometimes all it means is that the underlying complexity is passed on to you to handle in your program yourself; and the damning part is, Go does not seem to do a good job of making that process as smooth and clear as it could.

Re: Learn Go in five minutes

#76

Earlier quoted context omitted.

> the simplicity of Go As someone who's not written any Go, I found fasterthanlime's critique of the language[0] damning enough that I likely won't ever touch the thing. Maybe he's cherry-picked examples, but his article was thorough and technical enough to convince me that the Go mantra of simplicity is just surface-level. [0] https://fasterthanli.me/articles/i-want-off-mr-golangs-wild-...

How is this damning, exactly? It's a very specific set of library quirks that are kind of expected -- Chmod doesn't do much on Windows. Arguably, maybe Chmod shouldn't be in the core library if it can't do everything on every OS/architecture combination, but I am not sure that damns the language. It does the best it can, but doesn't deliver a POSIX overlay for Windows. (The complaint continues into a discussion of bu…

I guess I ignored the section on resolving the long dependency graph, and that's important to discuss. The community could do a better job of splitting their clients and servers into separate modules (writing to InfluxDB should not require downloading the code for an InfluxDB server). (I do love using servers written in Go, though, because my integration tests can just start one up at the beginning of the test and talk to it. No setup/teardown required outside of "go test"; no extra dependencies to make developers install. It's nice!)

The language could do a better job of letting you choose "plugins" at runtime; if you use Prometheus for monitoring and not InfluxDB, it's not ideal to have a bunch of 'if UseInfluxDB { send to InfluxDB }' compiled into your binary. The alternative is to dlopen something that provides monitoring functionality; been there done that with Nginx and OpenTracing, and it's hugely painful. (There simply aren't binaries that work together; you can't wget a prebuilt plugin into your Nginx docker image. You have to build both from scratch.) Or, you can at least defer the monitoring library selection from library to application with an abstraction layer like OpenTelemetry. The cost to the code author is high, and it still doesn't let the operator choose the backend at runtime. Overall, this is something that a programming language should choose to take on, but it's also exceedingly difficult to get right. I haven't seen it done right, anyway; so all you have to go on is a list of ways to get it wrong.

It is annoying that there are 600 different logging libraries. But people are VERY particular about logs, and one person's treasure is another person's "that is so horrible I can't even use it". If there is a programming language where everyone uses the same logging library and that library provides structured logging, the log levels are [trace, debug, info, warning, error, fatal], has built-in support for sending to third-party services (Sentry), rate-based sampling, and metrics generation... then that sounds great to me and I'll definitely take a look. But for some reason, I kind of doubt it. People have a lot of thoughts here, and are very committed to their thoughts. In the Go world, libraries with wonderful authors let you inject your own logger, and it mostly works well. GRPC, pgx, Jaeger, etc. all do a good job here. K8s's client_go does a bad job here, but they're working on fixing it :)

Wasn't planning to get sucked into this discussion, but the article does raise some good points. I'll be very honest and say rants like this sound to me like a pre-rant for next year when it's "why I quit programming forever and became a beet farmer". To succeed at programming, you will have to endure in the face of minor problems with your tools. You will have to use those tools to program better tools, after all. And even then, it still won't be perfect, and you'll see a new set of problems to be mildly annoyed at. Such is life! Ultimately, for me, Go has supported my efforts to make stuff. I run it on STM32 microcontrollers. I run it on Beaglebones. I ran it on thousands of servers at Google. It just kind of gets out of the way and lets you turn your ideas into things that you can use. Who can complain.

Re: Learn Go in five minutes

#77

Earlier quoted context omitted.

I like C but I would prefer Rust over Go. Go may be simple but I really hate using conventions like init(), comments working like syntax, captial letter means published etc.

Do Go comments work like syntax? Do you mean that they need to be formatted a certain way like they’re language syntax?

The Go authors have (ab)used comments to extend the language in experimental ways for code generation, build pragmas and recently file embedding.

They’ve done this to avoid breaking the language stability guarantee, not sure if there were other reasons. I think it’s a mistake personally to create this sort of metalanguage in comments (now you have two problems!) but it’s easy to avoid using this most of the time as the uses are pretty esoteric.

Re: Learn Go in five minutes

#78

Go can be understood as an improved C that keeps much of C's simplicity but adds small, powerful features like interfaces and channels and garbage collection Go fixes C's well-understood flaws (declaration resembling use, unintuitive operator precedence, unrestricted address math, silent casting, zero-terminated strings, etc.) Go puts essential C idioms directly into the language (pointer/length is formalized as slic…

> If you like C, you will love Go

That may be true. But if you love C you’re going to hate Go like you’ve never hated any thing ever before.

Re: Learn Go in five minutes

#79
post #12

This is neat, and a testament to the simplicity of Go. I normally point people to this tutorial if they want to learn Go quickly, it is interactive (able to navigate straight to go playground) and very well done in my opinion. https://gobyexample.com/

[deleted]

Re: Learn Go in five minutes

#80
post #45
post #20

Earlier quoted context omitted.

My main small day-to-day usability gripes with C are lack of type inference, lack of destructors and terrible ergonomics for error handling. Go solves two out of three, but it really dropped the ball hard on error handling which is very disappointing IMO. Things like generics and garbage collection involve some deep tradeoffs, so I get Go's take on them, even if I don't necessarily agree with it. On the other hand IM…

I agree that the error handling is terrible, but I'm not sure how much better it could be without generics. For me, the gold standard in error handling is Rust, where the type system simply does not allow you to ignore errors. This means that the existence of error handling is checked at compile time. Of course, this doesn't mean your error handling is _good_, but I think that's beyond any language design to enforce.…

the type system simply does not allow you to ignore errors

Which is excellent.

the gold standard in error handling is Rust

Really? What library is in fashion this week for handling errors? I have so far used vanilla Rust, error-chain and Failure.

Seems like there is so much choice to improve the gold standard:

https://blog.yoshuawuyts.com/error-handling-survey/#librarie...

Post reply on HN