marad / chi-compiler-kotlin

Experimental language to try some ideas
MIT License
10 stars 0 forks source link
compiler hacktoberfest kotlin programming-language

Build and Test the project

Oh god, another language?!

Yes. How do you like your programming workflow with writing some code, starting tests and... waiting for them to finish just to see that you made a small mistake?

Wouldn't it be nice to have an instant feedback on what you are working on?

As a matter of fact - you can already do this with languages like LISP and Smalltalk. The thing is... their syntax is a bit outdated and this makes people uncomfortable.

Chi language takes the ancient wisdom and simply dress it up in some more modern clothes, so we all can benefit.

The key language feature is that the language is introspective. This means that you can browse and modify defined modules, packages, variables and functions within the running application.

Here's the list that makes it stand out:

You can read more on that features here.

How to get started?

You'd probably need to learn the syntax first. I'm working on this!

Here is a simple naive Fibonacci function:

fn fib(n: int): int {
  if (n == 0) { 0 }
  else if (n == 1) { 1 }
  else { fib(n - 1) + fib(n - 2) }
}

To learn about the language you can read the docs.

You can also explore the examples folder. It contains some Advent Of Code 2015 solutions written in Chi.

How can I use it?

Right now you need to build it yourself but in the future there will be few ways to use it:

Building Chi yourself

One single requirement is to have GraalVM SDK 22 or newer installed. Then just make sure it's in your JAVA_HOME when you invoke:

./gradlew build

This wil generate the chi-launcher/build/libs/chi-launcher-1.0-all.jar after that you should be able to jump into REPL with:

java -jar chi-launcher/build/libs/chi-launcher-1.0-all.jar repl

Building native executable

For this you'll need to have GraalVM's native-image installed (with gu install native-image).

On Ubuntu you'd also need build-essential package to have the tools required for compilation.

For Windows you'll need VS Native Tools and use their command line (it has all the tools set up correcly on the PATH). Here is how to use it.

When you have all the things, what's left to do is to

./build_native.bat

Yeah - it's for Windows now, but it should be easy to convert to .sh script (I'm open to your contributions!)

After that you can simply run some script ./chi.exe somescript.chi or drop straight to the REPL ./chi.exe repl.