Live data from Hacker News

Go is my hammer, and everything is a nail

maragu.dev

501–510 of 816 posts

Re: Go is my hammer, and everything is a nail

#501

Earlier quoted context omitted.

Not a programmer, so this is every programmer's chance to hammer me on correctness. No, Go doesn't have a type named Dict, or Hash (my Perl is leaking), or whatever. It does have a map type[1], where you can define your keys as one type, and your values of another type, and that pretty closely approximates Dicts in other languages, I think. [1]: https://go.dev/blog/maps

So, these types (and many more) are hash tables. https://en.wikipedia.org/wiki/Hash_table They're a very common and useful idea from Computer Science so you will find them in pretty much any modern language, there are a lot of variations on this idea, but the core idea recurs everywhere.

I have a quibble here. A hash table, the basic CS data structure, is not a two-dimensional data structure like a map, it is a one-dimensional data structure like a list. You can use a hash table to implement a Map/Dictionary, and essentially everyone does that. Sets are also often implemented using a hash table.

The basic operations of a hash table are adding a new item to the hash table, and checking if an item is present (potentially removing it as well). A hash table doesn't naturally have a `V get(key K)` function, it only naturally has a `bool isPresent(K item)` function.

This is all relevant because not all maps use hash tables (e.g. Java has TreeMap as well, which uses a red-black tree to store the keys). And there are uses of hash tables besides maps, such as a HashSet.

Edit: the term "table" in the name refers to the internal two-dimensional structure: it stores a hash, and for each hash, a (list of) key(s) corresponding to that hash. Storing a value alongside the key is a third "dimension".

Re: Go is my hammer, and everything is a nail

#502
I recently tried to setup a PHP / Laravel dev environment on Suse Linux box. Installed PHP and all the stuff accordingly, then following one of the get started doc from Laravel. You know what happened? Doesn't work, broken. I assume that way Laravel created Sail, which I didn't use. Much different case with Go, installing the toolkit and development environment is easy. Even with free vscode, everything is just work, PHP+Laravel seems encourage you to buy all dev things.

Re: Go is my hammer, and everything is a nail

#503
post #430

That's why Typescript is my hammer, unless I need a jack hammer, which is Rust. With Deno and Typescript I get an even more versatile toolbox than with Go. And what's even more important to me, Typescript is safer and more ergonomic than Go, but slightly slower. Rust is safer, more ergonomic and faster than Go, but much harder to learn. Especially strict (which is a must) Typescript is underrated. Compared to Go, we…

- Typescript doesn't protect you at all against external data. - A Go program runs single-threaded, unless you explicitly tell it not too, so I don't quite see that as a plus for Typescript. - Go is quite a bit faster than Typescript. - I haven't had a versioning problem in Go, and I can still compile and run old code. Typescript still beats Python in that respect, but Go wins stability. And I say this as someone who…

> - A Go program runs single-threaded, unless you explicitly tell it not too, so I don't quite see that as a plus for Typescript.

I don't think this is a fair comparison. Almost all software needs some kind of concurrency, and multi-threading is the only way to do concurrency in Go. For example, the http server in Go's stdlib runs each request in its own goroutine, which I guess you technically asked for, but also can't be avoided.

Re: Go is my hammer, and everything is a nail

#504
post #502

I recently tried to setup a PHP / Laravel dev environment on Suse Linux box. Installed PHP and all the stuff accordingly, then following one of the get started doc from Laravel. You know what happened? Doesn't work, broken. I assume that way Laravel created Sail, which I didn't use. Much different case with Go, installing the toolkit and development environment is easy. Even with free vscode, everything is just work,…

At the same time using purely php is about as convenient as it gets. Just rsync, ftp or scp your index.php to the server and deployment is done.

PHP+Laravel is more akin to ruby on rails or python django. Pure PHP is similar to Go in terms of the deployment scenario

Re: Go is my hammer, and everything is a nail

#505
post #47

The author lists multiple reasons for this, but for me the biggest one is the first one: Go is good for almost everything . I have extremely good productivity when using Go. Once your project exceeds 100 lines it is usually even better than python. And yes, I am aware that Rustians did a survey where Rust was crowned as the most efficient language but in my reality (which may differ from yours) Go is simply the best…

Builtins well thought out? Have you seen the bignumber api?

Re: Go is my hammer, and everything is a nail

#506
post #224

Earlier quoted context omitted.

If I had one complaint, it’s the use of ‘tags’ to configure how json is handled on a struct, such that it basically becomes part of the struct’s type. It can lead to a fair bit of duplication of structs whose only difference is the json handling, or otherwise a lot of boilerplate code with custom marshal/unmarshal methods. In some cases the advice is even to do parse the json into a map, do the conversion, and then s…

As an aside, you may be interested in some of the ongoing work to improve the Go JSON serializer/deserializer: https://pkg.go.dev/github.com/go-json-experiment/json

That’s some good news that will hopefully smooth json handling out.

Re: Go is my hammer, and everything is a nail

#507
post #476

Earlier quoted context omitted.

> and Java is shockingly bad too, although a lot of that is down to the way the JVM/language have been mismanaged This is interesting and not what I would expect. Generally to get a java app running from github you'd install the correct JDK and that should be about it. Many projects will use maven, which will know how to obtain dependencies. Could you describe a typical issue?

Does Maven come bundled with the SDK?

It's an additional install, like the jdk. Typically on a brand new os install the equivalent of these steps would be done:

    sudo apt-get install   
    sudo apt-get install maven
And then you'll be good to go.

Re: Go is my hammer, and everything is a nail

#508

Earlier quoted context omitted.

Go is not good for data science and ML. It doesn't even have a proper, maintained dataframe library for data-science. R and Python beat it hands on. Rust also beats it now thanks to polars. And mobile ? gomobile is not maintained. Fyne is amateur level on mobile. AFAIK Go has no maintained 3d game engines. Go has its well-established niche for middle-ware services and CLI tools. And that's about it. If your domain is…

Is the reason for the absence of a well-maintained dataframe library lack of demand? It looks like Gota and Dataframe-go are abandoned, while Gonum isn't particularly active. Did these wither on the vine because no one used them?

[deleted]

Re: Go is my hammer, and everything is a nail

#509
post #490
post #419

Earlier quoted context omitted.

2012: Python is Awesome! 2014: Python is a pain in the butt to manage packages and dependencies, how the hell am I gonna deploy this? It's still a mess 10 years later unless you live deep in the ecosystem and know what third-party solutions du jour to manage that complexity. At least we have Docker now. Also let's not forget the Python 3 migration fiasco that lasted ~2008-2018 and I still find myself porting librarie…

chore(omfg): fix print to print()

I have a feeling that you've never dealt with sequences of bytes (encoded strings) in Python 2.

Re: Go is my hammer, and everything is a nail

#510
post #169

I've been coding in Go for over five years. I like Go, but I don't love it. It's never my first choice, although I don't advocate for rewrites just to move away from it. The tooling is a mess. Go modules still feel like a 'first pass' implementation that never got finished. There's no consistency in formatting or imports (even though Go claims there is). Generics are a good step but are still very primitive (no gener…

Not sure what you're comparing to, but Go modules are probably the best dependency management system in any language.

Exactly. What is he even comparing go modules with? npm and pip? The dependency disaster management which keeps breaking unless I create a new virtual environment for every project?
Post reply on HN