
Show HN: Neeilang: Minimalist OOP Language That Compiles to LLVM IR - neeeeees
https://github.com/neeilan/neeilang
======
neeeeees
Hi HN!

I’ve been working on this language for about 4 months now. While not
“complete”, it does have a number of nice features like virtual functions,
type inference, etc.

I reckon it will not be truly useful until GC is added, and that’s what I’m
currently working on.

Any feedback is welcome and appreciated!

~~~
jdmoreira
I think it’s great that more and more people are spending time working on
programming languages. I have a few questions for you about the type system /
type checking. Does llvm make it easier to implement a statically type
language than other backends? For example luajit? And how did you learn to
implement the typechecker? Is it algorithm W?

~~~
neeeeees
1) LLVM IR is strongly typed, which makes it very challenging to implement a
dynamically-typed language on top of it. AFAIK, there aren't many (any?)
successful such implementations of dynamically-typed languages. I haven't used
other backend libraries, but I do think that looser typing at the IR level
would make it a lot harder to catch implementation bugs; at least with LLVM,
you are likely to hit an assertion if you break typing rules in the IR.

2) The type-checker is fairly ad-hoc, and I admittedly didn't look much into
the literature here. The general idea is that since variable/function/class
field types are explicitly typed, every expression can be checked for
violating it's expected type. Implementation-wise, this is facilitated using
the visitor pattern [1]. For certain expressions, some extra flexibility is
allowed - for example, assigning an object of a child class to a variable of
the parent class is not a type error.

[1] [https://github.com/neeilan/neeilang/blob/master/src/type-
che...](https://github.com/neeilan/neeilang/blob/master/src/type-checker.cc)

------
c-smile
What is the main goal of it?

By feature set it looks close to D lang so asking.

Yet, have you considered to implement TypeScript instead?

Having native compiler of TS (or at least subset of it) would be beneficial.

~~~
neeeeees
This main goal for me is learning and not developing a production-ready
language. When picking the feature set, I wanted something like Java (OOP, GC,
no arbitrary pointers) but without a VM.

I think implementing TypeScript natively would be a very interesting project,
but the 'all valid JavaScript is valid TypeScript' part of the spec means
you're also implementing an AOT JS compiler, which is much more challenging.

------
Mathnerd314
also discussed here:
[https://www.reddit.com/r/ProgrammingLanguages/comments/erqm6...](https://www.reddit.com/r/ProgrammingLanguages/comments/erqm6s/neeilang_a_small_stronglytyped_language_oop/)

------
unlinked_dll
If you add `.md` suffix to your doc files, github will render them for you.

~~~
mjaniczek
I noticed the README had a nice ASCII-ART touch, and briefly thought about
converting my .md READMEs back to extensionless plaintext files :)

------
Hayvok
Is there sample code outside of /test?

~~~
protomyth
The page
[http://www.github.com/neeilan/neeilang/tree/master/doc/Lang](http://www.github.com/neeilan/neeilang/tree/master/doc/Lang)
is linked from the read me.

~~~
neeeeees
Thanks! I've updated the doc to Markdown as suggested by other commenters, so
it is now available at
[https://github.com/neeilan/neeilang/tree/master/doc/Lang.md](https://github.com/neeilan/neeilang/tree/master/doc/Lang.md)

------
Iwan-Zotow
Isn't it a bit too late (maybe 20 years too late) to work on new OO language?
Not that I discourage you, but what areas of OO in languages not
explored/expressed by now (say, by C#, Java, C++, younameit) ?

~~~
neeeeees
Not discouraging at all - that's a very valid point! Funnily enough, I wanted
to try implementing an OO language because they are popular... I use them a
lot, which makes it important for me to understand how they work.

~~~
nickik
To get an interesting unique feature I recommend implementing generic dispatch
a la CLOS or Dylan. That also makes your library writing a real joy, for
example you can just write a plus function for each combo of types.

Check out Dylan, a high performance dynamic language that compiles to LLVM.
Check out this example:

[https://opendylan.org/documentation/intro-dylan/multiple-
dis...](https://opendylan.org/documentation/intro-dylan/multiple-
dispatch.html)

This is how to do it:
[https://en.wikipedia.org/wiki/C3_linearization](https://en.wikipedia.org/wiki/C3_linearization)

Gives the language powerful uniqueness feature that the 'mainstream' languages
don't have.

~~~
neeeeees
Interesting suggestion! I'll definitely check it out. Looks like this, along
with generics, will make the library a lot easier to write. Thanks!

