3 ms·
ZL: A C/C++ Compatible Language with Hygienic Macros
- EgoIncarnate 11y ago"C++ like" is not the same as C++ compatible.
- AndyKelley 11y agohttp://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.
- AndyKelley 11y agoWhat 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/aaf09e30a3a7b9ed8f344a136a094ce5ffb7e306/src/main.zig#L5 https://github.com/andrewrk/tetris/blob/aaf09e30a3a7b9ed8f34... 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 11y agoI'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 11y agoIsn't that exactly how C++ started?
- dasannikov 11y agoMaybe, but nowadays we know that C++ have problems with simplicity.
- vmorgulis 11y agoYou can take a look at Cello but it's more script-like. http://libcello.org/ http://libcello.org/ As dragonwriter said, C++ begun as a preprocessor. The cfront sources are available here: http://www.softwarepreservation.org/projects/c_plus_plus/index.html#cfront http://www.softwarepreservation.org/projects/c_plus_plus/ind... About your language, it's possible to do your own by parsing the AST output of GCC with "-fdump-translation-unit". I think Uniform Call Syntax is planned for C++17 or maybe 20 (f(a,b)=a.f(b)).