HNHacker News
TopNewBestAskShowJobs

hualaka

50 karma · joined September 22, 2023

submissionscomments
hualaka··on Show HN: I wrote a Java decompiler in pure C language
When debugging complex projects, the C language is more flexible and convenient to view data in memory.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
custom backend
hualaka··on RenderFormer: Neural rendering of triangle meshes with global illumination
How efficient is neural rendering at this stage for game rendering?
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
Calling C code can solve most performance and ecosystem issues. Nature natively implements the system ABI for various operating systems and CPU architectures, enabling C code libraries to be called at extremely low cost. In Go, a separate thread + hook is required to call C functions.

I have not yet considered GPU-related features.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
In my view, a compiler is a text transformation tool that converts high-level descriptive text languages into the format required by the target machine. Target machines typically have two specifications: operating system specifications and CPU specifications. As long as the final generated binary encoding satisfies both, it can run on the target machine. For example, Linux systems have ELF program loading specifications, while ARM64 manufacturers have CPU instruction specifications. As long as the CPU can recognize the binary encoding, it can command the CPU to perform the required computations.

In concrete implementation, it is usually necessary to convert high-level text languages into an Abstract Syntax Tree (AST), perform necessary detection and optimization based on the AST, and then convert it again into a lower-level Linear Intermediate Representation (LIR). After performing necessary detection and optimization on the LIR, the LIR can be converted into readable assembly instructions required by the target CPU. Further implementing an assembly instruction conversion tool converts the readable assembly instructions into binary encoding that the CPU can recognize.

Next, this set of binary encodings is wrapped into an executable file according to the operating system's requirements, ultimately obtaining a file that can run on the target device. Since a compiler is a text transformation tool, it can run this tool on any device - this is the essence of cross-compilation.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
“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”

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
? Commonly used for nullable types.

The tup is an interesting question. I often think about tup(int, bool, string) vs (int, bool, string). I convince myself that there might be a better choice.

`var t = (1 as i8, true, false)` Use automatic inference to replace active type declarations.

t.0 vs t[0] is equally difficult to choose, but t[0] is the more commonly used syntax. Using t[n] consistently across map/vec/set/tup might be the more correct decision.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
I really enjoy thinking about such issues. I actually spend a lot of time considering whether to use type prefixes or suffixes, [] or <>, and ultimately settled on “<>”.

In my opinion, the change from `<>` to `[]` is a minor adjustment. `<>` is already widely adopted, and I don't want to break with convention for such a small benefit.

The position of the type is similarly considered. Postfixing the type has some advantages over prefixing it, but those advantages aren't sufficient for me to break with convention.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
That's a very good point, and I agree with you. I will adjust the relevant wording and use words such as “system” more carefully.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
This is the Natural Selection interstellar spacecraft from the Three-Body Problem novel. In fact, the disc-shaped part is the head.

I tried to draw this logo myself, but my drawing turned out rather ugly. The lines of the Millennium Falcon closely match my imagination of the Natural Selection spacecraft's appearance, so I borrowed its lines.

However, this is not permanent. In fact, the name “Nature” may be modified because it is not SEO-friendly.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
Yes, public, I won't add pub syntax. But maybe there will be a label provided for the editor to recognize, but this won't be the main route.

#local fn test() {

}

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
Thank you for finding the discussion from two years ago. The usable version took me another two years to complete. Focusing on implementation caused me to neglect collaboration and promotion, and I fell into many misconceptions.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
thanks, I'll fix it
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
Plan to add wasm backend
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
I will consider the issue.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
I use Go for IoT devices in my work, such as routers and TV boxes, which run on RISC-V/MIPS/ARM32/ARM64, etc. I appreciate its portability; even on devices with only 512 MB of memory, I don't have to worry about memory overflow issues.

I believe nature is equally suitable.

hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
Without using Go's asm, directly translate it into assembly code for the target system, then link and cross-compile it.
hualaka··on Show HN: Which hand do you type faster with? - leftright.space
It would be more interesting if we could count whether the left or right hand pressed the space bar, but there is only one space bar, so this is not possible. I think alternating between both hands to press the space bar is the most balanced way.
hualaka··on Show HN: A new programming language inspired by Go, no LLVM
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.
hualaka··on Show HN: Hardtime.nvim – break bad habits and master Vim motions
I didn't even realize I had these bad habits.
hualaka··on Show HN: Nature – Modern System-Level Programming Language and Compiler
I've already watch, this grammar is pretty good.