Live data from Hacker News

Learning Golang – From Zero to Hero

milapneupane.com.np

31–40 of 76 posts

Re: Learning Golang – From Zero to Hero

#31

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]

it's referring to the 'length' of the datastructure being able to change, not the types composed by the array-ish thing.

Re: Learning Golang – From Zero to Hero

#32

skip Golang, go straight for Rust EDIT: as my time for learning new programming languages is limited, I would invest it in learning Rust, rather than learning Golang or learning both of them. IMO the only reason to learn Golang is if your already have a legacy Golang codebase or if you want to contribute to various open source projects written in Go, like for example Kubernetes (my first experience with Golang was tr…

I've been learning Go these days and have enjoyed it quite a bit. Rust is also on the menu this year. Aside from the Rust book, do you have any suggestions on learning material?

Re: Learning Golang – From Zero to Hero

#33
post #28

Earlier quoted context omitted.

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…

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

Heavy reliance on such, as if they were free, is a very scripting-language thing. They hide all the grossness of such operations at the cost of significant memory bloat and inefficiency with simple, known-size structures (in order to make the more dynamic style run semi-fast at all).

There's no magic, and none of it's free, it just feels like it when you're push() and pop() and insert()ing all over the place. Making string manipulation closer to its roots as an array is also nice, in Go. If it's not worth bringing in a whole heavy library to deal with the awkwardness, then it wasn't worth writing the code that way to begin with. Figure out your lengths, resize as little as possible. Abuse and/or ignorance of how this all works is a big part of why we Can't Have Nice Things (performance, battery life) in the Age of Javascript.

Re: Learning Golang – From Zero to Hero

#34
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…

Rust doesn't prevent race condition.

Re: Learning Golang – From Zero to Hero

#36
post #7

This[0] is the best way I've seen to learn Golang. It's exactly what I needed to make things stick and make sense. 0: https://quii.gitbook.io/learn-go-with-tests/

I completely agree - I've worked through most of this as well and I feel it is a really great way to introduce someone to the language. It seems to me that a lot of languages would benefit from this style of tutorial or introduction.

Re: Learning Golang – From Zero to Hero

#37

skip Golang, go straight for Rust EDIT: as my time for learning new programming languages is limited, I would invest it in learning Rust, rather than learning Golang or learning both of them. IMO the only reason to learn Golang is if your already have a legacy Golang codebase or if you want to contribute to various open source projects written in Go, like for example Kubernetes (my first experience with Golang was tr…

> There are lots of overlapping technologies in our space and learning all of them is a huge time waste

I agree.

That's why I invested time into looking at Go over Rust.

Go will be the better choice for most programs most developers will write. Go 2 even more so. Rust is too complex, and for the applications where a garbage collector is acceptable (>99% of them) it isn't worth it.

Re: Learning Golang – From Zero to Hero

#38
> With a buffered channel, the receiver will not get the message until the buffer is full.

This is wrong. https://golang.org/doc/effective_go.html#channels

> Receivers always block until there is data to receive. If the channel is unbuffered, the sender blocks until the receiver has received the value. If the channel has a buffer, the sender blocks only until the value has been copied to the buffer; if the buffer is full, this means waiting until some receiver has retrieved a value.

Re: Learning Golang – From Zero to Hero

#39

Such a great language. If only it had a good GUI library...

I have made very good experiences with the GTK bindings for go (https://github.com/gotk3/gotk3). As the GTK Api is C-Based, it fits conceptually very good to Go. Actually I consider the Go bindings even better than using GTK from C, as the thin object model GTK uses, translates well to Go structures, most functions become methods on those structures. And the Go garbage collector solves the memory handling of the GTK structures.

Re: Learning Golang – From Zero to Hero

#40

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…

Go standard library is excellent, that comment makes no sense.
Post reply on HN