Skip to content
The Braceless v0.x bootstrap compiler.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Samples
.gitignore
LICENSE
README.md
TODO.md
b0c.py
build.bat
compile.bat
unittest.bat

README.md

The Braceless v0.x Compiler

The Braceless language is a new static typed programming language which aims to offer Python v3's convenience at near native speeds (I aim to be able to compete head-on with C and C++) .

The language borrows heavily from these languages:

  • Occam and Python (the basic syntax and especially the "indentation matters" principle).
  • Python (the semantics, albeit I intend to clean these up considerably).
  • C# (the strict semantic models and the static typing).

The languages' name, Braceless, is a pun on the horde of braces that attack you from all sides when you want to program today. Is it really the case, that Mankind can do no better than derive from the hack C?

The language primarily focuses on adding these "new" features:

  • Built-in coding standard: I simply loathe that everybody must produce their own books on how they write their code. In other words: Spaces matter, just like the indentation matters. It makes a lot of sense once you get accustomed to the idea! Half the work of a code review group erased in an instant!
  • Ultra-Fast Exception Handling (I simply loathe "Zero Cost Exception Handling" because it is so extremely expensive when an exception occurs; I want my exceptions to be handled at C-like speeds).
  • No global variables ever! Nothing ruins the readability of code so much as global variables. Also, they tend to be all but thread-safe and intense multi-threading is and will be the future of software.
  • Complete Unicode UTF-8 and UTF-32 support from the start.
  • Completely exception aware low-level run-time library from the start.
  • Completely object-oriented low-level run-time library from the start.
  • A beautiful systems programming language that will eventually interface seemlessly with existing C libraries (never C++).

Credits

First and foremost, I need to thank my good friend Alexandre Bencz for having pushed me forward and for having told me when I was doing things upside-down. Good friends tell you when you are wrong and Alexandre does exactly this! Thank you, Alexandre!

Second, I need to thank the author of the Cobra language, Charles G., for implicitly suggesting (by doing it himself) to use Python to write the bootstrap compiler. I have fought numerous battles with C, C++, C#, D, and Go in various attempts of writing a simple bootstrap compiler for Braceless but over the past week I've accomplished more than I ever did in those languages. Why? Because Python has all the features I need (its two drawback are that it is very slow and that it performs no static checks)!

Third, I need to thank Niklaus Wirth, then inventor of Pascal, for unintentionally having stimulated me to become interested in programming language design at the tender age of 11 years. Wirth was my childhood hero and I still think that he has contributed much more to proper software development languages than the plethora of brace-loving people out there. The biggest problem about Pascal was that it used those tedious begin/end pairs all over the place (and the pointer notation was pretty awkvard too). I can't but help wonder what Wirths track record had been, if Wirth had a chance to study Occam while developing his multitude of programming languages (Pascal predates Occam by 13 years).

This reminds me why I want to do Braceless at all:

  • To create a beautiful, efficient, portable, and sensible programming language that makes you as productive as Python v3.x!

Objectives

The purpose of this project is to write a complete bootstrap compiler for Braceless v0.x in Python v3.x.

The purpose is neither of these:

  1. To create the fastest, most advanced compiler ever envisioned.
  2. To create an advanced monster that nobody can understand or maintain.

The purposes are as follows:

  1. To create a working bootstrap compiler that implements Braceless v0.x and nothing more.
  2. To generate working executable code using the LLVM v7+ tool chain.
  3. To prepare for writing the actual production compiler using this bootstrap compiler.

Requirements

  1. The compiler must be implemented in portable Python v3.x.
  2. The compiler must support all of Braceless v0.x.
  3. The compiler must generate working, usable executables from Braceless v0.x source code.
  4. The compiler must enforce all Braceless v0.x requirements and static checks.
  5. The compiler may take two days to compile a simple project, it does not matter!
  6. The compiler may not use overly advanced concepts or code structures: KISS!
  7. The compiler must implement some sort of embedded test suite for all components.

"Hello World" Sample

Just a tiny taster for how I envision the classical Hello World sample program to look in Braceless v0.x:

# The mandatory scope (namespace) of the program.
scope Samples.Hello_World:

    # The program's entry point, which returns a value to the host environment.
    entry Start(system is !Braceless0.System) is cardinal:
        # Call the provided standard console output routine.
        call system.Console.Print("Hello World!")
        return 0

As you can see, Braceless0 is very inspired by both Python and C#, but aims to eradicate the Visual Basic thinking of the latter.

Things worth noting about the sample:

  1. Braceless is a purely line-oriented language. There is no backslash-at-the-end-of-the-line trick.
  2. Empty lines are ignored.
  3. Comments are statements and thus must appear on their own line (and properly indented too).
  4. All other statements begin with a keyword such as scope, entry, or call.
  5. Namespaces are called "scopes" in Braceless, at least for the time being.
  6. Indentation is always done using tabulators, which always count for four spaces.
  7. The program's entry point is marked using a so-called "entry".
  8. The entry point must use the profile given above, no other variants will be supported.
  9. The entry point take a mandatory parameter, system, that gives access to the environment.
  10. The system argument gives access to all external features, such as disk files and terminals.
  11. The entry point must return an unsigned integer value, which is returned to the environment.

Hence the standard Hello World program is a bit bulky, but Braceless is not made for sample programs, but rather for efficient, large, portable, reliable, and sound software systems. Why spend time optimizing your Hello World sample program, when it is only going to be read and then discarded?

Status

I'll probably forget to keep this list up-to-date, but as of 2019.03.16, these things are working mostly:

  1. Modules (I've only tried compiling one module at a time).
  2. Entries and functions.
  3. Return statements, whether with or without a returned expression.
  4. Create statements (creates a local variable), the type is not inferred at this point in time.

Things that are missing:

  1. Virtually everything.
  2. The ability to build and link an executable.
  3. The static type checker is very crappy right now, until I get some things fixed.

Exploring on 64-bit Windows

If you want a quick look at the current state of the compiler, take a look at Samples/Evergrowing.b0.

If you want to try out the compiler yourself, you need three things up front:

  1. A Windows 64-bit installation, whether as a physical box or a virtual machine.

  2. Git for Windows; remember to add it to your PATH somehow before you continue.

  3. Python for Windows; remember to add it to your PATH somehow before you continue.

Braceless intentionally generates LLVM v7.x IR, not object files or executables. This is because I don't want to update binaries for a mere bootstrap compiler all the time. Also, generating LLVM IR makes many things possible in the long run, without me having to spend tons of time studying C++ interfaces and class hierarchies just to get something done.

If you want to compile the generated LLVM IR (.ll) file into either an assembly or object file, you need to install LLVM v7.x too - and remember to add it to your path.

The compiler does not yet invoke Clang automatically, but this feature is planned in the near future.

If you want quick results, do this after following the steps above:

cd /d %TEMP%
git clone https://github.com/archfrog/Braceless0.git
cd Braceless0
build
compile Evergrowing.ll
nano Evergrowing.s
rem Hit Ctrl-X to exit nano.

Exploring on 64-bit Linux

Most Linux distros that I know of come with Git and Python v3.x preinstalled, so all you need to do is this:

# Remember to install LLVM (Clang), if not already installed.
cd ~
git clone https://github.com/archfrog/Braceless0.git
cd Braceless0
./b0c.py Samples/Evergrowing.b0
clang -masm=intel -S Evergrowing.ll
less Evergrowing.s
# Press 'q' to quit less.

Please notice that I have not yet tested the compiler on Linux; but I have tried to prepare for that scenario.

Contact

My name is Mikael Egevig, I'm living in Herning, Denmark, and I can be contacted by email on mikael@egevig.org.

I know the documentation is sorely lacking, but the compiler is hardly able to do anything sensible just yet, so there's not much to document. As soon as I can begin to write tiny programs in Braceless0, I'll begin documenting my progress a bit more.

Feel free to open an issue on GitHub or mail me if you need help with anything related to Braceless.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.