News for hackers. Stuff that matters.
Re:Twelve Years of Go by kryptonomist on Wednesday November 10, 2021 @02:47PM (#29179629)
To me, the greatest advantage of Go is the build time, which is almost instant. So you get the joy of programming like in Python/Js, being able to test very quickly your code, without having to deal with stupid errors coming from type mismatch or function parameters.

Plus, you get the performance of a compiled language, with a simple syntax. Sure, you get just slightly better results with C/C++/Rust, but then you deal with complicated OS level calls, memory and library deployment issues (problems fixed by Go). Yes, a few benchmarks show C#/Java almost as fast, but at the price of a highly optimized syntax not seen in any average programmer. An average guy get superb performance with Go without complications from day 1.

And absent object oriented features are quickly forgotten.

Re:Twelve Years of Go by throwaway894345 on Wednesday November 10, 2021 @03:01PM (#29179844)
> So you get the joy of programming like in Python/Js, being able to test very quickly your code

Ironically the canonical Python type checker, code formatter, etc take ages to run on even small code bases.

Re:Twelve Years of Go by bobbylarrybobby on Wednesday November 10, 2021 @03:10PM (#29179973)
I think a lot of that is that Python doesn't launch a server that handles code analysis/formatting requests, so every time you want to do another round of things-to-do-on-save, they all have to do be done more or less from scratch (some info can be cached between runs, but if you're launching a Python process that's like 100ms right there...). I imagine if there were a Python code server that handled formatting and type checking without ever shutting down, it would be quite speedy.
Re:Twelve Years of Go by bombela on Wednesday November 10, 2021 @03:22PM (#29180158)
I have some sort of python language server running with neovim to highlight type errors. This is definitively not fast to add errors. But being asynchronous it's palatable.
Re:Twelve Years of Go by MapleWalnut on Wednesday November 10, 2021 @03:28PM (#29180252)
Mypy provides a server to help with this called dmypy: https://mypy.readthedocs.io/en/stable/mypy_daemon.html
Re:Twelve Years of Go by wbobeirne on Wednesday November 10, 2021 @03:22PM (#29180155)
Check out https://github.com/microsoft/pyright, it's pretty snappy if you don't mind some JS in your ecosystem.
Re:Twelve Years of Go by ryandvm on Wednesday November 10, 2021 @03:03PM (#29179889)
C#/Java are almost as fast, but not for immediate execution environments. If you have one off invocations of the code, Go executables will beat the pants off Java as you wait for the JVM to fire up and for HotSpot to kick in.
Re:Twelve Years of Go by jpavel2 on Wednesday November 10, 2021 @03:29PM (#29180262)
I write a variety of CLI tools for my own use in Java.

On this low-end Chromebook (Samsung Chromebook 3 with a Celeron N3060 @1.60GHz) I can start the JVM, load the classes for my CLI program, and print a help message,

    jpavel@penguin:~$ time rcr -h
    Usage: RCloner <config path> get|put <entry> [args]
           RCloner <config path> list
    
    real    0m0.316s
    user    0m0.208s
    sys     0m0.126s
in less than 1/3 of a second. And this is with stock openjdk version 1.8.0_302, which doesn't include the startup time improvements of Java 10 & 12.

Sure, I wouldn't write utilities meant to be piped one into another, but for standalone CLI tools, the JVM startup time isn't prohibitive at all.

Re:Twelve Years of Go by leodriesch on Wednesday November 10, 2021 @04:54PM (#29181449)
I think he was talking more about serverless functions, where 300ms longer for answering an HTTP-request would be pretty long.
Re:Twelve Years of Go by azth on Thursday November 11, 2021 @01:18AM (#29185010)
See GraalVM: https://quarkus.io/
Re:Twelve Years of Go by throwaway894345 on Wednesday November 10, 2021 @03:09PM (#29179958)
I've heard smart people argue convincingly that the JVM doesn't actually take long to fire up, and that this is something of a myth. It may take a bit of time for the JIT to optimize, but that shouldn't impact basic CLI tools (un-JIT-ed code is basically just interpreted code, and that runs quickly enough). I'd be curious to hear from people who have looked into this.
Re:Twelve Years of Go by kaba0 on Wednesday November 10, 2021 @04:44PM (#29181329)
For smallish programs, a recent JVM will start up in 100ms. This is enough to make some CLI tools (like eg. git, with many separate invocations that return almost instantly) slightly bad to use, but longer running CLI tools are perfectly fine with it. There is also Graal to AOT compile classes and that way the startup time is truly negligible.

What actually increases JVM startup time is class loading, as it has to do byte code validation and the like for each new class. This is only apparent for largish frameworks though.

As for JIT, there is no much point for short-lived programs. Like, most python scripts are run without that and people write prod code in it.

Re:Twelve Years of Go by ed25519FUUU on Wednesday November 10, 2021 @03:09PM (#29179957)
Maybe fast in principle but rarely in practice. I’ve never once worked in a Java codebase that started up shorter than 5 or 10 seconds.
Re:Twelve Years of Go by maleldil on Wednesday November 10, 2021 @03:11PM (#29179994)
> C/C++/Rust, but then you deal with complicated OS level calls

What OS-level calls are you doing in C++/Rust that you aren't in Go?

> library deployment issues (problems fixed by Go)

How is Go's library tooling better than Cargo? I believe Go's is strictly worse, with its URL-based imports and how it deals with major versions.

Re:Twelve Years of Go by Thaxll on Wednesday November 10, 2021 @03:16PM (#29180084)
I think OP is talking about single binary with no dependencies here.

As for go mod, yes it's not perfect but it's as powerful as Cargo. https://golang.org/ref/mod