JC-Plus Programming Language
A custom programming language compiler written in Java that adds class-based inheritance, subtyping, and bounds-checked arrays to the C programming language.
App in Action



Project Details
Problem / Approach / Result
C lacks modern safety and object-oriented features
C is a powerful low-level language, but it lacks modern features like object-oriented programming, type-safe inheritance, and automatic bounds checking for arrays -- the latter being a well-known source of security vulnerabilities. Developers need these higher-level constructs without sacrificing C's performance and portability.
- C has no native support for classes, inheritance, or polymorphism
- Unchecked array access is one of C's most dangerous security vulnerabilities
- No subtyping system means no type-safe code reuse across related types
- Bridging high-level OOP concepts with low-level C requires a compilation strategy
Design a new language with a multi-stage compiler targeting C
JC+ was designed to bring higher-level programming constructs to a C-like language while compiling down to standard C. The compiler follows a traditional multi-stage pipeline -- lexer, parser, typechecker, and code generator -- each implemented as a distinct Java module.
- Defined class-based inheritance with instance variables, constructors, and methods
- Implemented a full subtyping system for polymorphic behavior and type-safe reuse
- Added runtime bounds-checked arrays to prevent buffer overflow vulnerabilities
- Built a four-stage compiler pipeline -- Lexer, Parser, Typechecker, Code Generator
- Targeted C as the output language to leverage existing C toolchains and portability
A working compiler that bridges OOP and systems programming
A complete, functional compiler that translates JC+ source code into valid C programs. The language combines the expressiveness of object-oriented languages with C's performance, proving that high-level features can compile down cleanly to procedural constructs.
- Working compiler with 106 commits across the development cycle
- Class-based inheritance with Java-style extends keyword
- Full subtyping allowing subclass instances wherever a superclass is expected
- Runtime bounds checking eliminates C's most common security vulnerability class
- Complete control flow support including if/else, while loops, and break statements
Key Features
Class-Based Inheritance
Define classes with instance variables, constructors, and methods that extend other classes using Java-style inheritance.
Subtyping System
Full subtyping allowing subclass instances wherever a superclass is expected, enabling polymorphic behavior.
Bounds-Checked Arrays
Runtime bounds checking prevents out-of-bounds reads and writes -- addressing C's most dangerous security vulnerability.
Multi-Stage Compiler
Traditional pipeline with lexer, parser, typechecker, and code generator -- each as a distinct module.
Built-In Types & Expressions
Integer types, void, array types, arithmetic and comparison operators, method calls, and object instantiation.
Control Flow
Full support for if/else conditionals, while loops with break statements, return statements, and block-scoped grouping.
Architecture
JC+ source files containing class definitions with inheritance, methods, and bounds-checked arrays.
Custom tokenizer breaks JC+ source into typed tokens including keywords, identifiers, operators, and literals.
Recursive descent parser builds an Abstract Syntax Tree from the token stream, enforcing grammar rules.
Type system validates subtyping relationships, method signatures, and inheritance hierarchies for correctness.
Translates the typed AST into valid C code, injecting runtime bounds checks for array access safety.
Key Metrics
Tech Stack
Compiler implementation language for all pipeline stages
Output language for compiled JC+ programs
Tokenizes JC+ source into typed token streams
AST construction from token streams
Subtyping rules and type inference implementation
| Category | Technology | Purpose |
|---|---|---|
| Implementation | Java | Compiler implementation language for all pipeline stages |
| Target | C | Output language for compiled JC+ programs |
| Lexer | Custom Tokenizer | Tokenizes JC+ source into typed token streams |
| Parser | Recursive Descent | AST construction from token streams |
| Type System | Type Theory | Subtyping rules and type inference implementation |