C3 is a system programming language based on C. It attempts to improve on C whilst retaining most of its syntax and semantics.
To get started, head over to c3-lang.org/getting-started.
Once you have the compiler on your system, go ahead and create a file hello.c3
with the following snippet and compile it using c3c compile hello.c3
import std::io;
fn void main()
{
io::printfn("Hello World");
}
You can also create project by running c3c init project-name
.
To build it, first cd
into the newly created directory then run c3c build
.
If you are familiar with C you’ll notice a few differences.
C3 uses the fn
keyword to declare functions. It also introduces modules,
in the example above we import std::io
in order to use io::printfn
.
Note: all my upcoming posts on C3 will assume the latest version of the compiler so if the examples don’t compile then please refer to c3-lang.org/getting-started/compile on how to build the compiler from source.