Live data from Hacker News

Why I Don't Like Golang (2016)

teamten.com

191–200 of 237 posts

Re: Why I Don't Like Golang (2016)

#191
post #89

Earlier quoted context omitted.

Yes, and it's missing tons of things we take for granted in other langauges. If you look at the "strings" section it's so short. There aren't even convenience things like string reverse.

Why do you want a string reverse? - Do you want to reverse bytes, or codepoints? - Do you want to reveres codepoints, or grapheme clusters? - Do you really want to reverse grapheme clusters, or do you want to reverse some grapheme clusters while leaving e.g. sequences of control characters in the same order? - Do you really want to reify any of this rather than iterate backwards in the existing memory?

I think most people are expecting something along these lines:

C++: reverse(str.begin(), str.end());

Dart: str.split('').reversed.join();

Java: new StringBuilder().append(str).reverse().toString();

JavaScript: str.split('').reverse().join('');

PHP: strrev($str)

Python: ".join(reversed(str))

Rust: str.chars().rev().collect()

Re: Why I Don't Like Golang (2016)

#193

Earlier quoted context omitted.

Why do you want a string reverse? - Do you want to reverse bytes, or codepoints? - Do you want to reveres codepoints, or grapheme clusters? - Do you really want to reverse grapheme clusters, or do you want to reverse some grapheme clusters while leaving e.g. sequences of control characters in the same order? - Do you really want to reify any of this rather than iterate backwards in the existing memory?

I think most people are expecting something along these lines: C++: reverse(str.begin(), str.end()); Dart: str.split('').reversed.join(); Java: new StringBuilder().append(str).reverse().toString(); JavaScript: str.split('').reverse().join(''); PHP: strrev($str) Python: ".join(reversed(str)) Rust: str.chars().rev().collect()

Yes but why? Those expressions do wildly different things both in terms of language semantics and in terms of observable behavior and most of them haul in some heavy additional machinery from the language. Perhaps where it is present, this is a case where stdlibs have implemented it because it's easy to implement, and not because it's actually useful.

(What do I mean by wildly different things?

C++: Swaps the string's contents in-place, and probably breaks any multi-byte code units unless you've got a parameterized std::string at hand.

Dart: Makes a new string but has to round-trip via an array, because... it doesn't have a string reverse? This seems like a really bad argument for your side!

Java: Reverses codepoints, but the fact you have to round-trip through a StringBuilder to handle this is also telling.

JavaScript: Same comments as Dart, but I believe this is broken, it will reverse surrogate pairs incorrectly.

PHP: Good luck figuring out what this does depending on your platform, locale, and moon phase.

Python: Another codepoint reverse, again not via strings but a lazy sequence, and also not even idiomatic - use `str[::-1]`.

Rust: And finally again... not a string reverse.

You want a Go slice reverse? You can get a perfect one post-generics.)

Re: Why I Don't Like Golang (2016)

#194

Earlier quoted context omitted.

Putting fundamental features of the language behind a price barrier at all will keep students and people who want to experiment with the language out of the ecosystem. This isn't a papercut, it's an intentional omission that has backfired and can only be fixed by tooling. If the only way to access an often necessary feature is proprietary, why not make the whole language proprietary at that point?

The language has a tool that does this, and every editor I can think of uses it ( https://github.com/golang/tools/tree/master/cmd/guru ), specifically implements.go if you're interested.

Guru has been replaced by gopls, using the common LSP protocol.

Re: Why I Don't Like Golang (2016)

#195
post #99

Earlier quoted context omitted.

This isn’t true. Go has a basic standard package list. https://pkg.go.dev/std

Another big area that is lacking is Go makes it so hard if you want to use something other than a primitive as a hash key (Rust is guilty of this as well, mind you). This is something that should come out of the box in any modern language in my opinion.

The map key type can be anything for which `==` is defined. This includes structs for which `==` is defined for every field. Composite keys etc are trivial.

https://go.dev/ref/spec#Map_types

Re: Why I Don't Like Golang (2016)

#196

Earlier quoted context omitted.

I think most people are expecting something along these lines: C++: reverse(str.begin(), str.end()); Dart: str.split('').reversed.join(); Java: new StringBuilder().append(str).reverse().toString(); JavaScript: str.split('').reverse().join(''); PHP: strrev($str) Python: ".join(reversed(str)) Rust: str.chars().rev().collect()

Yes but why ? Those expressions do wildly different things both in terms of language semantics and in terms of observable behavior and most of them haul in some heavy additional machinery from the language. Perhaps where it is present, this is a case where stdlibs have implemented it because it's easy to implement, and not because it's actually useful. (What do I mean by wildly different things? C++: Swaps the string…

And reversing by codepoints is still wrong. It wrecks multi-codepoint sequences like flags.

https://go.dev/play/p/IsZBLqi7--1

Re: Why I Don't Like Golang (2016)

#197
post #167

Earlier quoted context omitted.

This is true for all typed languages though..

No, type inference avoids this issue.

Which Go has. https://go.dev/ref/spec#Type_inference

(Not to a level something like Typescript has it, but I'll argue that's a win. Typescript inferred typing can be hard to follow.)

Re: Why I Don't Like Golang (2016)

#198
post #107
post #15

Earlier quoted context omitted.

This is entirely off topic, but how are Elixir or Kotlin "modern C replacements"? Elixir is built off of Erlang and has influences from Ruby and Clojure, and Kotlin is a replacement for Java. Rust, Nim, Zig, and Go are all fair game in that list, as far as I know being a C replacement is in the mission statement for the creation of all those languages.

I literally don’t understand why so many people believe Go is a C replacement. Like it is by all means in the first camp of managed languages with a huge runtime.

Replacement for C in many areas it is used for != replacement for C in all areas it is used for

Re: Why I Don't Like Golang (2016)

#199
post #179

Earlier quoted context omitted.

Someone apparently isn't aware that IDEs can consume build scripts as project definitions. I don't duplicate anything, my CI/CD pipelines consume MSBuild, Ant, Gradle, Maven, CMake, XCode, package.json, gulp, webpack files just as easy as my IDEs.

Have fun clicking around until it works

Why would I need to do that?

Re: Why I Don't Like Golang (2016)

#200
post #180
post #178

Earlier quoted context omitted.

Game consoles, with their Windows based IDEs. Mainframes and embedded OSes, the latter with much more market share than all desktops together.

Are you programming on a game console???

> Game consoles, with their Windows based IDEs

Unfortunately English comprehension skills is a lost art.

Post reply on HN