Live data from Hacker News

What Golang Is and Is Not

danmux.com

241–250 of 279 posts

Re: What Golang Is and Is Not

#241

Earlier quoted context omitted.

Google is not the only entity that operates at scale, and simply because google does it does not mean it is the correct choice. That's kinda cargo cultish. In distributed systems, go is fragile and dangerous -- because it will panic. IT has no supervision system, and it has the potential for deadlocks, in fact, unless you engineer around it, all coroutines and channels will produce deadlocks and can silently kill you…

> In distributed systems, go is fragile and dangerous -- because it will panic. Do you know when it will panic? Do you know you can recover from panic if you for example want to communicate with other systems that this node is going offline? > it has the potential for deadlocks I could write that for most of languages that have mutexes. This is design problem, not language problem. > When that happens you have no ide…

[deleted]

Re: What Golang Is and Is Not

#242

Earlier quoted context omitted.

It may be harder to write some things, but it definitely is easier to read Go code. Besides, while the language itself may be more verbose than it could be, the standard library is extremely pragmatic and terse. It's like the opposite of the standard C++ library. E.g. to see if a string starts with another string in C++: std::mismatch(prefix.begin(), prefix.end(), toCheck.begin()).first == prefix.end() In Go: strings…

Oh wow, string prefix checking is the example you want to run with? In C#: toCheck.StartsWith(prefix) Meanwhile in Golandia, this is still an issue: https://github.com/golang/go/issues/16721#issuecomment-24015... ...and I haven't felt this kind of pinch when using C#, ever. But what do I know? I'm just a .NET wage-slave pleb who's too mentally handicapped to see Go's glory.

It was just a simple example. Of course many languages have that. The point is Go nearly always has what you want.

Don't pretend that there aren't things in C# that are better in Go.

And I agree, the min/max thing is stupid. I never said Go was perfect.

Re: What Golang Is and Is Not

#243
post #150

Earlier quoted context omitted.

> The Go standard library is full of things that do exactly what you want them to, whereas in other languages you have to manually do it yourself. Sorting a slice is a pretty obvious counterexample.

Or checking for the presence of an item in a slice. Because Go doesn't supply sets, or allow you to write them yourself, this is something i find myself needing to do a lot, and every time, i'm writing that idiotic function from scratch.

You can use map[X]bool as a set. Not ideal I agree, but it works ok.

Re: What Golang Is and Is Not

#244

As someone who writes Go every day for work, I can't agree that Go is simple. Using a language for analytics without generics can be quite painful and error prone. Go is a language that pushes remembering corner cases and failure conditions onto the programmer rather than the language and runtime itself. When you already have to remember a myriad of corner cases for business logic, also remembering so many corner cas…

> Nim is a very good language that actually accomplishes the simplicity Go wanted imo. Coincidentally, I just looked at Nim this evening, wrote some code and came away with the opposite impression. I'll copy-paste my sort-of-blogpost on this from [1]: Nim itself feels a lot unlike Go and, interestingly, a lot like C++: 1. Non-orthogonal features. In C++, there are references, which are like pointers, but not quite, s…

Your example doesn't produce SIGSEGV for me. It prints out the text, "nil".

However, if I write

    echo(cfg.someSetting[0])
it will segfault. This makes sense because it dereferences a null pointer (in Nim-speak, a nil value). I would guess that's what you experienced.

Dereferencing a null pointer is not unsafe. The program cleanly exits. Compiling that via C is sketchy though, because the C compiler may treat provable null pointer dereferences as undefined behavior.

Re: What Golang Is and Is Not

#245

Earlier quoted context omitted.

Oh wow, string prefix checking is the example you want to run with? In C#: toCheck.StartsWith(prefix) Meanwhile in Golandia, this is still an issue: https://github.com/golang/go/issues/16721#issuecomment-24015... ...and I haven't felt this kind of pinch when using C#, ever. But what do I know? I'm just a .NET wage-slave pleb who's too mentally handicapped to see Go's glory.

It was just a simple example. Of course many languages have that. The point is Go nearly always has what you want. Don't pretend that there aren't things in C# that are better in Go. And I agree, the min/max thing is stupid. I never said Go was perfect.

Not being a Gopher myself, and seeing whats missing from Go compared to C#, I don't see why I'd ever bother using it (unless it's a work requirement).

I like generics and the things that come with it, like LINQ and manipulating abstract collections in a type-safe manner, thank you very much :)

Re: What Golang Is and Is Not

#246

Earlier quoted context omitted.

seems to be the canonical view among gophers that Go's paucity of features is about accessibility for programmers that don't understand them or find them cumbersome to work with Please keep in mind that there are differences at scale. What is "easy to work with" for 1 programmer over a month might not be so for 20 programmers over years. The argument can't be that paucity is good as a general condition, its that ther…

> Please keep in mind that there are differences at scale. What is "easy to work with" for 1 programmer over a month might not be so for 20 programmers over years. > The argument is that simpler is better at scale. Airplanes can move freely in 3 dimensions, but airliners are constrained to fly in particular ways around busy airports and cross country. For one, I just debate the premise the simplicity has anything to…

> But let's take that argument at face value: then why _not_ assembly if this is the case?

Okay, then you can throw away the rest of your post and stop right here. The overwhelming historical evidence is that assembly doesn't scale.

> That's an argument for Go to not have types.

Sorry, that doesn't follow. Is the logic here just because I mention Smalltalk, that I'm advocating late binding and the only type being Object for Go? Sorry, but that doesn't follow. The argument is that Go doesn't need a more complicated type system to avoid problems with heterogeneous collections -- because practice shows that even a simpler one can suffice.

> Frankly I find it bizarre that people claim that they have found type errors to be trivially fixable, because the scope of where a type error can be introduced is enormous in an untyped language...

Sounds like you're invoking freshman level false "common knowledge." Have you ever worked in an "untyped" language in a real project? What if a project simply used runtime asserts? Then a type error in a heterogeneous collection would be caught in unit testing. If it got out to production, it could be easily caught and logged. In 15 years of Smalltalk industry work I never encountered the kind of heterogeneous collection type error you're referring to in production. The closest thing I can recall involved the heterogeneous typed reuse of a local variable. (Which is simply bad coding style in Smalltalk.) In Go, you have a type system that provides much more feedback at compile time, and workable mechanisms for detecting the problem at runtime. So at least in this one instance (heterogeneous collections) there is arguably almost no practical benefit to parametric polymorphism.

(P.S. Technically speaking, Smalltalk is strongly typed with message passing semantics for methods implemented through late binding. It's not "untyped.")

Re: What Golang Is and Is Not

#247

Earlier quoted context omitted.

seems to be the canonical view among gophers that Go's paucity of features is about accessibility for programmers that don't understand them or find them cumbersome to work with Please keep in mind that there are differences at scale. What is "easy to work with" for 1 programmer over a month might not be so for 20 programmers over years. The argument can't be that paucity is good as a general condition, its that ther…

> The argument is that simpler is better at scale . Parametric polymorphism is simple and well understood. And not exactly new either: it has been understood for some 40 years already. > I could see an argument for parametric collections and parametric sorting in Go. C++'s header is proof that there are lots of algorithms that benefit from being expressed generically, not just sorting. > In your experience, what kind…

Would a Go programmer even dream of bootstrapping fancy data structures from simpler ones?

What use is there for a fancy data structure? In practice, these occasions aren't that common. Many "fancy" data structures tend to exhibit bad cache behaviors if implemented naively.

At scale, the law of large numbers says that even improbable events will occur every now and then. Unfortunately, a program with even one bug is still incorrect.

Are you an undergraduate? Depending on how you interpret the spec (which isn't cut and dried when business requirements meet the real world) almost every page of production code has some kind of bug in it. Also, the law of large numbers isn't that relevant for most codebases and developer populations -- the numbers aren't that large. The effect of hubris is much larger in practice.

Re: What Golang Is and Is Not

#248

Earlier quoted context omitted.

>After all, Go ignores all progress in programming languages for the last 40 years. I've seen this meme being spouted so much every time Go's mentioned it's ridiculous. No, piling up feature upon feature is not progress otherwise we wouldn't be using anything but C++. Go is a language you pick for the right situation. If it's not enough for what you're trying to do, go for a different one instead of trying to expand…

>After all, Go ignores all progress in programming languages for the last 40 years. I've seen this meme being spouted so much every time Go's mentioned it's ridiculous. Is it a meme when it is true? To support this question, witness the statements of Rob Pike[0] below. --- Regarding the utility of supporting first-order functions[1]: I wanted to see how hard it was to implement this sort of thing in Go, with as nice…

> [1]:

I don't see how that helps your argument. For loops are more than enough for that task, it's easily readable and universal.

And Go does support first-class and higher order functions so not sure what you're talking about here.

> [2]:

How's ditching inheritance in favor of composition "ignoring the last 40 years"? It's the biggest example together with goroutines that proves that phrase is a meme, and that we've learnt a lot on typing best practices as an industry over the past couple decades.

And as an added bonus, another thing that's a good example of Go actually looking back and improving upon what's been done before is the select statement. Most popular languages fall through by default with the switch statement.

Outside of examples on the internet, I can't recall right now the last time I've seen a switch statement in the wild that didn't break at the end of every case. Making the case (pun not intended) for a fallthrough statement and having switch/select break by default.

Re: What Golang Is and Is Not

#249

Earlier quoted context omitted.

Hell, simply the idea of programming is rife with potential for abuse. Exactly. Everything you add has a cost/benefit for a particular context. Evidently you disagree with how the Golang team has calculated cost/benefit with regards to generics. Because from my perspective, being able to define parametric data types and functions is a huge win for safety and terseness of code without a lot of downside. Terseness is a…

> Terseness is a good thing? Some people say terseness is bad. Clarity is good. Clarity comes from both including every relevant detail (which pulls away from terseness) and excluding irrelevant details (which pushes towards terseness). Clarity also comes from saying everything that has to be said exactly once and no more than that (which pushes towards terseness). Unfortunately, when you program in Go, you often hav…

The benefits of typeful programming go beyond type safety. They also include: “economy of thought”, “fearless refactoring”, “less time wasted on fixing stupid mistakes”, etc.

Funny, but that's exactly what we Smalltalkers had in Smalltalk -- with far less of the "type system" enforced by the compiler and almost all of it in our heads. (That said, back in the day, we had tooling which was more advanced while also being more responsive, years ahead of everyone else, so our viewpoint might be skewed.)

Re: What Golang Is and Is Not

#250

Earlier quoted context omitted.

> Terseness is a good thing? Some people say terseness is bad. Clarity is good. Clarity comes from both including every relevant detail (which pulls away from terseness) and excluding irrelevant details (which pushes towards terseness). Clarity also comes from saying everything that has to be said exactly once and no more than that (which pushes towards terseness). Unfortunately, when you program in Go, you often hav…

The benefits of typeful programming go beyond type safety. They also include: “economy of thought”, “fearless refactoring”, “less time wasted on fixing stupid mistakes”, etc. Funny, but that's exactly what we Smalltalkers had in Smalltalk -- with far less of the "type system" enforced by the compiler and almost all of it in our heads. (That said, back in the day, we had tooling which was more advanced while also bein…

> Funny, but that's exactly what we Smalltalkers had in Smalltalk

Smalltalk doesn't let you say “this object responds to message Foo only when used in this part of the program”. In other words, there's no separation of concerns.

> and almost all of it in our heads

What you realistically can't produce entirely in your head is a proof that your program is correct, unless the language is explicitly designed to lift part of this proof obligation. That's exactly the role of parametricity: to help you separate concerns, allowing you to prove one small thing at a time.

Post reply on HN