Live data from Hacker News

Learning Go by porting a medium-sized web back end from Python

benhoyt.com

31–40 of 207 posts

Re: Learning Go by porting a medium-sized web back end from Python

#31
post #10
post #7

Earlier quoted context omitted.

I really wish that there was a language which had these features: - simple (so not Scala, Haskell, Perl 6, etc.; no Rust either, unfortunately) - clean (nice syntax, preferably Python inspired, but consistent) - modern (generics, some functional features, string interpolation, etc.) - decent concurrency/parallelism story - good IDE, preferably supported by the core dev team - compilation to a (possibly static) native…

C# actually already has most of that except for "compilation to a (possibly static) native binary", which is really just a convenience for shipping. It's also not really very cross-platform, it's definitely a "Windows First" language.

I'd recommend continuing to look into .NET Core. It's really quite stable these days and has all of the features you've mentioned, as well as C# having a lengthy history as a language. Knowledge is relatively transferrable amongst JS (especially TypeScript) developers, as well as Java developers. This puts you into an area where finding capable people is easy and cost-conscious (vs. niche languages.) Historical baggage has also been trimmed with .NET Core, and Microsoft has done well maintaining the language over time (adding new concepts and removing old ones.)

In a couple years, .NET Core will be even more stable and will surely have convinced the stragglers in the community to adopt it. (I'm seeing this is already mostly the case, because everyone likes not being locked into Windows.)

I'm a pretty big fan of .NET Core (coming from Node.JS) and I really do expect it to grow a lot in the next few years as people discover how easy and sane it is.

Re: Learning Go by porting a medium-sized web back end from Python

#32
post #7
post #3

Recently I have had the opportunity to write a microservice in Go. It was a very refreshing experience switching from Scala. Go is a lot faster to compile and runs with a far smaller footprint. The channels are nice. On the other hand the testing feels wrong because its so annoying to do mocks. And don't even get me started on the dependency management. Overall Go feels to me like some version compiled PHP with bette…

I really wish that there was a language which had these features: - simple (so not Scala, Haskell, Perl 6, etc.; no Rust either, unfortunately) - clean (nice syntax, preferably Python inspired, but consistent) - modern (generics, some functional features, string interpolation, etc.) - decent concurrency/parallelism story - good IDE, preferably supported by the core dev team - compilation to a (possibly static) native…

Swift is a potential competitor in this space too.

Re: Learning Go by porting a medium-sized web back end from Python

#33
post #30
post #27

Earlier quoted context omitted.

Yeah, but Kotlin Native loses all the Java libraries. The more interesting thing would be Java native compilation coupled with Kotlin. So you'd write a Kotlin Java app and pass that through the Java native compiler introduced in Java 9. Unfortunately that's a beta feature right now, I think it only supports Linux x64, that's why I said Kotlin 2019, I assume that by then the Java native compiler will support all Java…

Java compiles to native code since version 1.0, only not for free. All commercial JDKs had this option in one form or the other, and many of them are still around. If you want to try this for free on open source projects, Excelsior JET is one option.

I'm probably too conservative, but I'd rather use these kinds of things from the actual platform developers. I'm a bit more liberal with libraries, but in general I want the compilers/interpreters from the upstream source. Software has enough bugs as is :)

Re: Learning Go by porting a medium-sized web back end from Python

#34
post #5

Earlier quoted context omitted.

Coming from a data science background, don't anaconda and environment description files [1] solve this problem with python? Not even sudo is needed to install anaconda and setup / clone environments, also it can manage python versions independently from the system's python. [1] https://conda.io/docs/user-guide/tasks/manage-environments.h...

Thanks for your comment. I have just started using Conda locally to learn before taking it to work. I'm a new sysadmin and my predecessor maintained a restricted list of python packages on all cluster systems like a dictator. I don't want to be one. Does conda cloning the environment mean I can just copy the project directory to another server and expect my program to run without it looking for the packages on the in…

I'm not sure about Conda, but virtualenv already does that.

Re: Learning Go by porting a medium-sized web back end from Python

#35

Earlier quoted context omitted.

Other than the compilation to binary, Elixir seems a good fit for what you're looking for

Elixir compiles to bytecode which is not half bad

Pretty much everything compiles to bytecode (e.g. Java does, Python does, C# does, …)

I expect they want a native binary (possibly even statically linked) so they can trivially distribute the artefact without requiring that the VM be installed or bundled which is a PITA, in which case "compiles to bytecode" is useless.

Re: Learning Go by porting a medium-sized web back end from Python

#36
post #28

Earlier quoted context omitted.

Nim has everything nailed down except the ecosystem/commercial backing; It does have some of those, but not to the extent that I would blindly tell you they are there. It's as fun as writing Python (with a similar syntax), but it has essentially all the goodies you want from Lisp when you need them, runs as fast as equally optimized C, produces standalone native binaries, _or_ standalone JavaScript if that's your thi…

I wish there was a Go->Nim compiler or a way to simply import stuff from Go :) I'm just half-joking to be honest.

Go can generate .so/.dll usable from C; Nim can use them.

Re: Learning Go by porting a medium-sized web back end from Python

#37

Earlier quoted context omitted.

Thanks for your comment. I have just started using Conda locally to learn before taking it to work. I'm a new sysadmin and my predecessor maintained a restricted list of python packages on all cluster systems like a dictator. I don't want to be one. Does conda cloning the environment mean I can just copy the project directory to another server and expect my program to run without it looking for the packages on the in…

I'm not sure about Conda, but virtualenv already does that.

Oh really? You can't move a virtualenv folder around on a single machine. If you move it to the same location on a different machine, does it work?

Re: Learning Go by porting a medium-sized web back end from Python

#38
post #37

Earlier quoted context omitted.

I'm not sure about Conda, but virtualenv already does that.

Oh really? You can't move a virtualenv folder around on a single machine. If you move it to the same location on a different machine, does it work?

It does work, AFAIK, but you can also move it around on a single machine if you rerun "virtualenv " on the env (it fixes the links). It's been a while since I've done that, so I'm not sure if it still works, but it should.

EDIT: Yeah, just tried it again, it rewrites the shell files so everything works again. It even uses the same python version as you used.

Re: Learning Go by porting a medium-sized web back end from Python

#39
What I've noticed, and personally experienced, about these porting projects is that they're generally a premature optimization but are a great way to learn a new language. The gains from a port are largely intrinsic in nature, residing with the programmers. However, systems and operations largely carry on just fine with the original language chosen.

Only one story comes to mind where a programmer had a legitimate problem using a high-level language and solved it with a lower-level language, and that was Armin Roacher, who solved a significant performance issue using Rust: https://blog.sentry.io/2016/10/19/fixing-python-performance-...

Can you think of other stories? Please, share.

I encourage all to be more skeptical about potential gains and realistic about who is actually gaining.

Re: Learning Go by porting a medium-sized web back end from Python

#40
post #33
post #30

Earlier quoted context omitted.

Java compiles to native code since version 1.0, only not for free. All commercial JDKs had this option in one form or the other, and many of them are still around. If you want to try this for free on open source projects, Excelsior JET is one option.

I'm probably too conservative, but I'd rather use these kinds of things from the actual platform developers. I'm a bit more liberal with libraries, but in general I want the compilers/interpreters from the upstream source. Software has enough bugs as is :)

Commercial JDKs, like from IBM or OEMs for embedded platforms, are the actual platform developers.
Post reply on HN