News for hackers. Stuff that matters.
Re:Half a million lines of Go by bilal4hmed on Sunday May 16, 2021 @01:20PM (#27175251)
Is Go no longer worth it to learn? Seeing a lot of posts where over the long term go code base is not fun to manage.

Was looking at my next language after python. Rust is one , should something like kotlin be the other ?

For interviews python seems to be nice and fast to type.

Re:Half a million lines of Go by Philip-J-Fry on Sunday May 16, 2021 @01:49PM (#27175527)
Go is 100% worth it. If you're seeing these posts on HN then you should know that the majority of Go posts here are just "why Go is bad" posts. You'll rarely find an upvoted post about why Go is good.

From a Go dev who came from .NET, Go is one the best tools I've learned in a very long time. Code is incredibly readable, I never come back to an old code base and have to wrap my head around the weird abstractions like "MapperServiceFactoryFactory" because they're no idiomatic. Code can be verbose, but the verbosity is what aids its readability.

I haven't had any issues maintaining large Go codebases, the only issues you come across are the same regardless of the language you use. And that's things like ensuring consistent style across a team of developers.

Re:Half a million lines of Go by dcow on Monday May 17, 2021 @12:30AM (#27180059)
I thought large Go codebases relied almost religiously on `gofmt`.
Re:Half a million lines of Go by Intermernet on Monday May 17, 2021 @04:36AM (#27181257)
There's obviously more to style than code formatting, but yeah, every Go codebase should rely on gofmt. I'd go so far to say that every language should have an equivalent to gofmt. There are so many advantages, the least of which is eliminating meaningless diffs in git where (for example) one person used spaces and put a new line before the opening brace of a function, while the other person used tabs and put the opening brace on the same line as the function definition. That drives me crazy in other languages!
Re:Half a million lines of Go by Matrixik on Monday May 17, 2021 @05:05AM (#27181427)
Or even better `gofumpt` that is more strict.
Re:Half a million lines of Go by cle on Sunday May 16, 2021 @01:33PM (#27175371)
I maintain hundreds of thousands of lines of Go code, for a few years now. I would not pick another language for that.

The important properties with maintaining code bases like that are language regularity (most code is written the same way and you don’t have to make personal “taste” decisions on things), good documentation and online communities, well-maintained libraries, tooling features for versioning and namespacing, deployment simplicity, etc. Go nails those things.

I agree that Python is great for interviews. I would not use it for a large codebase maintained by a bunch of people for years, unless there is a really compelling reason.

Re:Half a million lines of Go by mixmastamyk on Sunday May 16, 2021 @06:04PM (#27177444)
Typing is available now, and other QA tools for years.
Re:Half a million lines of Go by kuang_eleven on Monday May 17, 2021 @01:03AM (#27180224)
Python has all of those things:

- language regularity; black has been the default for years now, and if you want to enforce a different style, there are other tools

- documentation and online communities; not even a contest, no language comes close to Python in extensive documentation and online support

- libraries; much the same, Python standard libraries are world-class

- versioning & namespacing; Depending what you need from this, Python is again more robust, namespacing in Go is a disaster.

- deployment simplicity; ...alright, you got this one. Python deployment is harder than it should be. Still, I find my Docker images about the same complexity between the two; more complex deployment in Python, but no need for compilation

Re:Half a million lines of Go by cle on Monday May 17, 2021 @02:19AM (#27180535)
By regularity I mean much more than just style. Ironically Go does “one obvious way to do something” much better than Python. When formatting a string, should I use % operator, str.format(), or f-strings? If I want to make a data obj, should I use a regular class, dict, namedtuple, dataclass, or TypedDict? If I’m changing each element in a list do I use a list-comprehension, or loop, or map()? Even unit testing in Go is mostly converged on the stdlib framework, in Python it’s constant back-and-forth between unittest, pytest, and nose. Static typing? Mypy, PyRight, Pyre, Pytype, with varying degrees of IDE support. Speaking of IDE support, which of the 3 major LSP servers should you use? How do I specify dependencies, with raw pip, Conda, pipenv, or poetry? When setting up my dev env should I use virtualenv or venv, or do I not have to use it bc of pipenv or Conda?

(I only actually use one of each of those with my own code, but I have to know about them all to work in the ecosystem.)

Also IMO, Python’s stdlib comes nowhere close to the quality of Go’s.

Somehow despite all this I still enjoy writing Python, and use it sometimes for my personal stuff. But in a team setting on a large code base? Nah.

Re:Half a million lines of Go by ngrilly on Monday May 17, 2021 @02:45AM (#27180655)
Go namespacing works quite well in my experience. As well as Python. No idea what you mean.
Re:Half a million lines of Go by oconnor663 on Sunday May 16, 2021 @09:25PM (#27179107)
I'll say this as a huge Rust fan: If you're thinking about learning Go, just go ahead and learn Go. One of Go's strengths is that it's very quick to pick up, especially if you already know at least one statically typed language. You can get a good sense of it in a weekend, and then you can make an informed decision about whether you'd like to keep working with it or try something new. By comparison, even experienced programers take at least a few weeks to start feeling comfortable and productive in Rust.
Re:Half a million lines of Go by dcow on Monday May 17, 2021 @12:33AM (#27180066)
Make sure to write tests in Go before you decide. I liked Go a lot more in the honeymoon period after just learning the language before getting into the weeds of the amount of code required to ensure correctness. While rust takes longer to pickup, I strongly believe it pays dividends down the road.
Re:Half a million lines of Go by dangoor on Sunday May 16, 2021 @03:04PM (#27176102)
I hope you didn't get an impression like this ("Go not being worth it to learn") from my post. We think it's great and that our Go is going to be much easier to maintain over the long term than our Python was.

It's all rock solid and easily understandable by the whole team.

Re:Half a million lines of Go by bilal4hmed on Sunday May 16, 2021 @03:38PM (#27176368)
Thank you for the reply. I didnt get that impression from your post at all, but from the larger comments & posts on HN and programming subreddit. I have wanting to learn Go, but seeing so much negativity around it was making it harder to start learning.
Re:Half a million lines of Go by dangoor on Sunday May 16, 2021 @06:49PM (#27177840)
Go may be more polarizing than a lot of languages. It makes tradeoffs that aren't as exciting, which turns people against it, I think.

There are plenty of legitimate reasons to choose a different language, so it makes sense to figure out what's important for oneself and go from there. The only problem is that it's hard to know all of the aspects that may be important without trying a tool out... so we do, quite reasonably, turn to blog posts with other people's opinions.

I do think it's good to differentiate the opinions of people who have really worked with the tool vs. those who are just e.g. complaining about Go's error handling because they're used to exceptions but they haven't done any significant work with Go.

For deciding on whether or not to learn a language: I'd say it depends on _why_ you want to learn a language. If it's for getting a different job, then look at the kinds of jobs you want and learn the languages/skills to do that. If it's for pure knowledge, then learning languages that teach you something new are useful. Go's concurrency might be interesting in that regard. Rust's borrow checker is certainly interesting.

Re:Half a million lines of Go by nine_k on Sunday May 16, 2021 @07:17PM (#27178132)
It is of course worth learning, very much like Java, PHP, C, or Cobol. These languages are going to be with us for a long time, just because of the large amount of important code written in them.

If you want fun, you might consider other languages, like Ruby, or Clojure, or Rust, or Scala, or Elixir, or... But they are not going to be as much the foundation of corporate software, exactly because they are more expressive and require higher qualification to handle well. The languages from the first list, though, while more boring, provide a more certain piece of bread and butter.

Re:Half a million lines of Go by otter-in-a-suit on Monday May 17, 2021 @08:46AM (#27182798)
Don't think the HN bubble is real life. go, much to my surprise, has been pretty well accepted by companies that used to do Java and Python exclusively (at least in my experience w/ projects).

It's still insanely frustrating in many ways, but if you need code that is fast (i.e. faster than Python), typed (I don't think type hints are a valid replacement), where concurrency is not a never ending nightmare (or at least not any more than it needs to be), and compiles to native binaries, go is a great language to use that doesn't scare large companies away.

Re:Half a million lines of Go by spamizbad on Sunday May 16, 2021 @01:39PM (#27175436)
A language isn’t going to save you from a bad codebase. And the longer I work in this industry the more this has become apparent to me.
Re:Half a million lines of Go by baby on Sunday May 16, 2021 @01:43PM (#27175477)
It's funny but I'd still say that Golang is the easiest language to maintain, due to the code being harder to write but easier to read.
Re:Half a million lines of Go by wejick on Monday May 17, 2021 @12:56AM (#27180178)
I see there are a lot of go shop companies, basically most of "start-up ey" tech company use go in someway or another.

So I don't see why go is not worth to learn.

However depend on what engineer are you, IMHO go is one of the top mindshare language for backend services.

Re:Half a million lines of Go by iudqnolq on Sunday May 16, 2021 @08:07PM (#27178553)
What do you want to do? Rust would be a great pick for "systems" code, or anything where you need to talk to existing c/c++ code. Pretty good for CLIs if you're the sort of person who enjoys puzzles.

Definitely go for kotlin if you want to write a GUI. I'd also recommend Kotlin (or maybe go, never used it) if you want to write a server. Rust has ambitious but not there yet server frameworks, and it's quite hard to go off the beaten track with most Rust server frameworks (say if you want to write your own little cache layer).

I'm just a student, but I have the impression rust isn't a good choice for maximizing career prospects. Still writing it, because I love it.

Re:Half a million lines of Go by mplanchard on Sunday May 16, 2021 @09:40PM (#27179207)
As someone who just took a job writing rust recently, I have to disagree with your take on the career prospects. I specifically looked to switch to Rust in my last job search, and I had plenty of companies to apply to. The market also is only getting bigger, with all of the FAANG(M) companies now employing a significant number of rust engineers.
Re:Half a million lines of Go by sk1459 on Monday May 17, 2021 @07:36AM (#27182331)
I just did a search on Dice for jobs.

Java: 12,879 Golang: 4,339 COBOL: 321 Haskell: 18 Rust: 2

The Rust jobs also appeared to be blockchain related, so I wouldn’t count on that being a place that could get you to retirement. I would expect Rust is a requirement so a marketer add a bullet point in his or her slide deck.

Re:Half a million lines of Go by mplanchard on Monday May 17, 2021 @09:04AM (#27182930)
Yeah, there are fewer rust jobs in general because it’s a newer language, and blockchain is one of the areas it gained its earliest traction. Of the companies I applied to when I was looking for a rust job, though, only one out of five did anything related to blockchain.

I don’t know what Dice is, but Indeed, stack overflow, angel list, and google’s job aggregator all had quite a few rust jobs when I was looking. I also kept a spreadsheet of companies I had heard about who were using and hiring for rust over the course of the last couple of years at my previous job. In addition to FAANG and Microsoft, there were quite a few smaller shops like 1Password and Signal.

And the job I wound up taking has nothing to do with blockchain, fwiw

Re:Half a million lines of Go by iudqnolq on Sunday May 16, 2021 @09:44PM (#27179221)
That's really exciting to hear. I'm struggling with a cs degree (especially the mathier bits) at a mediocre school, and I think the sort of jobs looking for Rust are looking for a more traditional background. Still, I hope I'll get a job in Rust someday.
Re:Half a million lines of Go by mplanchard on Sunday May 16, 2021 @10:05PM (#27179363)
I know this is only anecdata, but I graduated from a state school (absolutely nothing fancy) with a biochemistry degree and switched to a programming job a couple of years later. I worked in Perl, Python, and JavaScript mostly for years, while picking up whatever interested me on the side, which included Rust.

The company I joined didn’t expect people to already be rust programmers, and I think about half of our engineers are from non-CS backgrounds. Experience counts for way way more than your degree once you’re a few years into the field.

So, keep an eye out! There’s plenty of stuff out there for whatever interests you, and most programming (even in a language like rust) is not super heavy on meatier CS concepts most of the time.

Re:Half a million lines of Go by kyawzazaw on Sunday May 16, 2021 @08:35PM (#27178734)
How do you write so much as a student?
Re:Half a million lines of Go by iudqnolq on Sunday May 16, 2021 @08:43PM (#27178786)
Procrastinating :) It's an average of around 15 loc/day, and I'm not great at going to sleep on time.
Re:Half a million lines of Go by alert0 on Sunday May 16, 2021 @06:43PM (#27177779)
Go is my favorite language but I'm still learning Rust. Would highly recommend either. I hate Python as a language but use it for web scraping and the occasional data transformation.