Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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}?


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.


Looking at the co routine example. Does the function type implicitly change when using co.sleep in the function body?


Any chance you missed “go” that turned the function into the future?


Congratulations on finishing this.

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


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.


There are some misspellings in the README, such as "natrue". Just FYI.


thanks, I'll fix it


Cool work! Just out of curiosity, what made you pick the name nature?


“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”


"Tao" might be more search-engine friendly than "nature".


Do you have plans to support WebAssembly target?


Plan to add wasm backend




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: