Hacker News new | past | comments | ask | show | jobs | submit login

That really depends on what you mean by "most of the time". After all, you only write a generics based library once, and you reuse it many times - therefore on the outside it appears that you don't really use generics all that much.

In my opinion, depriving a "normal" language user of generics is like depriving a Lisp user of macros. Whatever it is, its definitely not just "bold".




I've done most of my Go programming on library code. A sync library for relational databases to sqlite (for mobile devices) and an embedded database. Lack of generics has bothered me a little, but copy and paste with a multiple-cursor editor really makes short work of it. I think the worst part is really our natural aversion to code duplication and the ugliness of it. e.g. having to write min/max for integers is pretty ugly (although not as ugly as converting your ints to float64 and using the stdlib min/max.) However, I spent more time thinking that it was ugly than writing min and max. Sure it's ugly, but programming is not art, it's engineering, and Go is a language for engineers.


> I think the worst part is really our natural aversion to code duplication and the ugliness of it. e.g. having to write min/max for integers is pretty ugly

Sometimes ugliness is a sign that something is designed incorrectly, especially if the language aids in making that more visually evident.

> (although not as ugly as converting your ints to float64 and using the stdlib min/max.)

Not to mention incorrect.

> it's ugly, but programming is not art, it's engineering

Not mutually exclusive. A good language would make incorrect or inefficient code "ugly" or "uglier" than correct code.

> and Go is a language for engineers.

So are languages with generics like C++, Java, Rust, Haskell, etc.


Plus all those dynamically typed languages which are intrinsically built on the concept of generics (JavaScript, Perl, PHP, Python, Ruby). /sarcasm Nobody uses them because nobody needs generics.


They are intrinsically built atop generics. Duck typing is row polymorphism. Dynamic languages often depend upon that flexibility to operate—and they enable it by allowing everything. Static languages without polymorphism are at a low point in that trade-off space since they restrict useful operations and provide no way to express the invariances needed to recover that flexibility.


I never thought people will actually come up and defend code duplication. It's definitely more than ugliness. The need to fix all the copies when they need to be updated is a bigger problem.


Or the fact that I actually saw someone on the mailing list also implement min() incorrectly due to copy-paste :)

> I never thought people will actually come up and defend code duplication.

Indeed. Some of the responses by some Go fans really leave me surprised to say the least.


It was the community attitude towards generics and code distribution that eventually made me focus on Rust and D.

At least those communities embrace modern computing abstractions and code distribution practices.


It's fine that you don't agree with our tastes, but it would be nice if you could stop coming into every Go thread and being condescending about it.

Like PostgreSQL and OpenBSD, I've been permanently turned off Rust because I never want to be left at the mercy of a community that invests so much time in harassing and insulting others.


We have rules against harassing and insulting others in the Rust community, and pjmlp does not speak for us.


Look, we gotta keep busy while waiting for the rustc build to finish. :(


Please tell me where you've been harrassed and insulted by the Postgres community? Sometimes people come into the IRC channel and say something that doesn't make sense and are told it doesn't make sense, and sometimes those people get very upset, but I wouldn't classify that as harrassment. And that's basically the strongest reaction you'll ever get from anyone in the community.


Any active comments thread related to MySQL attracts a derailing holier-than-thou invasion telling us how dumb we are for not using PostgreSQL. PostgreSQL's advocates haven't quite reached the arrogance level of Oracle DBAs, granted, but they're a lot more active.

I basically stopped using (public) IRC somewhere around 2000. I have little idea what goes on in PostgreSQL's IRC channel(s). I expect it's toxic, but I'd expect that for any project's IRC presence. Public IRC is an inherently toxic medium.


That doesn't sound like anyone I know of who actually works on PostgreSQL, and certainly not anyone I'd consider part of the PostgreSQL "community." The mailing lists, IRC channel and other forms of community communication are much more hostile to Oracle than any other RDBMS, and anyone who tries to start a flamewar there (particularly one about MySQL) is instantly shut down. I'm really sorry that you've been turned off from great technology by the actions of some overzealous Postgres users.


Except, I also talk good about Go in what concerns using it to replace C, specially in possible uses for real systems programming in a GC enabled language.

After all, when compared with the first Oberon version, Go only needs a few more primitives in runtime and unsafe, Kernel and SYSTEM in Oberon respectively.

This is what attracted me to the language in first place.


even if I think it's horribly naive if not flat out erroneous, I can see how someone could feel that way about OpenBSD...but Postgres?!

who is harassing or insulting anyone in the Postgres world?!?!


Yeah, the deficiency isn't the most harmful part - its the attitudes that come with defending that deficiency.


    > I never thought people will actually come up and defend   
    > code duplication.
DRY is a principle, not an axiom.

Overapplication of DRY as axiomatic has led to much pain and suffering.


Agreed! But what this means is that when you decide not to apply DRY, you need to have a reasonable justification. Code duplication in general is a bad thing.


Now you are shifting to a editing dilemma. Code duplication is not machine code duplication which is what really matters at execution time. Reading is also easier (even for non-Go programmers at least familiar with C) without templating-like syntax.


Machine code duplication is spending a few extra megabytes on perfectly valid, if duplicate, machine code.

Source code duplication is a risk of spending an hour, or maybe a day, of developer's time to detect the duplication, change it in concert in several places, with an occasional need of detecting and fixing a subtle discrepancy between the copies.

RAM is $0.015 per megabyte. Developer time is $50 per hour.


You could also spend that developer time trying to untangle code reuse between various components, or the more subtle breakages caused by changes that don't account for the expectations of all callers. Code reuse is still a tradeoff.


It should be noted that generic code is harder to break. It is, by definition, less entangled with its callers. There are also fewer operations you can do with generic parameters, so there are fewer ways to screw up.


Code duplication is definitely a programmer problem, not a machine problem. It's also a major problem. Code duplication increases the probability of programming errors, and makes maintenance harder. Any modern language with poor tools for keeping duplication at bay is suspect.


"My editor makes it really easy to do this terrible thing, so it's okay!"

I'm sorry, I quite enjoy many aspects of Go - but the argument that committing one of the cardinal sins of programming is okay because your editor makes it easy is worse than the actual language shortcoming itself.


Code duplication is not a cardinal sin of programming. In fact, the attitude that it _is_ has probably done more harm to [modern] programming than duplication ever did :)


This comment wins the thread!

Sorry, I meant to say that the language's shortcomings, even if temporary, start to attract a wrong attitude, which is sad (and you, golang team, should feel sad).


OffTopic: This sync library is available?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: