Hacker News new | ask | show | jobs
by golergka 3121 days ago
I don't know why you're downvoted. Generics is a feature that's holding back a lot of developers dealing with complicated business logic (and need for abstraction) from moving to Go. And at the same time, including generics into the language means that all libraries will add generics interfaces - and most probably, stop supporting the old, non-generic interfaces in some time into the future, breaking backwards compatibility at some point.
4 comments

I am one who downvoted that statement, because I considered it a snippy remark without any content. Especially, as the question of generics in Go has been mentioned and discussed often enough. And if one feels the need to restart that discussion with each Go release, one should do so with an insightful comment.

I do not agree with your comment. I don't see how generics are needed to deal with "complex business logic". Yes, ultimately I would like to see generics added to the Go language. As does the Go development team. But, as they have clearly laid out, this is not a trivial undertaking. There hasn't yet been an implementation concept presented, which fits into the Go framework with its design goals.

And until then, I am quite happy that they didn't implement some half-finished concept.

> I don't see how generics are needed to deal with "complex business logic".

Complex business logic really has no place in Go. I would advise people to use more expressive languages (ideally with a modern type system). Go was designed for low-level network systems programming and is not well suited to more high-level problems, despite what the hype train might claim. I see the future as a polyglot one. Folks should use the most appropriate language for whatever domain they are currently working in and not let their careers be defined by any one language or technology.

And Java was designed for toasters. But enough people worked on it made it one of the most popular general purpose language of all times. A lot of folks do not have time to evaluate most appropriate language for a given task at hand and they would rather write code for their needs in a general purpose language and be done with it.
Sure they tried to make it work. But it did create a static typing and OOP backlash. IMHO, too many of us succumbed to the marketing. Many would have been better off using OCaml or Python, both of which were released about the same time (and OCaml has always shipped with "generics"!).
Can you elaborate on what do you mean by "complex business logic"? Any examples?
I didn't bring the term up, but I personally understand it to mean complex domain-specific code. Some examples from my own workplace: pricing/risk of derivatives transactions, financial contract definition, portfolio optimisation, interpreters/compilers for various complex data transformations.
Don't disagree but what often goes unnoticed in this discussion is that there are generics designs out there: https://github.com/golang/proposal/blob/master/design/15292-....

It's not so much "we should add generics but no one is really working on it" it's more "we should add generics and we've tried a dozen designs that haven't really panned out and we're still working on it".

That's what makes me think they will end up happening.

Adding generics to Java and C after several years, shows how successfully the "wait and see" actually works, versus languages that have supported them from the get go.

CLU was designed in 1975 and ML in 1973, several languages with support for some kind of generics have been born and died since then.

So in 42 years, there wasn't a single generic implementation that could fit Go's design goals, other than not having generics at all?!

But Go has not existed for 42 years. Fitting any of those models on Go is exactly what should be avoided unless one of those models magically was a perfect fit for Go which came out just a few years ago.
That is just hand waving, it is more than clear that //go:generate, 90's style is the the only way accepted by Go design team.

There is nothing special in Go's type system that hasn't been tried out in 42 years of generics CS research.

Magically? It would take magic for one of these models to NOT be a perfect fit for Go.

The fact that Go "has not existed for 42 years" is irrelevant -- almost all of its characteristics have been present for 3 to 5 decades, even altogether in the same language(s).

E.g. http://cowlark.com/2009-11-15-go/

Seems author has added an update after 6 years:

"..Updated 2015-09-25: So, about six years later, people are still reading this. I'm not sure how to feel about this; Looking at it now, it's incoherent, badly argued, and a lot of the details are simply wrong. But 1000 hits a month indicate that people still get value out of it."

But this article link is still quite handy for random proof of Go badness.

Whatever the author added, the original points still stand.

He might have changed his mind, but the facts are more stubborn.

The "wait and see" approach as you call it, means that "Generics" (a.k.a. parametric polymorphism) have had to be retro-fitted to languages like Java. This means they are more complex than they need to be and have some ugly edge cases.
This. We still can't overload foo(List<Integer> x) and foo(List<String> x) because vintage 2004 JVMs wouldn't be able to distinguish them. Type erasure was a horrible compromise from which Java will probably never completely recover.
In C11 they are even uglier with the _Generic selector, which understandably was made to work together with how generics were done via pre-processor macros.
These two statements are arguments for different discussions:

> I don't see how generics are needed to deal with "complex business logic".

Here, we're talking about what user (developer who chooses between Go and Java) needs or wants. User doesn't care about costs behind the product.

However, instead of proving this statement, you jump to a different perspective whatsoever:

> But, as they have clearly laid out, this is not a trivial undertaking. There hasn't yet been an implementation concept presented, which fits into the Go framework with its design goals.

And here you're estimating things from the cost perspective; and it quite logically follows that it's not rational for Go developers to dive into generics at the moment. Just keep it mind that this decision means that Go stays unappealing to users like me.

No, I am not talking about costs at all. First of all, I don't see how complex business logic requires generics. I have written complex business applications and not required them. I really have no idea why you would "need" them.

And also for the Go developers, it is not about "cost". They have no idea how they could implement generics without fundamentally changing the Go language to something different than what it was about before. They are working on concepts, but nothing resulted what would be a candidate for implementation.

This boils down to how much one values static types and code reuse. If you do not have Generics (a.k.a. parametric polymorphism) then you are forced to make a choice between type safety and code reuse. You cannot have them both.
I imagine the downvotes are because it doesn't really add anything insightful. It just looks like whining.

Personally, I don't get the fuss. If you want generics, go use Java/Kotlin/something else. I don't see anyone complaining about the lack of generics in C or brainfuck, what makes golang special?

Because C actually has better support than Go for generics.

They could be faked with macros since the early days, which was what Borland's BIDS framework in Borland C++ 2.0 for MS-DOS made use of, dropped when version 3.0 with initial template support was released (around 1992).

Additionally, C now has basic language support for generics in C11 with _Generic.

Except adding tools for doing some kind of macros is much simpler in Go than C because the language is easier to parse. What stops you from using a preprocessor in Go? It is not really part of the compiler in C either.
Sure it is, ANSI C11 (ISO/IEC 9899:2011) chapter 6.1 and section 6.5.1.1.
Fair enough, my C knowledge is a little behind the curve.
This isn't a hard concept to understand.

People like 90% of Go e.g. simplicity, build process, speed and feel that if they added features such as generics, decent error handling e.g. Option or Exceptions then it might go to 95%.

Everyone is looking for that perfect development platform.

> If you want generics, go use Java/Kotlin/something else. I don't see anyone complaining about the lack of generics in C or brainfuck, what makes golang special?

Because it's painful to see a language that would be just perfect for a LOT of things with just ONE extra feature - but without this feature that is a requirement, we have to chose alternatives that have irritating downsides.

People have been using Basic and similar for ages to successfully implement business logic without generics. What is necessary for business applications is good integration with databases and reading/writing in various data formats.

That typically depends on reflection facilities provided by the language, not genetics. In fact genetics, unless done with extreme care, inevitably makes reflection API more complex. In turn that makes it harder to write readers/writers for typical business formats harming the case of business applications.

Basic got generics long time ago in Visual Basic.NET.

I have been coding since early 80's, naturally I have delivered lots of production code without generics.

Oberon, one of my favorite language family and influence to Go, which I used for a while, also did not had generics.

But that was in 1996, when generic programming was WIP in ANSI C++, ML compilers were starting to be adopted, Ada was too expensive, Java and .NET were yet to come.

In 2017 I only use static typed languages without support for genericity when forced to do so.

Isn't there some fact about how COBOL (which I'm reasonably sure doesn't have generics) still handles more transactions and/or more $$ per year than anything else?
Use another language then. What is the point of different languages if they are supposed to have the same feature set? If you want native code type safety and generics use Rust instead. If that is too complicated use a more friendly type safety focused language like Swift.

Really you are spoiled for choice and there is no need to insist every language should follow your particular language philosophy.