Sea (a compiled language)
fuzzyastrocat (671)

Hello everyone! This is my first post, so if it's boring I apologize :D

Just wanted to share a little compiled language I made called Sea. It's called Sea because, well, Sea shares many things in common with C. I chose C to mimic because this was my first compiled language — given that C is so low-level, I figured I wouldn't have to do too much work translating to x86.

A quick overview of the language

In case any of you want to try it out, here's a quick overview of the syntax/semantics.

To start, we'll take the simple "hello, world" program:

    import "stdlib.sea";
    int function main {
            println("Hello, world!");

Here we immediately see a few differences between C and Sea:

  • Import is not a preprocessor routine, it's a keyword
  • Functions are defined as <type> function <name>
  • Functions automatically return their last expression — to suppress this, the last expression can be void;
  • Arguments in functions are declared differently — instead of putting arguments between parentheses, they are written as null declarations on the following line:
    int function my_function
            int my_arg_1;
            int my_arg_2;
            // some code

Control flow (if, else, while) is implemented as a "postfix operator":

    1 == 2
            :then {
                    println("Whoa, math broke"); // And no, this won't get printed :D

A for-loop can be emulated with a block scope and a while:

    {int i = 0; i < 5
            :while {
                    printf("%d", i);

These control flow constructs can be extended — an excerpt taken from the stdlib:

    int::isZero {
            :else {

$int represents the int in question, and $() represents execution of the block given to the control statement. We could "call" this like so:

         :isZero {
                 println("Hey math works again!");

Sea has support for ints, chars, pointers, strings (char*), and moderate support for floats. If you want to see more about the language, peruse stdlib.sea and the tests (and oldtests, though some of those are outdated) folders in the repl.

EDIT: stdlib.sea uses what might be a confusing doc notation, so let me explain that here.


Sea comments behave just like C comments:

    // This
    /* will
    */ // Evaluated

However, there is a doc notation (used by SeaLib to generate simple HTML docs for a file). It is the following:

    The header must be the first line of the file (outside of line or block comments).  It gives  a description of the file to follow. // This line is the file info

    [[your_function]] // Descriptor doc — gives info about a function
    A cool function I just wrote for demo purposes

    void function your_function {
            println("Hello, world!");

    // Add more functions with their descriptor docs

SeaLib translates that to the following:

And yes, that file would actually run (aside from saying "entry point main is not defined"). Doc headers are ignored (along with the line after) just like normal comments.


"That's neat — but why are you posting it here right now?"

Unfortunately, I'm going to abandon Sea (in favor of a newer language, Curta). Why? Two things:

  • As the language became more complex, I noticed a few things I had done not-quite-nicely in the compiler were becoming difficult to manage. I was faced with either using bad tools or buying (re-coding) new tools.
  • I was actually wrong about translating from a C-like language to x86 being easy. While the actual conversions themselves are not difficult, finding the proper x86 commands can be very difficult! For instance, there is no power function for the SSE floating point system — and all the tools I needed to make a power function were either nonexistent or difficult to implement.

So Sea will probably remain in its current state [for the rest of time].

In the aforementioned newer language (Curta), I am learning from my mistakes — it will compile to C++, with the added benefit that it will work on some embedded systems (most notably the Arduino). Stay tuned!

EDIT: Curta is now here:

You are viewing a single comment. View All
yekyam (0)

What are some of the internal differences between Sea and C? Like when you think of cpp, it adds templates, references, etc so what does Sea add?
Regardless of features, cool language man!

fuzzyastrocat (671)

@yekyam Answer: basically nothing.

"Wait, what?" Yes, in its current state, Sea doesn't add hardly anything internally to C (The control flow extension system is new, though you could represent that in C code). Then why did I make it? Well, the key phrase is "current state": all the cool internal additions to C I had planned became too cumbersome to implement (due to problem 2 listed above).

However, you can expect some really cool (internal) features with my next language, Curta. So... stay tuned! :D
(and thanks for "cool language"!)

yekyam (0)

@fuzzyastrocat Absolutely no problem with cutting your losses, always better to start with a clean slate! I can't wait to see what's coming next!

fuzzyastrocat (671)

@yekyam Definitely! And I can't wait either! :D

yekyam (0)

@fuzzyastrocat Last question: is your new language going to have memory management, or is it going to be garbage collected?

fuzzyastrocat (671)

@yekyam That's rather difficult to determine. As Curta is an embedded systems language, its memory footprint is very, very low. However, I believe the answer would probably be garbage collection (though much less overhead than other garbage-collected languages).

Why am I using all this shifty wording? Because to properly explain it, I'd have to give away a good deal about the language, and that would ruin all the surprise :D

yekyam (0)

@fuzzyastrocat Sounds interesting, I can't wait to see it!

fuzzyastrocat (671)

@yekyam If you're interested, curta is now here:
It's changed since my last post here but it still retains its purpose!

yekyam (0)

@fuzzyastrocat Cool, I'll check it out!