- Features
- Example
- Philosophy
- Functions
- Libraries
- minimal size: generated binaries are optimized out of the box
- function driven: c-honky is a functional language, making anything possible
- little boilerplate: barely any boiler plate is required to start having fun with this language
- minimal tooling: both compiler and assembler are bundled as one library
- supports namespaces: namespaces are easy to set up and use
- very cute: Named after Liuk's cat!
Hello world in C-honky:
// test.ck
// Include our standard library
#embed[ck] "std.ck"
std::println("Hello World!");
Want to see more examples? Check out the Handbook.
ChonkPC is a minimal 32bit CPU built from the ground up, therefore there is no compiler or assembler developed directly for it. C-honky provides a simplistic low level language to abstract >30k assembly lines of boilerplate code, it provides enough to be used for calculations, graphics, disk operations and more to come! The language syntax and semantics concept was first based on the toy language Pyetty, that was written entirely in Python. The syntax has been expanded to allow for lower level communication with the CPU and other components provided by the ChonkPC emulator.
The entire language relies on the use of functions to decrease code redundancy and performance. Each functions address is stored in memory to be used later.
Creating a function is as simple as providing the name and it's code block. Currently no return statements are supported
// ...
func HelloWorld(int test1) void {
if (test1 == 1) {
std::println("I'm one!");
}
}
HelloWorld(1);
// Output: I'm one!
Currently C-honky has the following libraries:
- std.ck - Standard library
- gl.ck - Graphics library
- disk.ck - Abstracted Disk library
- dif.ck - Disk Interface
The standard library provides the ability to write to the console, ... and panic. Not much else is implemented there yet. The print
and println
functions have a limit of 100 characters.
// Hello world with a panic!
#embed[ck] "std.ck"
std::print("Hello ");
std::println("world!");
if (1 != 0) {
std::panic("[FATAL] Oh no! Math!");
}
The graphics library works directly with the GPU by writing to different addresses to define properties of the triangles to be drawn, and then calls draw on them. You must clear the command fifo before writing again.
Examples:
// Gradient triangle example
#embed[ck] "gl.ck"
// Clear screen
GL::clear(0, 0, 0);
// Colours
int r = 50;
int g = 150;
int b = 200;
// Triangle
GL::tri( 120, 400,
520, 400,
320, 100,
r, g, b,
b, g, r,
g, r, b
);
GL::draw_double();