💻

Exploring the C3 Programming Language

Aug 8, 2024

Recreation Programming Session - Lecture Notes

Introduction

  • Host: Mr. Aan
  • Focus: Low-effort language review
  • Target Language: C3 Programming Language

Overview of C3 Programming Language

  • Description: Simple, fast, safe, compiled.
  • Goal: For developing maintainable software, not necessarily readable.
  • Notable Features:
    • Module system (better than C)
    • Namespace support to avoid collisions (e.g., with Windows API)

Installation Guide

  • Focused on Debian Linux for installation.
  • Downloaded a tar file of C3.
  • Noted a lack of dark mode on the website.

Initial Exploration of C3

  • Executable identified as ELF (Executable and Linkable Format).
  • Dependencies include libxml2 for XML parsing, possibly for MSVC integration.
  • Initial tests included compiling an empty file and generating object files.

First Impressions

  • C3 requires a main function and provides error messages for missing components.
  • Compiling a simple "Hello, World!" program works but lacks syntax highlighting.

Language Features

  • Function Definitions

    • Uses FN keyword, similar to C but adds a new keyword for functions.
  • Control Structures

    • Supports if conditions and classical for loops.
    • Enumerations and switch cases are present.
  • Error Handling

    • Errors handled using optionals, similar to a functional approach.
  • Macros & Compile-Time Execution

    • Macros can be evaluated at compile time.
    • Allows for compile-time reflection and execution.
  • Built-in Types

    • Built-in vector types with associated mathematical operations (e.g., swizzling).

Linking with External Libraries

  • Successfully linked with C libraries, demonstrating ease of interoperability with C.
  • Example with Raylib showed ability to create and manage windows and rendering.
    • Events must be handled properly in an event loop.

Game Development Example

  • Attempted to implement a simple physics simulation.
  • Implemented a bouncing object using vectors for position and velocity.
  • Discussed generating random colors upon collision using HSV.
  • Introduced methods for object randomization and scalability.

WebAssembly (WASM) Compatibility

  • Explored potential for compiling to WASM but noted incomplete support.
  • Attempted various commands but faced challenges in achieving a working module.

Conclusion

  • C3 programming language shows promise with its features and ease of use, particularly for game development.
  • Lacked some aspects like robust WASM support, which may improve with future updates.
  • Overall rating: 8/10 - good language for practical programming.