|Re: [hatari-devel] offtopic: Golang|
[ Thread Index |
| More lists.tuxfamily.org/hatari-devel Archives
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] offtopic: Golang
- From: Chris Jenkins <cdpjenkins@xxxxxxxxx>
- Date: Mon, 30 May 2022 22:36:16 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=y4L7GvVQGuHQK/gU7JsEyYXMWYfUYP3MDZsR3pHj2bg=; b=WNW5DzB1/jQlprh9qsN+ahasML8myj0VHLFuJStqDeAphKQN7s09uISWSgLXk+qYJ2 mPKlJFiJbuJlgKJadVurRyKu9bFowuJiGtvprpodGnpviIqVcfV1dMC5YSY6qLQl4CYA BnwPuAm31UpchUGdAjrkTQkn5Kaw1LuI6tCNPgIS4nxrZOB0DX/48qslhnXbARNq6NUe YkyWiP48jHurpmMafeE4ojt1sH+T0i9csqIUUh3n25JyZguFrWgFYYluXsMaJ/tgcgIr avH1oKEfxuqqQS5Z/awByRA2Ee9GxQS5niuXN/AoOR43lOWoeNQK4jD+rweOVAznmNqm /bbQ==
Many thanks for that. I'll let you know if/when I do try golang. We have quite a few serverless apps and microservices that run in containers, which are mostly written in Kotlin or Java. They are pretty slow to start up and golang is one of the things that we were thinking of trying in order to make it better. (Of course, we may just end up building stuff using GraalVM Native Image instead in order to avoid having to introduce a new language :-). It's really interesting to hear your observations and there's a lot in golang that I like the look of.
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
* 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
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.
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.