logoalt Hacker News

NJVL: Nim's New Intermediate Representation

70 pointsby generichumanlast Thursday at 1:44 AM8 commentsview on HN

Comments

elcritchlast Saturday at 10:09 PM

It's an interesting take on an IR. It's goal is to support the current C/C++/JS backend but also to make generating native assembly easy to do as well.

It also doesn't rely on lexical scopes to do analysis for things like lifetimes, nil tracking, destructors, etc. Instead it uses the versioned variables AFICT to enable those features more directly. Should be much simpler for the compiler implementation for 99% of cases versus traditional SSA blocks.

Unfortunately I'm busy writing Nim code and not able to play with the new Nimony compiler framework. I'm excited about incremental compilation and borrow checking features though.

digdugdirklast Saturday at 10:00 PM

Nim seems to be almost a pet project of a single individual. Is that just my interpretation or is it an actual representation of reality?

If it is correct, and mostly created by one person - how? Are they a genius? Is creating your own programming language from scratch something anyone can accomplish if they just go for it?

Or is it just something that shouldn't be trusted/used for commercial purposes because it's not as "legit" as a newer language like rust for example?

It's just a weird vibe - it seems like it should be so much more popular than it is.

show 2 replies
fuhsnnlast Saturday at 10:57 PM

The tree-like syntax interested me but unless this new layer enforces it, there's no guaranteed evaluation order among its backends[1], which IMO kind of defeat it's usability as general purpose IR.

[1] https://github.com/nim-lang/nimony/issues/792

ebb_earl_colast Saturday at 8:27 PM

I am really only familiar with Python, in which I’m pretty sure that the .py becomes .pyc and then CPython translates .pyc into machine instructions.

How does this differ? Is an IR the same idea as Python’s .pyc?

show 2 replies