Hacker News new | past | comments | ask | show | jobs | submit | himujjal's comments login

This. Writing a parser in Zig is so simple. Just allocate once, and then start writing your parser.

One allocator for parser, one for scanner. One for type allocation. Keep them all for semantic analysis. Write the output renderer (binary/language). Deallocate.

In this whole process, it makes it so easy to not think about memory anymore. Just enjoy writing your program.


The scanner can probably be zero allocation though - zig should be able to express an iterator over the input byte array that returns a token on dereference without needing more state than the position in the array


Is there a detailed blog post or a book or something you can share that shows how easy it is to write a parser in zig?


Neovim user detected!


This is state of the art. It will take time before Tigerbeetle themselves release their state machine as a library.

They have done some incredible job. Implementing things I didnt know existed about software/hardware.


I dont know if you want to monetize this. But I suggest make it open source.

You will receive tons of improvements and updates. I love this idea!


I loved Nim when I used it first.

But I left it because of recursive imports. I had to basically put all my types into one file and use them from various others. For a relatively medium sized project (~10LOC), its a but of a hassle. Refactoring is an issue.

That being said, the language is fantastic. Can anybody with experience suggest me what HTTP library/framework do they prefer for servers?


The lack of recursive imports can be annoying, but I found I don't mind it. It keeps your module tree into a DAG.

Chronos is probably the most feature rich and uses async. Mummy is newer and uses a threading model. Both are used in production.


Node and Python also don't really work with circular imports.


Python doesn't work with circular imports. NodeJS does. After using NodeJS for such a long time, I think it is a feature that is taken for granted.

That being said, the Nim team is working on it as per a few issues: [1] https://github.com/nim-lang/rfcs/issues/6 [2] https://forum.nim-lang.org/t/2114

I love the language, and this is probably the only bottleneck for me.


Node really doesn't work with circular imports. There are runtime gotchas with it, for example destructuring a cyclic import via require() will give undefined for the destructured values as they "don't exist yet".

Glad to see progress on the Nim side!


Go through Zig’s Async. Its a bit like co-routines but low level. You are required to keep track of memory allocations and pointers to function “frames”. For someone coming from a high-level language POV, frames were a new concept. But Zig does it so superb.

Zig just needs some runtime event loop like Tokio or AsyncIO from Rust to get up and running with its fantastic async model.


Did you check their Wiki? Have a nice set of gifs


So, its not just me!


Yeah. This is what people miss. I have always seen Space missions as an investment into the future.


I think people would be more inspired by functional basic services and increase railway safety.


given that space is hard, any progress in this direction has real and practical repercussions for all of humanity; for example, knowing how to handle metals, chemicals, mechanical systems, logical systems (production chains and industrial production), lighter and more powerful computers, human biology and so on

furthermore, the fascination with space missions generates hordes of inspired children who will study and thus this plant the seeds of scientists for future generations who will solve tomorrow's problems (in practice, it is a long-term investment)

of the race to the moon we now have the practical and common use of transistors and chips, led, batteries, pace makers, medical pumps, thermal insulation and dozens of other things we use and take for granted every day

to prefer little and bad immediately at the expense of much and good in the future is a very short-sighted and stupid attitude


What makes you think India hasn't been investing in railway safety? While the recent accident was unfortunate, number of railway accidents have been decreasing over years. Here is an infographic:

https://cdn.statcdn.com/Infographic/images/normal/30152.jpeg


if only countries can multitask but of course they can only work on space OR railway safety. such a shame.


No one is inspired by this, its simply expected.


Waiting for V to hit 1.0. It is going to be a game changer once everything is up and running at its best.


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

Search: