18 ms·
Go is an example of how to be extremely successful by catering to the needs of the project's core audience (well-rounded stdlib, extremely fast GC, short build
by nine_k 9y ago
Go is an example of how to be extremely successful by catering to the needs of the project's core audience (well-rounded stdlib, extremely fast GC, short build times, trivial deployment, etc) while paying much less attention to the vocal minority's complaints (generics, package system, etc).
- pera 9y agoMaybe, but even then at the end they decided to pay attention to this "vocal minority" and add go dep.
- hood_syntax 9y agoAre the complaints about lack of generics really a minority thing? Writing separate functions to sort different types just strikes me as ridiculous. EDIT: My original tone was a bit nasty in retrospect. Did a little research and while I still am on the generics side, the current situation seems at least workable for a good number of use cases.
- ori_b 9y agoBut you don't need to do that. It's a bit clunkier than generics, but it's usable: https://golang.org/pkg/sort/ https://golang.org/pkg/sort/
- hood_syntax 9y agoI did a little research after I posted my original comment and came across that. It does seem usable even if it's not what I'd prefer
- pcwalton 9y agoYou're still writing separate functions (implementations of sort.Interface) to sort different types.
- dualogy 9y agoA little boilerplate hasn't killed anyone. If you're talking about "100s of different Enterprise Business Objects (TM) structs", something is probably off in the overall program design and/or code-gen should probably be introduced regardless of the 'sort' (and related typically-generics use-cases) question, as that sounds like something to be largely derived from pre-existing schemas of some sort..
- pcwalton 9y ago> A little boilerplate hasn't killed anyone. It's annoying, especially since basic generics are simpler than interfaces. > If you're talking about "100s of different Enterprise Business Objects (TM) structs" I don't write enterprise software. I sometimes need to sort things.
- ori_b 9y agoBut this is something you often need to do for any non-trivial type, even with generics. There's a reason that C++ std::sort<> takes a comparator, or why Rust requires you to implement the 'Ord' interface. Again, it's a little clunkier in Go, but not unusably so.
- pcwalton 9y agoYou need to define how to order things in other languages (though not in languages where you can automatically derive implementations like Haskell or languages with built-in polymorphic comparison like OCaml) but you don't need to define how to swap elements over and over.
- ori_b 9y agoYes, I'm aware. That's the clunky part that I was referring to (although, you can still avoid it for slices, and simply pass a single compare function.) Go is far from my favorite language, but the sheer amount of bad criticism by people that clearly don't use the language annoys me.
- 9y ago
- krylon 9y agoI have had the need to sort data rarely enough that it has not been a real problem to me (most of the time that data came out of a relational database that did the sorting for me). But when I did have the need to sort stuff, I have found it annoying. Even C has a more convenient solution for this problem. (Admittedly, Go's sort.Sort can work for data structures other than arrays/slices.) Like I said, it has not been a sufficiently large problem to really bother me, but it is not a pretty solution, IMHO. Of course, one might argue that the creators of Go knew that sorting things was not such a common problem for their target audience, and thus they made the trade off to make sorting suck in return for overall simplicity; Go's type system makes it practically impossible to implement a type-generic sorting function like C's qsort(3) without sacrificing performance or making the language more complex. So maybe that is one of the trade offs we have to make. I still wish for a better solution, even if that may be impossible without turning Go into another C++. And if you like C++, that is totally fine, it has a number of very big advantages. But then you do not need Go to become another C++ if you have the original right there; and even if you wanted to get away from C++ without giving up the benefits it offers, D looks like a more promising alternative.
- misframer 9y agoI've been using Go at work and for my personal projects for over 4.5 years. I rarely have to sort. It's not a big deal for me.
- sanderjd 9y agoIt's not about sorting, it's about every single abstract operation on a collection or other type of container. You either have to use primitives, or reimplement everything yourself on each new type. Most people just use primitives. This proliferation of primitives is what I actually dislike about reading and writing code in Go, but it's caused by not having a way to define abstract data types that work well.
- dansouzaio 9y agoThere are a few good templating (gengen, genny, etc) solutions for generics in Go, but yeah, it would be nice if it was baked into the language.
- deleted 9y ago[deleted]
- Gys 9y agoAssuming developers are rational in their choices, by far most of the Go developers still prefer to use the language without generics. I think its just a minor problem compared to all benefits.
- weberc2 9y ago> by far most of the Go developers still prefer to use the language without generics I've been writing Go regularly for at least 5 years, and my guess is that at most 60% of Go developers prefer no generics. I also think that number is climbing.
- rifung 9y agoI write Go at work but have never heard anyone say this. Can you explain why you would prefer no generics to this dumb junior engineer who wants to be enlightened?
- weberc2 9y agoTo be clear I prefer generics. The cases for why other Go developers don't want generics seem to mostly fall on "it will change the language / encourage people to write stupidly complex code" to "it's too hard to implement". The first one is valid--Go's constraints give it this nice property that there is (more or less) one obvious way to write most programs, and that will go away with generics; however, I think that cost is worth the gain. The other criticism seems like a cop-out; the Go team has far and away more than enough talent to slap generics onto the language.
- ziotom78 9y agoNot the OP, but here are my 2¢. Introducing generics in a language implies a deep revision of the type system, which risks to become much more complex to understand. Moreover, this might have a bad impact on compilation performance (compare C++ compilation times with Go compilation times and you'll understand what I mean).
- 9y ago
- kown223 9y agohow often do you sort? most of the time you would do a database ORDER BY instead.
- tree_of_item 9y agoI...I can't even believe you just said that. Go really does have a unique core audience.
- shurcooL 9y ago(This is not endorsement of the parent post; I don’t agree with it either.) This is how you can sort slices of arbitrary types in Go: https://play.golang.org/p/VHJW9lVY9b https://play.golang.org/p/VHJW9lVY9b I’m not sure about you, but it feels very reasonable to me. It’s not anywhere near the top of my list of pains that I feel when working with Go everyday.
- kown223 9y agocare to enlighten me? if you have an index you could get the sort for free, also you never pull all results, so why would you pull all, just to sort, on the web I would love to work more in ram, but since you assume a server will crash, you need to save the actual state in the db.
- joshmarlow 9y agoI didn't down-vote, but what jumps out to me is the assumption that you'll generally be pulling data from a database. Yeah, that's almost certainly true in a web-application, but it's not going to be nearly as universal in a systems-programming niche which is where Go appears to be excelling (as perceived by someone outside of the Go community). So ease of implementing sorting in your core language without making assumptions about the operating environment of code written in that language sounds like a reasonable demand.
- z0r 9y agomore like tree_of_interface{} interfaces are a poor substitute for generics, but that's by design. the minute they add a reasonable implementation of generics Go will begin to metastatize into something unrecognizable as people will no longer be bound by the limitations of the already existing core generic types. the core developers really do not want that to happen. it's a highly opinionated language and for some reason some people enjoy writing mountains of for loops so that their code can remain "simple" as they produce a maze of twisty funcs all alike. i mostly see a for loop or two per func with a map and some slices repeating the same patterns over and over. that's the way the language designers want it. i work with a lot of go programmers and they are all fine and good programmers. that makes it even harder to understand why they enjoy all the boilerplate and even defend it.
- nine_k 9y agoApparently, the project leaders see it as a lower-priority (though not unimportant) issue. Looking at the adoption figures, they seem to be right. I personally stay away from Go due to lack of generics and other expressiveness issues. People who have to work with it write code generators on top of the compiler, because the compiler team won't include it into the language. (I can see how it's not an easy thing to do; Russ Cox wrote a nice piece about it.) Java prior to version 5 had the very same problem. It was wildly popular nevertheless. It took Java 8 years to gain support for generics, though, about as long as it took Go to not yet obtain them. (By that time, Java was widely considered the Cobol of 21st century; I think Go must be successfully stealing that crown now.)
- pjmlp 9y ago> Looking at the adoption figures, they seem to be right. Not really, for me Go is a bit like JavaScript. I have to deal with Go thanks to Docker and K8s, doesn't mean I would use it when given the option.
- nine_k 9y agoWould you rather have them use C++? In this regard, Go is a lesser evil.
- dansouzaio 9y agoOr Rust, if you really really want to avoid C++.
- pjmlp 9y agoYes, as long as it was modern C++, not C compiled with C++ compiler. Or any modern natively compiled language.
- hackerfromthefu 9y agoThat's kind of part of the problem - with C++, or Java, or C#, you can write in 15 different styles, syntactically valid but quite possibly unreadable to another programmer who is experienced in the language. That's because there isn't one idiomatic standard for the code, there's 15++, and the language has the complexity that enabled that mess. If you want to work in a kitchen sink language (and I often do haha), just use one of the many available. But perhaps you're missing the value of simplicity? It is after all the main strength of Go, and a rare commodity in software engineering these days. Overall I think it's a shame to have less choice, and we lose something by making all languages too similar (in both features, and at the meta level in complexity).
- AnIdiotOnTheNet 9y agoYes, it is minor. Go has interfaces, so you just write a Comparer interface and sorter that takes two Comparers and then anything implementing Comparer is sortable. *Note: author has written basically nothing in Go and only has a passing familiarity.
- weberc2 9y agoIf your `Comparer` is an element type (as opposed to Go's `sort.Interface` abstraction over collections), this is going to be horribly unperformant. Suppose your `Foo` type implements `Comparer`, and you have a large `[]Foo`. Then you'll first have to iterate over each element in `[]Foo` and add it to your `[]Comparer`, probably with an allocation per element. Then each invocation of `foo.Compare()` is going to be indirect as well (in other words, an interface lookup and a function call, i.e. no inlining). Mind you, this is still faster than many languages, but it's not the kind of performance people expect from Go.
- AnIdiotOnTheNet 9y agoFrom this description, I'm getting the impression that Go's interfaces are not as much like Java interfaces as I had assumed. Never the less, I find that generics usually are just an over-engineered solution to any given problem.
- weberc2 9y agoThe primary differences (I think) are that everything in Java is already a pointer, so there isn't an extra alloc to make an interface. The same is true in Go if your comparables are all pointers. Probably the more significant difference is that Java has a JIT compiler, which may be able to inline all of those calls to Compare(). This is largely why Go's `sort` package abstracts over the collection, not over the element.
- foldr 9y agoI don't see any reason why the interface lookup couldn't be done at compile time in this instance.
- Silfen 9y agoMy concern is less about writing a bunch of separate functions, but rather the way this hampers the abstractions that are available to you everywhere in the language. You don't have map or fold! And that's only the very tip of the iceberg.
- jopsen 9y agoYeah, I wish go had more functional stuff, like .map(), .filter(), etc. On the other hand I enjoy that when I pickup a package someone wrote there is not a bunch of different meta-programming using templates. Generics sometimes lead people (including myself) to over-engineer solutions... usually because we want as much compile safety as possible. But at what cost in complexity.
- erik_seaberg 9y agoI'd rather read x.filter().map() than read the loops someone had to expand them into by hand.
- ryanplant-au 9y agoI groan every time I have to implement the 15th type-specific loop implementation of what I'd do with a single map or fold in Ruby/Elm/Haskell/JS/TS/Crystal/every other language I use. It's not a lot of effort but it's a lot of mess and cruft.
- cube2222 9y agoCheck out goderive
- z0r 9y agolinking this for you: https://github.com/awalterschulze/goderive https://github.com/awalterschulze/goderive i wish i could laugh, but i can't. the lengths people will go to work within such an impoverished language, and by means so antithetical to the go philosophy.
- gcgggfxsdg 9y ago> My original tone was a bit nasty in retrospect Why are you backpedaling? Are you afraid of getting banned? Look, if it’s bollocks it’s bollocks, call it like it is.
- krylon 9y agoYou are not wrong. But I think there is more to it. I have used Go (almost) exclusively for private toy programs I write in my free time to relax (sounds weird, I know), so my perspective may be warped. But something about is very compatible with the way my mind works. With some other languages, say C or C#, I find myself constantly browsing through documentation to figure out what a given construct means in that language. And don't get me wrong, I like both of these languages. But with Go, my intuition what I think a given piece of code should mean is nearly always in line with the language specification. The only other language I had this level of rapport with is Python. There are many things I miss in Go, but all in all, I think it is simplicity done right. BUT if Go had not also gotten the things right that you mention, it probably would not have become this popular.
- nine_k 9y agoGo does have brilliant simplicity! It's the simplicity of Pascal I used in middle school, and of Modula-2 I used on my freshman year, with basically the same syntax. I'm glad Go revived a number of good ideas from Pascal / Modula / Oberon. For writing toy programs to relax (can relate), I personally prefer Python, or maybe a Scheme. While also being simple at the core concepts, they have much more expressive power, an easier way to combine simple things into complex things. They pay for that by higher resource consumption, of course. I do fondly remember a PDP-11 Pascal compiler reporting "15 KB used" after compiling my program; you can't get a Python process with these constraints. But by now we have _vastly_ more computing power.
- TheOtherHobbes 9y agoGo has human-sized simplicity. Programming language complexity is limited by human cognitive limitations, and Go has a small cognitive load. This makes it feel like a very intuitive language. That doesn't mean it is an intuitive language - just that it feels like one for a specific class of problems. Personally I enjoy using it for the same reasons as everyone else. But... I'm also aware it's quite an old-fashioned language, with some bumps under the floorboards where useful things were hammered down to make them go away, instead of being fully solved.
- dekhn 9y agoComplaints about generics aren't coming from a minority group. It's a majority now.
- tqkxzugoaupvwqr 9y agoHow do you know? Anyone who is not interested in generics simply abstains from these discussions/polls. This skews perception.
- dekhn 9y agobecause people at my company collect data on this.
- yjftsjthsd-h 9y agoCould you expand in this? Like, if there's somebody surveying what programmers want as a population, that's pretty cool.
- dekhn 9y agohttps://blog.golang.org/survey2016-results https://blog.golang.org/survey2016-results Note that generics is the highest requested change.
- theshrike79 9y agoPeople want generics because they think every language should have generics. What they don't know is the exact cases where the lack of generics causes a real-world problem for them. This is what the developers are requesting at the moment, in order to possibly bring generics to Go 2.
- erik_seaberg 9y agoEvery statically-typed language needs generics to allow a function to be used with more than one type. Otherwise you throw away most of the type info and end up with the same problems dynamically-typed languages have.
- rdsubhas 9y agoI'm not sure what you mean by vocal minority's complaints. Golang generics is the second most voted issue on GitHub itself: https://github.com/issues?q=is%3Aopen+is%3Aissue+sort%3Areactions-heart-desc https://github.com/issues?q=is%3Aopen+is%3Aissue+sort%3Areac... (I'm not sure if GitHub sorting is broken, but the same issue has more +1s than the top +1d issue as per that sort mode as well) Generics has the most experience reports in Go 2 proposal. Maybe this can be categorized and excluded as a vocal minority, but above data doesn't seem to.
- theshrike79 9y agoThey haven't said "No" to generics. What the developers want is for people to submit _actual_ problems that generics would solve, with examples. Because there are more than a few way to do it and they want to pick the right one.
- kmicklas 9y agoIt's simply astounding that the Google engineers working on Go lack the imagination to understand what problems generics would solve.
- sctb 9y agoWe've asked you twice before not to do this and now you're at it again, so we've banned the account like we said we would. If you would like to comment within the guidelines, we'd be happy to unban your account. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- erik_seaberg 9y agoThat's easy. Concurrent access to maps is unsafe. https://golang.org/pkg/sync/#Map https://golang.org/pkg/sync/#Map should be a drop-in replacement but due to the lack of generics it can't present a compatible or typesafe API.
- 9y ago
- qaq 9y agoHow would allocating resources to making a nice package mnger would have hindered Go popularity :)? Tacking it on postfactum is always a big pain.
- GuB-42 9y agoLike pretty much every successful programming language. Most of them have one original goal, and a core philosophy to go with that goal and that guides the compromises. Take C for instance : its original goal was to write UNIX. Because of this, it has to be low level, portable, and efficient. These are the important things and that's why people use C. Features important for writing UNIX stuff get priority, this ensure consistency. Go is Google's language, made to be effective at doing what Google does. And its direction ensure that people who follow Google's way of coding are happy. There are other options for those who don't like it.
- chmln 9y agoGo devs who want generics are obviously a minority. Those who care about generics enough probably just avoid Go and use another language.
- pjmlp 9y agoIf only we could avoid Docker and K8S in the process.
- camus2 9y ago> while paying much less attention to the vocal minority's complaints That's debatable. Those who can't stand the language don't bother using it,therefore don't bother complaining about it. My point is Go biggest critics have already abandoned the language long ago. Go reminds me Rails. It had a huge success 8 years ago but since all other languages have caught up when it comes to RAD webdev. The JVM and others will eventually catch up.
- bsaul 9y agoi don't think you can "catch up" with go, because it has aimed at being minimalist. catching up by removing major features to a language isn't something i've ever witnessed.
- camus2 9y ago> because it has aimed at being minimalist. You can absolutely catch up with the concurrency model, on the single binary deployment, and a other features. Go isn't "minimalist", that's false, go look at the reflect package, it's complex as hell.
- golangnews 9y agoI’ve used go for around 5 years on multiple large deploys without touching the reflect package. It is neither recommended nor necessary. Go is radically minimalist compared to other languages - it leaves a lot out, most notably inheritance.
- asavinov 9y ago> ... while paying much less attention to the vocal minority's complaints (generics, package system, etc). It is much more difficult not to add a feature than to add it, and the ability to reject even important feature requests is very important for the survival of a system in long term. This observation is formulated in "Getting Real" (https://gettingreal.37signals.com https://gettingreal.37signals.com) as "Forget Feature Requests" and "Start With No".
- moocowtruck 9y agogo would be seen as a project of insanity if not been made by google; and would most likely be in a field of dead language husks
- Groxx 9y agoSurvivorship bias would explain this pretty succinctly.
- feelin_googley 9y ago"... trivial deployment, etc.)..." Does this refer to static binaries? What amazes me most about Go is that they managed to successfully pitch a C-like systems language that does not promote use of shared libraries. About six years passed before they added an option to create them. Were there many complaints about the absence of shared libraries originally? Whenever I have mentioned the benefits of compiling C programs as static binaries and that in some cases with todays hardware one can have enough memory that shared libraries may not be necessary in order to conserve memory (one of the original goals of shared libraries), I have encountered substantial resistance to the idea. Perhaps some folks are interested in shared libraries for reasons other than memory conservation.
- hliyan 9y agoThe deployment time benefits of static binaries far outweigh the resource saving benefits of dynamic linking. I'm speaking from experience with C++. There is also a latency boost for high CPU intensive processes.
- Santosh83 9y agoSecurity: they need to be updated in one place instead a hundred different places.
- closeparen 9y agoThe Go community mostly deploys network server daemons to its own datacenter infrastructure. C and systems programming in general also target end-user devices, where it isn't the programmer's memory to spend. The open-source community already has a mature ecosystem for dealing with shared libraries via package managers and distro maintainers. In a company's proprietary backend it's almost certainly cheaper to throw memory at the problem than to spend engineer time crafting and maintaining a coherent/compatible set of packages for its various backend services.
- ptr 9y agoIn my experience, shared libraries can simplify deployment as well; say you’ve got a 100 programs using the same library, and you need to change the implementation. With a shared library you only need to build and deploy one artifact, you don’t need to relink and redeploy 100 programs.
- fulafel 9y agoAnother take, from the Bell Labs POV: Go is an example of how to be extremely successful by inventing Unix and then going obscure for 30 years doing stuff like Inferno and Plan 9, and making a comeback when Google shows up.
- pjmlp 9y agoGo still lacks a few goodies from Limbo, like proper dynamic loading (only kind of working on Linux currently).
- mirekrusin 9y agoMaybe, but javascript is also extremely successful and quite opposite on many fronts. How do you know that go would be less popular if it had generics and package system?