
ZL: A C/C++ Compatible Language with Hygienic Macros - vmorgulis
http://zl-lang.org/
======
AndyKelley
What exactly does the author mean by "C/C++ compatible"?

Because my language[1] just got the ability to directly include .h files and
access to the functions and symbols therein. Small snippet[2]:

    
    
        c_import {
            @c_include("GLFW/glfw3.h");
            @c_include("stdlib.h");
            @c_include("stdio.h");
        }
    

I realize this probably comes across as trying to one-up another person's work
but I _just_ got this working a few minutes ago and I'm really excited to demo
it!

[1]: [https://github.com/andrewrk/zig](https://github.com/andrewrk/zig)

[2]:
[https://github.com/andrewrk/tetris/blob/aaf09e30a3a7b9ed8f34...](https://github.com/andrewrk/tetris/blob/aaf09e30a3a7b9ed8f344a136a094ce5ffb7e306/src/main.zig#L5)

OK I think I understand what the author means by "C/C++ compatible". Check out
this snippet[3]

> Note that there is no #include line in the source file. The ZL prelude
> includes some of the more common functions from the C standard library and
> ZL source files are not run through the C preprocessor by default. The
> driver script zlc is meant to act as a drop drop in replacement for GCC. For
> example,

> zlc main.zl file1.cpp file2.zlp -o main

I think that zl compiles to C and also acts as a compiler driver.

[3]: [http://zl-lang.org/doc/zlch2.html](http://zl-lang.org/doc/zlch2.html)

------
dasannikov
I'm looking for language that can be described like "C with classes".
Simplicity of C and some basic OOP features in one. Not Go and not C++. Simple
low-level language without garbage collector and with C libs support.

I've tried to imagine it as some kind of preprocessor with C files as output.

Fow example this:

    
    
        struct Test {
            int testFunc(int a) { return a * a; }
           ...
        };
    
        int main() {
            Test t;
            return t.testFunc(2);
        }
    

Can be transformed to C code:

    
    
        struct Test {
            ...
        };
    
        int Test_testFunc_int_int(Test * this, int a) {
            return a * a;
        }
    
        int main() {
            Test t;
            return Test_testFunc_int_int(&t, 2);
        }
    

Does anyone know language or meta-language (with output as C files) or some
libs maybe similar to this?

~~~
dragonwriter
Isn't that exactly how C++ started?

~~~
dasannikov
Maybe, but nowadays we know that C++ have problems with simplicity.

------
EgoIncarnate
"C++ like" is not the same as C++ compatible.

~~~
AndyKelley
[http://zl-lang.org/doc/zlap1.html#x19-66000A.1](http://zl-
lang.org/doc/zlap1.html#x19-66000A.1)

"The current ZL prototype supports most of C and an important subset of C++"

Looks like they have complete C compatibility and proof-of-concept C++
compatibility but not complete.

