Re: [hatari-devel] offtopic: Golang

[ Thread Index | Date Index | More Archives ]


On 29.5.2022 13.14, Chris Jenkins wrote:
(I added relevant commit IDs to commit message
and fixed indenting, as your code editor seems to have replaced some
tabs with 4 spaces.)

Thanks for fixing the indenting (and sorry for introducing it). I used VS
Code, which is normally good at auto-detecting indentation style. I guess
not for objc code... :-/

No problem, that's trivial to fix, and easy to see from "git diff" output.

PS. Within last year or two I've learned Golang, which is fairly nice
mix between C and Python. While I have some reservations for the
language itself, I'm in love with its tooling.

E.g. code formatting is a builtin feature which means that one run "go
fmt" after every change / before commits, without even needing to check
the results, which is not the case with C (and Objective-C used by Mac

And Golang tooling is lightning fast as parsing speed is one of the
design goals of the language...

I really must try golang some time. I know an increasing number of people
that use it and they say good things about it.

Latest version added support for Generics which was last main thing missing from the language.

My main reservations about it are the same for many of the new languages, which are also one of their strengths:
* Automatic pulling of deps from net, if they are not yet present locally
* Not using standard libs, but re-implementing everything in that same language * Everything being compiled from scratch to same binary, so that there's no extra code in it (except for libc, unless it's built statically)

This is perfect match for cloud containers when you have (money for) automation that builds everything constantly from scratch, but an update nightmare from distributions when there's security issue in one of the commonly used components.

I.e. it works fine for cases where one wants static binaries, not so well when wants to integrate with existing libraries. I.e. it's not for GUI stuff.

Things that I like in the language compared both to C and Python:
* channels + go routines which make threading easy
* "defer" + "error" type which make error handling easy

Some of the other things I like in the language compared to C:
* garbage collection, support for returning local variables, and <object>.<member> working regardless of whether <object> is value or reference, which ease memory handling
* "range", which makes iteration easy

If one needs to do complex hierarchies of data, that's much easier with Python, at least in prototyping phase. Golang's strict typing gets into to way for that.

	- Eero

PS. "range" was also one of the annoyances until I understood that by default everything in Golang is by-value, not by-reference like in Python. One needs to explicitly use reference types to be able to impact passed & iterated items, unlike in Python.

Mail converted by MHonArc 2.6.19+