Live data from Hacker News

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

benhoyt.com

51–60 of 207 posts

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

#51

I can agree with most of the article, but for some it looks like we have not been using the same language ecosystem at all. Go really feels opinionated around the wrong things, in order to claim "simplicity" as a feature: - No generics just mean you're going to be handing interface{} all the way in your stack, it makes things more complex and less readable for no reason (and less safe) - error handling which is essen…

> gofmt is a good idea (just like clang-format or yapf), and having it is great, but the maintainers specifically refuse to add simple features

This could be one reason why that is the case: https://xkcd.com/927/

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

#52
post #48

Earlier quoted context omitted.

> it's definitely a "Windows First" language C# used to be that but I don't think that's the direction anymore.

Which platform-agnostic GUI toolkit do you use?

HTML but there's always GTKSharp: http://www.mono-project.com/docs/gui/gtksharp/

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

#53
post #11
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…

YMMV, but my experiences with SBCL were way better than with Go. Using Hunchentoot and the other Quicklisp libraries made developing fun again. With Go I had to constantly worry about errors, repeat the same code snippets over and over again, had to comment out "unused" variables just to try something... not fun. That said, let's see how Lisp works out once I cross the 10'000 LOC barrier. But by then it won't be a mi…

The problem is getting people to actually code in CL or any Lisp. I haven't had that problem with Go so far.

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

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

Take a look at Elixir, it covers most of what you want.

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

#55
I'm not sure about Javascript, but why do you have to have two APIs when you have async? At least in C# you write the async version of the API and that's it.

Then you go asyncStuff.Request on it, and it blocks. There are some quirks but I remember that it worked all right.

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

#56
post #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 pro…

>they're generally a premature optimization

This example actually seems to be the opposite of an optimization. There's 50% more code to maintain and there appears to be almost no appreciable benefit to compensate for that.

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

#57
>However, it was only 1900 lines of Go (about 50% more than the 1300 lines of Python).

>However, I’d seriously consider using Go for larger projects (static typing makes refactoring easier)

Assuming a fully tested codebase and a relatively sane runtime type system, I'd much, much rather maintain the shorter codebase than the statically typed one.

Having less code makes refactoring easier.

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

#58
post #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 pro…

>they're generally a premature optimization This example actually seems to be the opposite of an optimization. There's 50% more code to maintain and there appears to be almost no appreciable benefit to compensate for that.

LOC is a bad measure for the complexity of code. Quite the opposite, expressive code can be faster to understand and easier to maintain than the same functions with half the code size.

In any case, switching to a compiled language and static types should bring some benefit, in addition to the gain in speed.

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

#59
post #26

Earlier quoted context omitted.

Kotlin covers all those features - much simpler than Scala while still being much more expressive than Java - clean syntax, with a higher consistency than e.g. Java - Generics, Higher Order Functions, Multiline-Strings, Destructuring, ADTs, Pattern Matching - Coroutines (experimental but production-ready) - IntelliJ Community Edition (or Ultimate) - not yet but will be possible with Kotlin Native - has its own ecosys…

I like Kotlin too, but in which way is it "much more expressive" in your opinion? What can you express in Kotlin that you can't express in Java? Scalas type system is much more expressive than the one in Java as an example. Only thing that comes to mind in Kotlin is non-nullable references. Most of the stuff in Kotlin looks more like less boiler plate (data classes) than "more expressive".

It's not immediately obvious, but when you write some Kotlin you'll see.

Little things that are a apin in Java and elsewhere are quick and natural in Kotlin:

- nullable types are smoother than Options - null checks are relatively painless - the stdlib works with you, not against - named parameters and optional parameters means no need for builders - etc. Etc.

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

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

UPDATE: Conda seems to be able to do just that.

conda create -n myenv python=3.6.3

conda install -n myenv scipy

conda install -n myenv numpy

conda install -n myenv pandas

source activate myenv # To make use of the environment.

source deactivate

conda create --name myclone --clone myenv. # Clones the environment.

du -sh /Users/asampath/anaconda3/envs/myclone

du -sh /Users/asampath/anaconda3/envs/myenv

813M /Users/asampath/anaconda3/envs/myenv

Fat environments. But, this works out just fine in our NFS mounted storage in cluster.

Post reply on HN