Readit News logoReadit News
avestura · 8 months ago
Maybe I have a too strict definition of systems programming languages, but I would never call a GC language a systems programming language. Who would use an operating system that suddenly stops the entire world because some random language's runtime wants to collect its memory garbage?

That said, well done for making this.

ksec · 8 months ago
>but I would never call a GC language a systems programming language....

Lilith: x86-64 OS written in Crystal (github.com/ffwff). [1]. And Crystal has GC.

[1] https://news.ycombinator.com/item?id=21860713

ac130kz · 8 months ago
Probably they meant that GC introduces a certain level of uncertainty, whereas OS or "systems" programming leans heavily towards manual handling (except when the compiler allows to avoid it, not the runtime).
hualaka · 8 months ago
I think you have some stereotypes about GC. In fact, current GC technology only requires a very short STW. Of course, I agree with your opinion, so this is not the final form of nature. I will find a better technology to assist GC.
virtualritz · 8 months ago
I think it's rather the other way around. What parent said, even though they prefixed it with a 'maybe' to make their statement less confronting, is that you used the term "systems programming language" too freely. As is also the case with Go.

If people keep doing that, the term will eventually loose meaning. Maybe in 20 years, it will have eroded enough that something like Python will be called a "systems programming language". I mean after all, a printf statement in C also parses the format string at runtime. Who is to say the fact that all of the code is interpreted should thusly exclude something like Python? I'm being sarcastic, if that wasn't obvious.

Nature claims 'concise'ness in it's README's opening paragraph. That is laudable. It's even more laudable if the conciseness would also be reflected in the use of natural language (no pun) that describes it.

Calling it a "systems programming language" while using GC is IMHO eroding the meaning of the term.

Something meaning X and someone including Y and then someone pointing out that X does not include Y has thusly nothing to do with stereotypes here.

MangoToupe · 8 months ago
Tbh, I've completely abandoned the concept of a systems programming language because the primary benefit of the concept seems to be to argue over it. There's practicality (eg can i link this into the kernel?) and then there's hand-waving about how it feels to a developer, and the conversation seems almost entirely subsumed by the latter.

See also: "is C a high-level or low-level language?" Just shoot me instead, please.

js8 · 8 months ago
Somewhat agree, but it depends. I agree that core of the operating system (kernel) should be responsive, but there are many tasks in the operating system that don't require immediate response and can be run in batch. Usually these are higher-level decisions, such as any housekeeping tasks like file backup and indexing, workload reprioritization and optimization, system update and reconfiguration, and the like.
lionkor · 8 months ago
Yeah, then you write a GC or use a library ;)
Tabular-Iceberg · 8 months ago
Isn't this a problem of allocating and freeing resources being generally non-deterministic, regardless of what algorithm is used?
WhereIsTheTruth · 8 months ago
From the website:

"Nature is... A general-purpose open-source programming language and compiler designed to provide developers with an elegant and concise development experience, enabling them to build secure and reliable cross-platform software simply and efficiently."

avestura · 8 months ago
That's true. However the website also promotes it as a systems programming language here and there. For example in the same homepage it says "Perfect for Systems Programming: Operating systems and IoT" and some other places like here: https://nature-lang.org/docs/get-started
heavyset_go · 8 months ago
Define operating system, the higher up the stack you go the less things like GC matter.

I wouldn't care if my network daemon was written in Python or not, but I would care if the networking stack itself was.

repelsteeltje · 8 months ago
> the higher up the stack you go the less things like GC matter.

But suppose the very top of stack is high frequency trading system or traffic light controller. Car brakes...

Depending on your stack, determinism may or may not be a key part. And that is only possible if determinism is guaranteed all the way down.

alexpadula · 8 months ago
Wowow. GO to not be used with systems programming? Absurd.
surajrmal · 8 months ago
go is ill suited for many systems programming environments. It works well on servers and larger iot devices with 512+ mib off ram, but not great on things with tighter constraints. We tried to use it for our netstack implementation for years and ultimately came to the conclusion we needed to switch to a language with greater control. Storage, RAM, and CPU usage were all improved with the switch. I don't consider it a systems programming language but rather something approaching systems programming.
alexpadula · 8 months ago
My jaw dropped when I read your comment.
9rx · 8 months ago
If your program isn’t a system, it is unlikely that you need to worry about freeing memory at all — It will be cleaned up when finished.
Zefiroj · 8 months ago
in a sense, RCU is garbage collection.
hualaka · 9 months ago
I am the author of the nature programming language. You can find code examples and a playground to try it out on the official website at https://nature-lang.org I would appreciate your feedback.
gonzus · 8 months ago
Nice work. Some questions / observations:

Can you add methods to any type? There is an example of adding a method to a builtin type (string) -- can you add also add a method to a union type?

Any plans to add some sort of enum type? If yes, will it be possible to add methods to enums?

How do you support (or intend to support) Unicode? It says "Strings use ASCII encoding" -- why not UTF8?

The example with a timeout channel does not show how / when the timeout will be triggered. Is this a special kind of channel?

It says "Packages will be synchronized to the $HOME/.nature/package directory" -- will this respect the XDG standard directory structure, which defaults to $HOME/{.cache,.local,.config}?

hualaka · 8 months ago
1. nature can add methods to built-in types, example

fn int.to_string() { }

I haven't considered whether union types can add methods, so I tested it, and it seems to be possible, but this may cause some unexpected behavior, so maybe I should disable this possibility for now.

type test_t = int|null

fn test_t.hello() { println('hello world') }

2. Enum support is planned. I plan to use type declarations. Why hasn't enum been added yet? Nature has adopted a conservative syntax design, and I hope to hear more opinions and avoid affecting existing functionality as much as possible when adding syntax features.

type weekly = enum {}

So methods can be added to enums.

fn weekly.found() { }

3. UTF-8 should be solvable via a library. I haven't thought much about UTF-8 yet, but if it can enhance nature's usability, I'll implement it as soon as possible. Usability is a key focus for nature moving forward.

4. Select{} timeout handling does require a special timer channel, which will be addressed in the standard library. Currently, it can only be handled via ch.try_recv() and ch.try_send(), which do not block the channel.

5. Actually, this is the first time I've heard of the XDG standard. I will study and understand the specification.

---

I am not an experienced programming language designer, so thank you for your questions. I will carefully consider them.

je42 · 8 months ago
Looking at the co routine example. Does the function type implicitly change when using co.sleep in the function body?
Simpliplant · 8 months ago
Any chance you missed “go” that turned the function into the future?
nextn · 8 months ago
Congratulations on finishing this.

If you were to do this again, how would you organize the source code differently?

hualaka · 8 months ago
I am more in favor of flat code organization, but I probably won't use C to implement a compiler again, as it involved a lot of unnecessary work. Zig or Rust would be better choices.
gonzus · 8 months ago
There are some misspellings in the README, such as "natrue". Just FYI.
hualaka · 8 months ago
thanks, I'll fix it
gautamcgoel · 8 months ago
Cool work! Just out of curiosity, what made you pick the name nature?
hualaka · 8 months ago
“Tao follows nature” (道法自然) is a phrase from classical Chinese philosophy, and it is the design philosophy behind the nature programming language. It can be understood as being natural and intuitive. I hope that nature can build upon Go's ‘less is more’ philosophy and achieve ‘Tao follows nature.’

Unfortunately, nature is not SEO-friendly, so the name has received a lot of criticism. Therefore, I am considering changing it to a name that starts with ”na”

WhereIsTheTruth · 8 months ago
Do you have plans to support WebAssembly target?
hualaka · 8 months ago
Plan to add wasm backend
intalentive · 8 months ago
Why should I care whether LLVM is used? What’s the advantage?
IshKebab · 8 months ago
LLVM is very big, takes ages to compile and compiles code relatively slowly. Also because it was designed to compile C there are occasionally C-isms that make it suboptimal for other languages with different properties. (Although a hobby project is never going to beat its performance even accounting for that.)
zer0zzz · 8 months ago
That’s what mlir is for
hualaka · 8 months ago
Faster compilation speeds, more customized error handling, and convenient cross-compilation. I believe this is a promising direction for the future development of programming languages. Zig has already made significant progress in this area.
mbel · 8 months ago
Probably the compilation time is better than it would be with LLVM. On the other hand I doubt that codegen and therefore performance is on par with LLVM.

Definitely a weird thing to advertise.

hualaka · 8 months ago
This is an advertisement, and I usually don't put “no LLVM” in the title or use it as a promotional feature.

I posted this project on HackNews a few times, but it quickly sank to the bottom. Maybe “no LLVM” might pique some people's interest in the project, so I added it. Actually, I posted this link a few days ago and had already given up on it, but unexpectedly, it suddenly appeared on the HackNews homepage.

I now need some attention, which will give the Nature project more capital.

Dead Comment

thayne · 8 months ago
I like a lot of things about this, and it addresses some of my complaints about go.

But I'm confused on why strings use ascii encoding instead of utf-8. What if you need non-ascii characters?

ivanjermakov · 8 months ago
Zig solved this by not having a string type at all and not shipping full Unicode support in std: https://github.com/ziglang/zig/issues/234#issuecomment-27630....
MangoToupe · 8 months ago
That attitude as described feels like chucking a large portion of the benefit you get from leaving C out the window.

But...

> But at that point, why does it need to be part of the language? Would not a standard library module suffice?

This indicates zig is desired to ship with unicode support—just not part of the core language runtime. Now this I can support—unicode doesn't require core runtime support. Most programs don't have a need for unicode text normalization, for instance, so why would you need this without linking in a standard library? But the idea of not shipping unicode in your standard library rightfully died decades ago.

Notably, this doesn't imply:

* source code being ascii

* string literals being ascii

* unicode string processing not being immediately available in the standard environment

So I'm not sure which behavior is being described here, but I certainly consider utf8 support to be table-stakes for language design in 2025. Without this a language is a toy. I'm not going back to using ICU and will fight anyone who encourages me to.

hualaka · 8 months ago
I will consider the issue.
nlitened · 8 months ago
Impressive work, but how is it better/different from Go or other programming languages? What would be one’s motivation to switch to this language?
thayne · 8 months ago
It looks like it addresses some of go, including:

- a better type system, that includes union types, and makes types non-nullable by default

- pattern matching

- designed with generics from the beginning

- try/catch error handling. This is controversial, and some people like checking every return value for errors, but it is a common complaint about go

- it looks like it is meant to have better c interop than go

ksec · 8 months ago
Feels to me like it is Go++. Or may be Go+ / BetterGo.

And in a very good sense.

hualaka · 8 months ago
vlang is a Golang-like programming language. I will use vlang as an example,

v has the same syntax as golang and is derived from it. But otherwise, v is moving closer to rust, with immutability, bounds checking, and so on.

Here's a discussion of vlang's implementation of coroutine https://github.com/vlang/v/discussions/11582 Until recently, vlang has not supported coroutines very well

The syntax of nature is different from golang. But everything else is the same as golang, including goroutine, GC, channel, cross-compilation and deployment, and even free programming ideas, less is more, and so on.

I think these features are the best thing about golang, even in front of all programming languages. That's why I'm trying to see if I can create a better golang.

In the early stages of availability, I would not advise others to switch to nature, as this would be irresponsible. When nature is sufficiently advanced, the situation will be different.

mountainriver · 8 months ago
Those design decisions by Go are what caused the need to trampoline to C right? How does nature fix that? Does it work well with GPUs?
WhereIsTheTruth · 8 months ago
Nice, the kind of project everyone should support, a language with a fully working backend for both X86/ARM

Clean source code too, impressive project

whobre · 8 months ago
There are many platforms other than x64 and aarch64; that’s the main advantage of using llvm.
hualaka · 8 months ago
nature will support more major platforms and wasm. also linux_riscv64 is in the process of being supported and I've done most of the work.
arthurcolle · 8 months ago
the name of the programming language should be in the title, I'm sorry but come on
hualaka · 8 months ago
You're right, but nature doesn't seem to be a good name, it gets a lot of criticism because its not search engine friendly. Maybe I should change the name before nature becomes popular.
codeptualize · 8 months ago
Love this, definitely rooting for this to get big!

I think the goal is great. My dream language is something "in between Go and Rust", Go but with more expressive types, Rust-light, something along those lines. This seems like it is hitting that sweet spot.

Imo Go gets a lot right when it comes to productivity, but the type system always annoys me a bit. I understand the choice for simplicity, but my preference is different.

Rust is quite enjoyable, especially when it comes to the type system. But, kinda the opposite of go, it's a lot, maybe too much for me, and I frequently don't know what I'm doing haha. I also don't really need Rust level performance, most things I do will run totally fine with GC.

So Go with some extra types, same easy concurrency, compilation and portability sounds like a winner to me.