News for hackers. Stuff that matters.
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by Pannoniae on Tuesday September 19, 2023 @09:55PM (#37579547)
This feels like such a non-news. They've pretty much created a language which is deliberately dumbed down to be 20 years behind other languages, then they are proud that they could speed it up with a feature that was fairly well-known almost 20 years ago.

Also the obsession with not providing tools for the programmer to use the stack, and rely on compiler internals to not heap-allocate everything.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by eru on Tuesday September 19, 2023 @10:14PM (#37579661)
> This feels like such a non-news. They've pretty much created a language which is deliberately dumbed down to be 20 years behind other languages, then they are proud that they could speed it up with a feature that was fairly well-known almost 20 years ago.

If you want to hate on Go, do it properly: https://en.wikipedia.org/wiki/Generic_programming says

> Generic programming is a style of computer programming in which algorithms are written in terms of data types to-be-specified-later that are then instantiated when needed for specific types provided as parameters. This approach, pioneered by the ML programming language in 1973,[1][2] permits writing common functions or types that differ only in the set of types on which they operate when used, thus reducing duplicate code.

> Generics was introduced to the main-stream programming with Ada in 1977 and then with templates in C++ it became part of the repertoire of professional library design. The techniques were further improved and parameterized types were introduced in the influential 1994 book Design Patterns.[3]

If you go with 1973, you get Go being behind the times by a nice round 50 years. If you go with the latest date mentioned, 1994, you still get almost 30 years.

The ML family of languages lives on in eg Haskell and OCaml these days. But Ada was perhaps more mainstream at the time, and 1977 gives you a nice 46 years to roast Go with.

But in any case, while it is tempting to mock Go and its inventors, we should applaud them when they do recognize their mistakes and fix them. Better having generics late than never!

(Btw, from what I can tell by reading their earlier justifications, it seems that the problem was that they only really knew the mess that C++ templates are, and thought all generics were like that. If the choice is between C++ style templates and no generics at all, I can at least understand where they were coming from with their reluctance.

However, given that they must have heard of Java, I'm not quite sure why they thought generics must inevitably be so complicated.

In the end, the Go people wisely got Phil Wadler and friends, who are more at home in the functional programming community, to help them out with the design.)

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by Pannoniae on Tuesday September 19, 2023 @10:31PM (#37579775)
I didn't do it properly on purpose, because that wouldn't have been fair towards Go. Ultimately, many things which aren't even common yet today have already existed in the 70s.

I have picked 20 years specifically since it was around 2003-2005 when Java and C# got generics. Obviously, they were also more than 20 years late but I compared it to mainstream languages people are more likely to know about or more likely to compare it with.

I wanted to be fair and compare Go to some other mainstream languages which are big today, not niche ones.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by fooster on Tuesday September 19, 2023 @11:29PM (#37580091)
It’s so frustrating that every post on go brings out the same tired tropes. It just ruins any sensible discussion on any changes. Why do you do it? Are you trying to troll and actively make HN a worse place because that is for me what you are doing.

If you don’t like go don’t read the posts it’s not hard. Just stop.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by sharts on Wednesday September 20, 2023 @01:57AM (#37580841)
Aren’t you doing the same by replying to their comment?
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by thfuran on Wednesday September 20, 2023 @04:09AM (#37581698)
How so?
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by geodel on Tuesday September 19, 2023 @10:33PM (#37579797)
This feels like such a non-comment.

Which popular GC'd language provide tools to use stack?

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by Pannoniae on Tuesday September 19, 2023 @10:56PM (#37579922)
C# does... you can stackalloc.

I don't see the incompatibility -stack isn't managed by the GC, so the stack isn't affected by the GC's operations, doesn't need to be pinned or anything

Why can't GC'd languages provide access to the stack?

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by jppittma on Tuesday September 19, 2023 @11:11PM (#37580001)
If you care so deeply about memory access that you want control over stack allocation, you probably care enough that you don't want a GC. What's your use case where the GC doesn't murder you, but you care about better cache locality?
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by adgjlsfhk1 on Wednesday September 20, 2023 @01:11AM (#37580574)
Objects on the stack don't participate in the GC (technically they're GC roots). Half of the reason you want to be able to put variables on the stack is because the stack variables are managed by lifetime and therefore the GC doesn't have to collect them.
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by thfuran on Wednesday September 20, 2023 @04:17AM (#37581746)
Isn't more explicit control of memory allocation useful precisely in the places where the default behavior would murder you? I don't see the incompatibility. Many python and java programs have portions that are native code for performance reasons (though that's not necessarily just about GC).

What's relatively rare is a program where the whole thing is absolutely performance critical rather than just some parts.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by adgjlsfhk1 on Wednesday September 20, 2023 @12:53AM (#37580502)
Not sure if Julia counts as popular, but Julia.
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by guenthert on Thursday September 21, 2023 @10:43AM (#37598368)
Common Lisp does in the form of DYNAMIC-EXTENT declaration. Some implementations honor that declaration (it's optional, as it's only an optimization in any case).

Now whether Common Lisp is truly a popular language these days ...

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by glotchimo on Tuesday September 19, 2023 @10:04PM (#37579606)
Because I genuinely don’t know, what do you mean when you say it’s 20 years behind other languages? Or rather, what features is it lacking that would make it up-to-date? And what languages are 20 years ahead of it?
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by Pannoniae on Tuesday September 19, 2023 @10:27PM (#37579749)
I would love to answer in detail but right now I cannot.

One really good example though is error handling - they've pretty much looked at C and decided that that was the best we can do, so now every Go program is full of nilchecking boilerplate.

The whole design of the language generally feels like as if it was made for unthinking drones.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by ARandomerDude on Tuesday September 19, 2023 @11:21PM (#37580063)
> now every Go program is full of nilchecking boilerplate

The try/throw/catch model is painful and Go opted for errors as values. It makes code more verbose but also much more predictable. Pick your pain.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by bushbaba on Tuesday September 19, 2023 @11:34PM (#37580112)
Makes developers need to at least think about error handling compared to say python. However I find Java’s error handling to be superior, but Java coding generally requires an IDE.
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by jacquesm on Tuesday September 19, 2023 @11:38PM (#37580121)
> I would love to answer in detail but right now I cannot.

Sorry but this is unacceptable. You post a generic comment hating on a popular language and then when asked for the specifics you bail out because you can't answer in detail for whatever reason. On top of that you then insult the language authors.

That's classic troll behavior, another commenter here asked you to stop, I'm going to do the same and flag your comments in this thread because they're strictly speaking completely off topic.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by d3w4s9 on Wednesday September 20, 2023 @01:33PM (#37587102)
"unacceptable"

Calm down, this is just a forum.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by Pannoniae on Wednesday September 20, 2023 @05:27PM (#37590431)
Hi. Sorry, I couldn't reply yesterday properly due to personal reasons, I am very sorry about that. It's not a generic comment, it directly reacted to the article. The article was about providing a speedup not because they innovated something new, but because they've finally fixed a wart which should never have been in the language in the first place.

I've said it another comment but I'll directly include it here: "I have picked 20 years specifically since it was around 2003-2005 when Java and C# got generics. Obviously, they were also more than 20 years late but I compared it to mainstream languages people are more likely to know about or more likely to compare it with." Generics are a feature Go has lacked for a very long time, and I think it's a bit misleading to claim that including them is some revolutionary thing which the article suggests. ("There are many reasons to be excited about generics in Go" or "The future of Go generics is bright")

Also, I don't see how it is insulting the language authors if I point out (what I think is) a bad design decision they made. They are not horrible human beings or anything for so, I am not attacking them.

I'd like to disagree with the trolling and off-topic assessments. I would understand if it was a tangential comment about some other problems of Go (like nilchecking for example), but I replied directly to the point the article was addressing. I see the argument that it could potentially invite hostile behaviour, but I'd like to believe in the civility of the forum.

Finally, to expand a bit on the "what features Go needs" question of GP, for example it doesn't support most unicode characters deliberately (only letters and digits), proper exceptions, unions, sum types, enums, and the language doesn't care about correctness at all, only about the "common use case" (see the nanotime/time.Time issue for example, they implemented it the worst possible way)

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by duckmysick on Wednesday September 20, 2023 @05:39AM (#37582245)
> I would love to answer in detail but right now I cannot.

No problem, we can wait. When will you be able?

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by Mawr on Friday September 22, 2023 @10:53PM (#37620226)
Seems to me they've rightly figured that exceptions were a mistake and C had the right overall idea about error handling all along. Go essentially took C's error handling, such at is is, and improved it one step further, taking it from ~20% complete to ~80%. In contrast, e.g. Rust is probably at ~95%.

---

It does endlessly fascinate me how 20 years after the definitive wisdom against exceptions appeared [1], programmers still keep insisting that seeing all code paths laid out bare on the page is somehow worse than keeping them implicit and hidden.

[1] https://www.joelonsoftware.com/2003/10/13/13/

"I think the reason programmers in C/C++/Java style languages have been attracted to exceptions is simply because the syntax does not have a concise way to call a function that returns multiple values, so it’s hard to write a function that either produces a return value or returns an error."

Effortlessly predicting the direction of future languages like Go/Rust/Zig decades ahead of their time. Excellent taste.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by eru on Tuesday September 19, 2023 @10:14PM (#37579667)
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by jrockway on Wednesday September 20, 2023 @12:34AM (#37580410)
People are upset that Go boringly models actual computers that you can buy and incorporates pretty much no exciting computer science concepts. You get structs, slices, and maps. This basically means, you never get to show off your esoteric computer science knowledge while making whatever you set out to make; all you get at the end of your journey is a working computer program that stands on the merits of what it does and not how it was implemented. This is very dissatisfying to many. They might not have anything in mind to make today, but do enjoy solving a good mystery, and there are many obscure programming languages that scratch that itch. Consider "monad tutorials". Nobody has ever needed to figure out what a monad is for their work, and they certainly aren't used to implement physical computers that you can buy at the computer store, but the high level of abstraction really pleases people. It's so abstract that it's difficult to reason about, and feels more like mathematics than making an automaton do your bidding (which is basically all programming is).

Like, structs, maps, and slices are things you can explain to someone in 5 minutes with no software engineering or computer science background. They map to real-life concepts that people use every day. Do you have an ordered todo list? Ever use a dictionary? Ever look at a driver's license, where every license has the same fields but different information? Congratulations, you now intuitively understand the core data structures in Go code.

There is also no way to golf down code. Want to map the elements of a slice into another slice? That's a for loop. Want to reduce over a slice? That's a for loop. People get super excited about giving each sort of operation like this its own name, map reduce foldr foldl zip... but like many things, the names hide what's actually going on, where as Go just makes you type what you're doing into your editor. This seems to annoy people greatly.

The "it's for dumb people" is riffing off a comment made when Go was first introduced; they were aiming for a language that would be easier for large teams to maintain. People new to the codebase could show up and start being productive. Fixes could be applied en masse across the entire codebase. So that's where that comes from. I guess we contrast it with C++, where one missed reference count increment here, or one stack variable returned from a function there, and you have an impossible to debug nightmare that is blowing up in production. Knowing not to make those mistakes makes you smart, and being new and having the system blow up in your face is a great learning exercise, right? Why should you get to come play with my system the day you graduate from college? You have to earn it! So I think that's where the hate comes from. If the junior engineers can start contributing, you're going to have to do something other than troll HN all day or you'll be rEpLaCeD.

A lot of criticisms of Go are right. You can absolutely type in the most dogshit broken programs imaginable. (Most of them start by overusing the keyword "interface", BTW.) There are lots and lots of traps for the newcomers and even the unwary ("invalid memory address or nil pointer dereference"! what's a nil interface value? why is every goroutine you started in that loop see the same value of the loop variable? your goroutine has no way of exiting, so after 100,000 web requests your app gets OOM killed.) Tons of stuff you have to learn to truly be fluent.

It's missing a lot of input from computer science. Structured concurrency? Software transactional memory? Algebraic data types? Classes? Metaclasses? And, it makes a lot of mistakes whose harm is well-documented. ("Nil in 2023!?") While Go tries to be a simple model of the computer, the simplicity is not free. There is no claim that abstractions are zero-cost. Garbage collection WILL use your CPU. Looking up an element in an array or slice has a bounds check added! That memory you got from the OS wasn't zeroed, so guess who set that variable you just declared to the zero value. You just used a resource and you didn't get to decide. That sort of thing can make a certain type of person furious.

There is also a lot of good. The standard library is actually useful. Using third-party modules is easy, and requires no registration with some intermediary to publish one. (Also fetching modules can't print advertisements. I have no idea if any Go developers drunkenly drove their motorcycle into some pedestrians and now need a job, whereas with Javascript, it tells me that every time I build my app! Frankly, my dear, I don't give a damn. I am in the middle of my workday!) You are only nagged about security vulnerabilities if you actually call into the vulnerable code. The speedy compiler outputs a binary that can run on pretty much any computer of the right OS and architecture. You can trivially cross-compile. Everything that is tedious about the mechanics of making something that people can use largely Go away with Go. You can open up your editor, type in a program, and send it to other people to use. That's really nifty.

At the end of the day, Go isn't the last programming language society will ever develop. But you can make a lot of stuff with it. If you've ever been to an art museum, you might notice that you rarely see an example of some famous artist's pencil. You see their work. That's how programming languages should be; get out of the way, and let your work speak for itself. A lot of people really don't want their work to be front and center, and those people really don't like Go.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by foobarbazetc on Wednesday September 20, 2023 @12:57PM (#37586635)
This is an amazingly non-succinct write up of why I love programming in Go.

I think it, I type it, it works and it works fast, with minimal cognitive overload.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by alex_lav on Tuesday September 19, 2023 @10:11PM (#37579651)
Every post about Go becomes a pretty even split about why Go is terrible/behind the times/frustrating/obsolete, and why Go is productive/simple/awesome.

Maybe just let people like things?

Interestingly most posts about Rust also become about Go as well.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by rcme on Tuesday September 19, 2023 @10:18PM (#37579694)
No, my preference is the One True Preference!
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by hinkley on Wednesday September 20, 2023 @01:20AM (#37580620)
Nobody here talks about PHP. Should we be?
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by alex_lav on Wednesday September 20, 2023 @01:29AM (#37580689)
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by hinkley on Wednesday September 20, 2023 @12:15PM (#37586043)
> 1 point
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by yazzku on Tuesday September 19, 2023 @10:04PM (#37579604)
"There are many reasons to be excited about generics in Go."

There were also many reasons to be excited about generics in C++, back in 1998 lol.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by eru on Tuesday September 19, 2023 @10:15PM (#37579675)
And C++ was already 25 years behind the times back then, because ML had generics in 1973.
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by pjmlp on Wednesday September 20, 2023 @02:58AM (#37581207)
C++ compilers already had experimental template support in 1992, e.g. Turbo C++ for Windows 3.1.
Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by dchftcs on Wednesday September 20, 2023 @12:37AM (#37580425)
> This feels like such a non-news. They've pretty much created a language which is deliberately dumbed down to be 20 years behind other languages, then they are proud that they could speed it up with a feature that was fairly well-known almost 20 years ago.

Sounds like the average iPhone reveal to me.

Re:Shaving 40% Off Google’s B-Tree Implementation with Go Ge... by diogenes4 on Wednesday September 20, 2023 @01:19AM (#37580618)
> 20 years behind other languages

What a ridiculous attitude