Live data from Hacker News

Proposal: Go should have generics

github.com

261–270 of 439 posts

Re: Proposal: Go should have generics

#261

The one thing that makes Go special is that it's pure "Engineering-Zen". While that doesn't make programming in Go the most fun exercise it makes it a profound one (after some getting used to). Less distractions, less eGo (forgive the pun). Disclaimer: I'm still having a hard time embracing all of that myself - I don't even like Go. I really miss all the functional cleverness I've come to get used to over the years -…

How do you cope? Weirdly enough I started my career writing selenium test in clojure and got used to (reduce (map (filter ... way of doing things. Then we moved to python and still I was at least able to do (modified(x) for x in xs where satisfies(x)) Then I needed to do some C# work and I really liked LINQ. Now I work in javascript and still can at least _.chain(thing).map().filter().value() It seems that we will us…

Hi there, I feel you :)

The way I've coped with this so far is to embrace it and just work through the given task - less warm-fuzzy-feeling and more "manual work" and time needed for sure but it wasn't that big a deal once I just let "go"...

Not having list comprehensions definitely is one of those things which makes me feel more like a "stupid coding monkey" but again you can be productive with less elegant tooling as well...

Re: Proposal: Go should have generics

#262
post #105

Earlier quoted context omitted.

mental exercise - replace C++ with "generics" and git/kernel/etc with "Go" here http://harmful.cat-v.org/software/c++/linus

Linus is clearly throwing his weight around here. If anyone else were to act this way and use such language we would all call him or her an asshole. Besides his main point is that C++ is not great for low level code. I don't see how this applies here.

He is being called asshole and worse innumerable times. The only difference is that Twitter commenters and Corporate HRs do not control his livelihood in ways it does to most professionals so he is free to say things the way he feels.

Re: Proposal: Go should have generics

#263

Earlier quoted context omitted.

The lesson Go seems to have learned is that, since C++ and Java burned their fingers, clearly fire is too dangerous for humans. The thing that makes it painfully obvious to me that Rob Pike hasn't bothered to learn anything from the PL community is that Go has nil. That just shouldn't happen in a modern language.

What's wrong with nil? Just legitimately curious, and I've never used Go at all.

> I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years.

https://en.wikipedia.org/wiki/Tony_Hoare#Apologies_and_retra...

Re: Proposal: Go should have generics

#264

Earlier quoted context omitted.

The lesson Go seems to have learned is that, since C++ and Java burned their fingers, clearly fire is too dangerous for humans. The thing that makes it painfully obvious to me that Rob Pike hasn't bothered to learn anything from the PL community is that Go has nil. That just shouldn't happen in a modern language.

What's wrong with nil? Just legitimately curious, and I've never used Go at all.

It means that every single type in the language has one extra value it may contain, 'nil', and your code will crash or behave erratically if it contains this value and you haven't written code to handle it. This has caused billions of dollars in software errors (null dereferences in C/C++, NullPointerExceptions in Java, etc.). See "Null References: The Billion Dollar Mistake" by Tony Hoare, the guy who invented it:

http://www.infoq.com/presentations/Null-References-The-Billi...

A better solution is an explicit optional type, like Maybe in Haskell, Option in Rust, or Optional in Swift. Modern Java code also tends to use the NullObject pattern a lot, combined with @NonNull attributes.

Re: Proposal: Go should have generics

#265
post #201
post #178

Earlier quoted context omitted.

Dinamic languages don't need generics

Can you explain?

The point of generics is so that you can use the same code with many different types. With dynamic typing, you can use the same code with anything, it just complains at runtime if you call an operation that isn't supported on a particular type. It's like every operation is implicitly generic.

You could look at generics as a way to bring some of the flexibility of dynamic languages to a static type system, so you get the expressivity benefits without sacrificing type-safety.

Re: Proposal: Go should have generics

#266
post #34

If they accept generics, then there is an implication that the language design isn't infallible as a result of being written by Rob Pike, and then the whole house of cards falls down as people start clamouring for things like real exceptions.

Your comment does a great disservice to Robert Griesemer, Ken Thompson, and the many others who contributed to Go's design.

Not to mention Ian Lance Taylor, who's been on the Go team since before it was public, authored the GCC Go frontend, was de-facto leading the team when I left Google in 2014, and also happens to be the author of the proposal.

Re: Proposal: Go should have generics

#267

I can feel the pain on the Sort issue. I've personally found sorting annoying in Go - I had a bunch of structs representing data entities from a database that all had the same field and I wanted to be able to sort them by this field. Seemed like a LOT of work (basically implementing the same sort that was 99% identical for every struct) or use weird reflection-workarounds to get this to happen. In Java I would not ev…

Couldn't you create a common interface that you could use for the sort?

The whole problem is that there is a common interface, but it's a PITA to reimplement it every time (which means copy-pasting a little less than 10 lines) when every other language gives you sorting with a single, simple, 1-line function (or even a single argument of an already existing function).

Re: Proposal: Go should have generics

#268
post #257
post #244

Earlier quoted context omitted.

Dart is also Google sponsored and no one uses it despite the fact that it's actually a pretty great general purpose language. People use go because it's productive and had a PHENOMENAL standard library for networking.

Given that .NET and Java already had a PHENOMENAL standard library for networking by the time Go came out, I really bet in the Google bias.

Your theory fails to account for the lack of success with respect to Dart; so, it seems more like something you have an urge to believe (despite a lack of evidence).

Re: Proposal: Go should have generics

#269

Earlier quoted context omitted.

>In a properly tuned system with sufficient CPU capacity there should never be any full GC pauses with G1. So you use a language without value types that makes you pay for two or three times more memory than comparable languages, and then you spend your time re-tuning the GC every time your allocation or usage patterns change. Then you hope to never trigger a full GC that could stall the VM for many seconds (or in ex…

100GB heap size in Go? How about 15ms pauses with zero tuning? https://pbs.twimg.com/media/CWoAGeUW4AAy0-9.png:large

They aren't comparable at all. Go doesn't collect incrementally and doesn't compact. So good luck collecting garbage fast enough to keep up with a heap-heavy app (which if you have a 100GB heap, your app probably is).

In other words, the issue is not pause time, it's also throughput.

And Go users do tune their GC: https://github.com/golang/go/issues/14161

Re: Proposal: Go should have generics

#270

Earlier quoted context omitted.

That comes with a big memory cost, though. Also huge startup time, so not suitable for command line tools.

Java startup time is ~50msec, which for command line tools is fine.

Unless you run them in a loop, which is not that uncommon.
Post reply on HN