Page 1 of 1

nanix and nanc

Posted: Sun Nov 02, 2014 6:31 am
by no92
nanc
After the CompilerDev topic a while ago, I started writing my own compiler. Now, after a few weeks, it's getting ready to being somewhat usable. My compiler compiles my own language, called nanlang. The compiler itself is called nanc.

I wanted my compiler to be modular. The main reason for that is maintainability, as one big block of code would become unmaintainable after some time. First off, I was only writing it for x86. After I tested it and tried some other stuff out, I decided to start over, hoping not to do the same mistakes again that I did with the first version. It has grown and become nanc by now. Currently, it is only compiling code for amd64, but ARMv6 is planned.

The reason I'm doing this is simple: I want to write my OS with this language. I want to use the same language for both OSdev and CompilerDev. I didn't choose C, as I think it's not suited for compiler development (my own opinion, haters gonna hate). C++ seems too unintuitive to me. Other ones are just crap when using them for OSdev. (Please don't start a flamewar, it's my opinion. It will not change.)

nanix
This will be the OS written using nanlang. I want it to run on x86-64 UEFI PCs and Raspberry Pis.

It isn't started yet, not even planning is completed, so I don't know about how I'll implement things, at least right now.

nanas
nanas is a assembler, featuring a new clean and human-readable syntax. It has no fixed instruction order, but instead it follows the way humans thing (e.g. "mov(e) 0 (to) eax", "cmp 4 (to) eax", leaving out everything in the braces). It does not use any commas. Intel syntax is scary, AT&T even more. Currently, it is capable of producing (horrible, but working) ELF64 binaries. Only few instructions are supported yet.

Download
Releases will be available through GitHub.

Re: nanix and nanc

Posted: Sun Nov 02, 2014 8:59 am
by martinFTW
It seems your compiler is written in PHP.
Perhaps you could implement a web interface for nanc, which prints out the asm code for a given code.

Re: nanix and nanc

Posted: Sun Nov 02, 2014 11:40 am
by no92
I already took that in consideration, but I won't do it. It would be no problem to implement it, but I plan rewriting it in my own language soon, which isn't a web development language at all.

I don't think somebody would use such an interface, as it's not a problem to run such the compiler on most architectures. You also have to take in account that you don't get an assembled object file or an executable, but only assembly.

You may suggest having the compiler in both languages; but maintaining it would be a nightmare then.

Re: nanix and nanc

Posted: Sun Nov 02, 2014 12:08 pm
by max
Nice work! will have a look at the code once i'm at home.
no92 wrote:You may suggest having the compiler in both languages; but maintaining it would be a nightmare then.
How will you bootstrap your compiler then? Distribute binaries?

Re: nanix and nanc

Posted: Sun Nov 02, 2014 12:28 pm
by no92
My plan for the next few months is to get the current compiler (written in PHP) to an acceptable state; after that, I'll begin writing it in nanlang, but compiling it with the old compiler. After both have the same set of features, every new compiler release will be compiled with the previous release.

With the first release of the nanlang-based rewrite, the old PHP-based compiler will get deprecated.

Both source and binary packages will be released by me, but probably only for Linux and nanix (maybe OS X, not quite sure yet). This will not happen in the next few weeks, as the current compiler and the rewrite will take a lot of time.

Re: nanix and nanc

Posted: Fri Nov 21, 2014 2:13 pm
by max
I'm moving this from my Ghost article to yours so we can discuss. :)
no92 wrote:That one may take a while - and I do plan to add some runtime routines for reflection, which may make things more complicated.
You'll need that anyway if you want proper inheritance and something like Java's instanceof.
no92 wrote:My plan for the next few months is to get the current compiler (written in PHP) to an acceptable state; after that, I'll begin writing it in nanlang, but compiling it with the old compiler. After both have the same set of features, every new compiler release will be compiled with the previous release.

With the first release of the nanlang-based rewrite, the old PHP-based compiler will get deprecated.
If you no longer provide a source release in PHP for newer versions, users are forced to use the binaries of your compiler. How could they then for example get it running on a new system where this binary does not work, and where only existing packages (preferably PHP then) work?

Re: nanix and nanc

Posted: Sun Nov 30, 2014 10:49 am
by no92
@max: They will download the binary and the source and compile the new (source) compiler with the old (binary) one. The binary will only work on nanix though (I may port it to Ghost later on, but that would require deep hacks in execve/fork).

Re: nanix and nanc

Posted: Thu Dec 04, 2014 12:31 pm
by no92
nanas, an assembler, has been added to the project. Therefore I updated the first post.