Live data from Hacker News

Go is my hammer, and everything is a nail

maragu.dev

521–530 of 816 posts

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

#521
post #103
post #67

Earlier quoted context omitted.

It's not really about Go, I think. But it makes me productive, and I like that. I don't think it's a magic bullet at all. Lots of things annoy me about it. But it's _good enough_ for quite a lot of things IMO. But tying shoes with a chainsaw does sound kinda fun. :D

I completely understand, but the productivity is superficial in my opinion, once you need to dig your teeth deeper into anything not "cloud" and "system engineering" with Go, overall productivity plummets hard. This is from some 10 years of Go experience. But like you say, it is not really about Go; my point is about the illusion of productivity that familiarity brings; it is very deceptive and hurts productivity in…

Very few languages are good at _everything_.

But what I do 95% of the time is backend services with APIs and CLI tooling, for both it's amazing.

For GUIs it's hit and miss. There are some attempts at tooling, but they all feel a bit off to me. But Rust the same issue, as does C#.

We need a modern Visual Basic again =)

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

#523
post #322

Earlier quoted context omitted.

Perhaps I’m thick but what kind of programming doesn’t involve data wrangling? What are Go programmers doing that they don’t feel the need for map/filter/etc? BTW there’s no reason why map and filter would be slower than loops, efficiently lowering such functions to loops was solved a very long time ago.

> What are Go programmers doing that they don’t feel the need for map/filter/etc? As a refugee from a scala project that went badly (we eventually ported the entire thing to go), it's not so bad when you're just using map and filter and friends. But eventually there's so many of those little methods each with their own nuances and I don't want to have to remember them all (`sliding` comes to mind), and it's just exha…

Thank you for sharing your experience and I am sure it is right for you. And I agree that Scala can be too much.

I just wanted to point out that there is a fundamental reason that for loops are inferior to map/reduce when working with data.

For loops is "how" where map/reduce is "what" and that puts the burden on you when you need to parallelize your job.

Joel Spolsky described it here (long ago)

https://www.joelonsoftware.com/2006/08/01/can-your-programmi...

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

#524
post #17

I wish Go had a decent UI framework though.

Can you give me an example of a decent UI framework? Or frameworks? (I'm not a GUI programmer, but I've been dabbling a bit using Fyne. I figured that in the C++/C# sphere UI frameworks especially on Windows were sorted out until I read an article by some frustrated individual who listed all the problems he has with various UI frameworks on Windows. So I realized that perhaps this isn't as well sorted as I thought. I…

Anything that has a visual designer where I can combine drawing and drag&dropping components and code depending on my needs.

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

#525
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.

Between conflating imports and URLs, the weird go.mod syntax, and the nonsense that are GOPROXY, GOPRIVATE and such, yes, it’s a mess.

Honestly, aside from left-pad stuff, even npm is much better. I personally find cargo to be the best one I’ve tried yet. Feature flags, declarative, easy overrides, easy private registry, easy mixing and matching of public/private repos through git, etc. And like go it properly handles multiple versions of the same dep being used, but the compiler will help you when it happens.

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

#526

Earlier quoted context omitted.

> The pain of dealing with JSON in Go is one of the primary reasons I stick mostly with nodejs for my api servers. Unless you're dealing with JSON input that has missing fields, or unexpected fields, there is no pain. Go can natively turn a JSON payload into a struct as long as the payload's fields recursively match the struct's fields! If, in any language, you're consuming or generating JSON that doesn't match a spe…

This. In $other_language you'll parse the JSON fine, but then smack into problems when the field you're expecting to be there isn't, or is in the wrong format, or the wrong type, etc. In Go, as always, this is up front and explicit. You hit that problem when you parse the JSON, not later when you try to use the resulting data.

Go's JSON decoder only cares if the fields that match have the expected JSON type (as in, list, object, floating point number, integer, or string). Anything else is ignored, and you'll just get bizarre data when you work with it later.

For example, this will parse just fine [0]:

  type myvalue struct {
    First int `json:"first"`
  }

  type myobj struct {
    List []myvalue `json:"list"`
  }
  js := "{\"list\": [{\"second\": \"cde\"}]}"
  var obj myobj
  err := json.Unmarshal([]byte(js), &obj)
  if err != nil {
    return fmt.Errorf("Error unmarshalling: %+v", err)
  }
  fmt.Printf("The expected value was %+v", obj) //prints {List:[{First:0}]}
This is arguably worse than what you'd get in Python if you tried to access the key "first".

[0] https://go.dev/play/p/m0J2wVyMRkd

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

#527

Earlier quoted context omitted.

My personal Python threshold is 10k lines. After that I tend to loose track of what I am doing and I start to miss static typing and nowadays, an IDE to navigate it. Maybe future Python IDEs can AI scan the codebase and compensate.

Wait... in what year was this comment written ? ;) There's type hinting and IDEs do navigate it.

optional hints

Both make them much less useful than in a typical statically typed language. Besides that, the tooling sucked hard not too long ago.

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

#528
post #120

Earlier quoted context omitted.

Go is the only language I've ever felt highly productive working in. Oftentimes in other stacks I find myself in analysis paralysis on meta things that don't matter: - what design patterns/language features make sense to use - what is the best lib to accomplish X - how do you keep things up to date With Go, the language is so simple that it's pretty difficult to over engineer or write terse code. Everything you need…

I do programming interviews and I found candidates struggling a lot in doing http request and parsing response json in Go while in Python its a breeze, what makes it particularly hard, is it lack of generics or dict data type?

I've done, literally, hundreds and hundreds of coding interviews and an http api was a part of lots of them. Exported vs non-exported fields and json tags are about the only issues I've seen candidates hit in Go and I would just help in those kinds of cases. Python is marginally easier for many.

The problem was java devs. Out of dozens upon dozens of java devs asked to hit a json api concurrently and combine results, nearly ZERO java devs, including former google employees, could do this. Json handling and error handling especially confounded them.

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

#529
post #494

Earlier quoted context omitted.

At least for Python dependency management, I'd hardly call it a mess these days and yes it was a horrible 10 years ago. The de-facto standard of venv and pip (using a requirements.txt file) is generally painless these days. To the extent that moving between MacOS, Linux and Windows is feasible for most (of my) Python work. And the Python 2/3 pain stopped being an issue a few years back. I haven't been forced because…

It still won't beat the deployment speed of scp executable user@host:direc/tory/ that you get with Go. I still use python for stuff that never leaves my computer, but in most cases if I know I need to run it on Someone Else's Machine (or even a server of mine) I'll reach for Go instead.

I agree with you, though if you live in a Linux+podman world, you can literally scp whole containers, so at least we made some progress.

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

#530
post #136
post #95

Earlier quoted context omitted.

How is it different than, say, java for this generalist purpose?

As someone who isn't super proficient in Java I usually find Java daunting to get started with full of buckets of "meta" issues like in my other comment. What JVM do I use? Does it matter? Does it matter what version I install, what if I have to install/manage multiple versions? If I want to write a web service can I use vanilla Java stdlib or do I have to use Spring or some framework? If I use Spring, do I have to g…

> What JVM do I use?

latest LTS (longterm-support) version, so currently 21, next 25 (late 2025).

> Does it matter?

new is always better

> what if I have to install/manage multiple versions?

https://sdkman.io/

> If I want to write a web service can I use vanilla Java stdlib or do I have to use Spring or some framework?

Spring

> If I use Spring, do I have to get into the weeds of dependency injection

yes, but it's not hard (or I've done it long enough)

> other complexity

that might just be inherent complexity when have to deal with a webservice. personally I dislike have to configure security

So basically go to Spring Initializr (https://start.spring.io/) pick the latest LTS Java&Maven (or Kotlin&Gradle-Kotlin) and You're off to the races.

Post reply on HN