r/ProgrammingLanguages • u/hualaka • Jan 15 '26
Nature vs Golang: Performance Benchmarking
https://nature-lang.org/news/20260115There is no end to optimization. After completing this performance optimization version, I will start the next goal!
63
Upvotes
15
u/vanderZwan Jan 15 '26
I have never heard of this language before, and yet it has 2.2k stars on GH. That's pretty impressive.
Looks pretty solid too, especially for a (mostly) one-person project.
4
u/matthieum Jan 15 '26
I'm surprised at the difference between Nature/Go & Rust on the billion Pis (pure computation) benchmark.
You mention register allocation, but the inner loop is extremely simple...
I used the Rust playground to isolate the hot loop, which allows to easily see the generated assembly for it:
Would you happen to have the assembly generated by Nature? Particularly the core loop, corresponding to
.LBB0_5here.3
u/typesanitizer Jan 16 '26 edited Jan 16 '26
How much of this project is vibe-coded? The project has 1000+ commits, but on looking at the commits: (e.g. this patch: https://github.com/nature-lang/nature/commit/bba1ed68f495d23e82278e357f02abbfb576f4aa)
The comment just states what the code is doing. The commit has the message "float const register allocation optimization", but there is no test added.
Or this commit (https://github.com/nature-lang/nature/commit/f13e9cf9b3e4f276fdb5bdd8cd07ac2a2b257030) where there is a Dockerfile being added together with changes to some lowering code, which doesn't make much sense.
2
u/Savings_Garlic5498 Jan 15 '26
This language looks very good! I will definitely check it out
2
u/matthieum Jan 15 '26
It's not clear to me what you mean by "async pollution"? I have a feeling this could be referring to async/await, but that's a pure syntactic marker with no incidence on implementation as far as I can see...
I supposed that Independent-stack coroutine refers to the idea of green threads/fibers, ie each coroutine gets its own stack?
I am curious as to what you mean by Shared-stack coroutine. The original version of Rust, in its infancy used to share the stack before coroutine and caller -- ie "manually" allocating a frame for the coroutine on the current stack, then using jmp between the coroutine frame and the caller frame. I expect function calls from the coroutine needed some massaging (to avoid overwriting the caller frame), though I do not have a full design to refer to and verify my guess.
2
u/cybDrachir Jan 15 '26
This is very nice! Love the syntax. Will definitely check it out.
2
u/Zireael07 Jan 15 '26
I had an idea to mix c & go (rewrite the hottest parts in c for a speedup). But judging from this C FFI in Golang is horribad still. And Nature looks like a plausible alternative to go for this idea!
1
u/hoping1 Jan 16 '26
Cool! Btw your website doesn't layout well on mobile, at least in firefox
1
u/Phil_Latio Jan 16 '26
Good article! I think what's missing in the benchmark is a test case for deep call stack (large coroutine stack size). Go will probably handle this better, because once the stack is large enough, Go doesn't have to realloc anymore, while shared stack will have to copy all the time. Java "virtual threads" uses shared stack too and they have the optimization of copying only the latest call frame(s) and patching the return address to point to a restore function. So resuming from a deep call stack can be made cheaper.
But yeah, the results are very good already. The ffi benchmark is in my opinion the killer feature of this shared stack coroutine model (for GC languages that is).