Live data from Hacker News

Learning Golang – From Zero to Hero

milapneupane.com.np

21–30 of 76 posts

Re: Learning Golang – From Zero to Hero

#21
post #10
post #8

Earlier quoted context omitted.

I agree. I would guess the "why" is that Rust is capable of everything that Golang is capable of, except more and better. Not to mention that Rust has a very supportive community to help each other.

Clearly there's more to it otherwise Go and other languages would be a thing of the past. This is really not a topic for language flamewars and it's even against HN guidelines. I don't understand why people need to scream rust in every other language post like if it was a religion.

No language is a thing of the past, since there are lots of projects and codebases written in it. Hell, people still using PHP and Perl. But they are not the first choice for starting a new project.

What will happen is that with time no greenfield project will be started with Golang and it will gradually become a legacy language.

Re: Learning Golang – From Zero to Hero

#22
post #20
post #10

Earlier quoted context omitted.

Clearly there's more to it otherwise Go and other languages would be a thing of the past. This is really not a topic for language flamewars and it's even against HN guidelines. I don't understand why people need to scream rust in every other language post like if it was a religion.

Devil’s advocate here : i think it’s due to the promise rust makes that borrow checkers prevent you from writing unsafe code or race conditions, as well as high level abstractions with zero performance cost. That set of promises really would make any programmer go crazy i think, and become a zealot. Rust is definitely on my todo list, i’m just waiting for the language to mature a little bit more, because some edges s…

It's not free though. There's a hefty price to be paid in complexity. I am as "crazy" for Rust as I am for Ada.

I suspect that is one of the reasons why behemoths like Uber, Twitch.tv, Stripe and Walmart chose Go over Rust.

Re: Learning Golang – From Zero to Hero

#23

Go's not existent standard library is almost a deal breaker for me. The lack of even a dynamic array (c++ vector, Java arraylist) means you write a lot of 2-3 lines of slice notation phrases that require stopping and thinking about indices you wouldn't need to in other languages (and creating a lot of zero length slices for boundary conditions that shouldn't be needed). Also no balanced tree is a big issue (googles s…

> The lack of even a dynamic array Are go slices not dynamic arrays? They grow automatically when necessary.

They are, but also very difficult to work with. For example, removing an element is a copy, followed by a slice notation. Inserting is combination of appends and slice notation. You don't get simple methods like insert(index,item). Also if you are growing the slice in a function, you need to find a way to return the possibly new slice variable since append might need to realloc so you often have to resort to using pointers to slices as inputs. They just aren't easy to deal with.

And you can have memory leak issues if you forget to zero a reference since the backing array still holds the reference. And none of that is efficient. A lot of temps and unnecessary copying going on.

Re: Learning Golang – From Zero to Hero

#24
post #10

Earlier quoted context omitted.

Clearly there's more to it otherwise Go and other languages would be a thing of the past. This is really not a topic for language flamewars and it's even against HN guidelines. I don't understand why people need to scream rust in every other language post like if it was a religion.

No language is a thing of the past, since there are lots of projects and codebases written in it. Hell, people still using PHP and Perl. But they are not the first choice for starting a new project. What will happen is that with time no greenfield project will be started with Golang and it will gradually become a legacy language.

Vague statements like this contribute nothing to the conversation.

Specially when they go against data https://www.jetbrains.com/lp/devecosystem-2019/

> Go - The most promising programming language. Go started out with a share of 8% in 2017 and now it has reached 18%. In addition, the biggest number of developers (13%) chose Go as a language they would like to adopt or migrate to.

And this https://research.hackerrank.com/developer-skills/2019

> Go is the language that developers want to learn the most in 2019

Re: Learning Golang – From Zero to Hero

#25

Go's not existent standard library is almost a deal breaker for me. The lack of even a dynamic array (c++ vector, Java arraylist) means you write a lot of 2-3 lines of slice notation phrases that require stopping and thinking about indices you wouldn't need to in other languages (and creating a lot of zero length slices for boundary conditions that shouldn't be needed). Also no balanced tree is a big issue (googles s…

I (and seemingly other people) consider https://www.techempower.com/benchmarks to be a good set of performance benchmarks for use cases many people around here would be facing. I guess they haven't been updated in nearing a year though. Go does reasonably well but apparently gets beat by Java. More generally. I like the idea of community driven benchmarks where each community tries to make representative, performant…

I don't do any a lot web stuff but most of my go code is quick hacks for data analysis or display but this is still really interesting.

I had a feeling go was slow, but I didn't expect such poor performance numbers. Some of that is probably the heavy reliance in reflection. For example they json parsing you need to go to the bottom of the list to find a go program, and go's json library makes extensive use of reflection and tags to guide the parsing.

It is somewhat ironic that go's big feature was AOT compilation static type checking, but it seems to immediately devolving into reflection and parsing tag key value strings to do anything. I had a typo on one of those they other day and could find the bug for an hour.

Re: Learning Golang – From Zero to Hero

#26

Earlier quoted context omitted.

> The lack of even a dynamic array Are go slices not dynamic arrays? They grow automatically when necessary.

I think the dynamic array in this context means an array with multiple / any types as value. Example: [1, "hello", true]

[]interface{} be like: "Am I a joke to you?"

Re: Learning Golang – From Zero to Hero

#27

Earlier quoted context omitted.

> The lack of even a dynamic array Are go slices not dynamic arrays? They grow automatically when necessary.

They are, but also very difficult to work with. For example, removing an element is a copy, followed by a slice notation. Inserting is combination of appends and slice notation. You don't get simple methods like insert(index,item). Also if you are growing the slice in a function, you need to find a way to return the possibly new slice variable since append might need to realloc so you often have to resort to using po…

> You don't get simple methods like insert(index,item).

This is by design, to lift the CPU and allocation costs to the foreground. You can argue that was a bad design decision, but it wasn't an oversight, as you imply in the OP.

Re: Learning Golang – From Zero to Hero

#28

Earlier quoted context omitted.

> The lack of even a dynamic array Are go slices not dynamic arrays? They grow automatically when necessary.

They are, but also very difficult to work with. For example, removing an element is a copy, followed by a slice notation. Inserting is combination of appends and slice notation. You don't get simple methods like insert(index,item). Also if you are growing the slice in a function, you need to find a way to return the possibly new slice variable since append might need to realloc so you often have to resort to using po…

(edit: exactly what sagi said, only more long-winded) :

Removing an item from a list (that is actually performant enough that you'd want to use it) in Java is also a copy though, unless you're removing the last element. Underneath the hood, there's a copy. Same deal with insert.

Given the number of times I've seen insert or remove used where it really, really shouldn't, I'm not so sure the lack of insert/remove is a bad thing.

But yea I do get that general feeling that golang sort of... distrusts the programmer. Like the opposite of C++, where it assumes you're God, but then happily vaporizes you with God-powered-lasers.

Re: Learning Golang – From Zero to Hero

#29
post #18
post #2

Info about workspace is outdated. Go modules allows you to to work outside GOPATH

agree, newbie to golang, just started with go1.13beta1 which will make go-module preferred to GOPATH/workspace.

The default mode is already `auto`, which checks if you're within GOPATH (if GOPATH is set) and defaults to mod if you're not.
Post reply on HN