A statically typed language project created for Hack FSU 5.


SlightC is a C-like language with some conveniences and conventions borrowed from Python, Ruby and other interpreted languages. While syntacially similar to C, SlightC does deviate in certain areas, we go into further detail about those differences below. SlightC is a superset of C as it transpiles directly into C code during compilation.

Table Of Contents

Quick Start
Conditionals and Control Flow
Input and Output

Quick Start

Download or clone the repository to an empty folder.

To run the main program, the Visual Studio 2017 C compiler is required to be installed.

Or if you don't want to use the Visual Studio compiler and want to use a custom C complier, then you have to manually edit the batch script to run the command of the c compiler of your choice where the VS compiler is run.

Once installed, its time to make your first SlightC program.

Here is a one line program for Hello World:
output("Hello World!")

To run your program, type javac If it runs correctly then run compileScripts.bat YourProgramName.slc into the command line of eith CMD or Powershell. Note: your program will automatically run after being compiled.

If done correctly your program should output:
"Hello World!"


Variables in C require explicit data type declaration when declaring a variable. SlightC uses type interfacing to determine the data type of a variable. Under the hood, variables are stored as primitive c data types.

a C variable declaration:
int x = 5;

the equivalent declaration in SlightC:
x is 5;

Notice that SlightC uses the keyword is for assignment instead of the typical = operator

Conditionals and Control Flow

Most control flow loops and conditional statements share the identical syntax to C, with the exception of for loops

In C, a typical for loop may look something like below:

for(int i = 0; i < 10; i++) {
    // statements

In SlightC, for loops take on a syntax more similar to Python than C, although there are still some key differences:

from 0 to 10 {
    // statements

Input and Output

Input and output work similar to how Python handles IO.

For output the syntax in SlightC is:

The equivalent in Python would be:
printf(x) if x is a string and printf("%d", x) if x is an int.

For input syntax is identical to the C equivalent. This includes cross compatibilty with C libraries such as stdio.h


In SlightC, functions are syntactically similar to to function definitions in Javascript. Compared to C the only difference is that instead of specifying the return type the keyword function is used when defining a function.

function myFunction(x, y, z) {
    // statements

To return a value from the function use the keyword return just like in C


A Hello World example:

output("Hello World!");

Use of nested For loops:

x is 3
y is 4

from 0 to x {
    from 0 to y {

Euclids Greatest Common Devisor (GCD) algorithm:

function gcd(m, n) {
    if (m == 0 && n == 0)
        return -1;

    if (m < 0) m is -m;
    if (n < 0) n is -n;

    while (n) {
        r is m % n;
        m is n;
        n is r;
    return m;

output(gcd(25, 10));


SlightC is a language that combines the ease of Python with the speed C. It represents the best of both worlds, allowing users to develop programs with a simplified syntax reminiscent of interpreted languages, yet that runs with the speed of a compiled program.

Built With

Share this project: