Lately a lot of new programming languages have been popping up. Some of them are really cool and offer qualities that others do not provide. My goal is absolutely not to create a new programming language that will be used by millions of people, but rather to learn how to create a programming language by implementing the features that I like from other languages.
For an in-depth look at my progress, you can find the πΊοΈ roadmap here. Additionally, you can explore practical examples of what you can achieve using the language here.
eheh-lang represents my educational endeavor into the realm of programming languages. This dynamically-typed, interpreted, general-purpose programming language serves as a platform for learning and exploration.
I have stumbled upon this book thanks to ThePrimeagen, it is an amazing book that I would recommend to anyone who wants to learn how to create a programming language: Writing An Interpreter In Go, it truly is worth buying !!!
I am a big fan of the Rust programming language, so I decided to implement the language in Rust.
There are a lot of features that I would like to implement in the language that comes from others such has:
-
Elixir (I really like the pattern matching and the pipe operator)
-
Zig (I also recommend following Andrew Kelley's work, he is an amazing developer and he is doing some really cool stuff with Zig and has some really nice Talks)
-
Swift (I like the way you can call methods on objects with the dot syntax)
-
Rust and C++ (Interesting way to manage memory, pointers, namespace with
::
, etc...) -
Python (No limit in terms of integer size)
To install and run your programming language, follow these steps:
-
Make sure you have Rust installed. If not, you can install it from https://www.rust-lang.org/. The project has been created and maintained with
rustc
andcargo
1.69.0 It should work with newer versions, but if you encounter any problems, please open an issue. -
Clone this repository to your local machine:
git clone https://github.com/adia-dev/eheh-lang.git
- Navigate to the project directory:
cd eheh-lang
- Run the REPL (Read-Eval-Print Loop):
cargo run
- Enjoy! π Here are some examples of what you can do with the language:
eheh(1)> let add = fn(x, y) { x + y; };
eheh(2)> add(2, 3)
5
eheh(3)> let factorial = fn(n) { if (n == 0) { 1 } else { n * factorial(n - 1); } };
eheh(4)> factorial(5)
120
eheh(5)> let name: string = "eheh-lang";
"eheh-lang"
------------------------------------- WORK IN PROGRESS -------------------------------------
eheh(6)> name |> String::to_uppercase |> String::chars |> Vec::len |> print
9
eheh(7)> name ** 2
"eheh-langeheh-lang"
eheh(8)> let hash_map = { language: "eheh-lang", version: { major: 0, minor: 1, patch: 0 }, year: 2023 };
{language: "eheh-lang", version: {major: 0, minor: 1, patch: 0}, year: 2023}
eheh(9)> hash_map |> Map::each(|key, value| print("{} => {}\n", key, value))
language => eheh-lang
version => {major: 0, minor: 1, patch: 0}
year => 2023
eheh(10)> help
[...]
eheh(11)> exit
~ Prend moi un Yop ~
eheh(1)> let add = fn(x, y { x + y; };
error[E01000]: expected `)`, found `{`
--> src/main.rs:1:17
|
1 | let add = fn(x, y { x + y };
| ^ : expected `)`
eheh(2)> if (true) { 1 } else { 2 }
warning[E01000]: Unnecessary parentheses around true
|
1 | if (true) { 1 } else { 2 }
| ^^^^
eheh(3)> let add = fn(x, y) { x + y; }; // <- define a function, functions are top-level citizens in eheh-lang
eheh(4)> if true {} else { add(1, 2) }
warning[E01002]: The consequence of the if expression is empty. Consider swapping the alternative and consequence branches of the if expression.
|
1 | if true {} else { add(1,2) }
| ^ ^^^^^^^^^^^^
- Initial project setup
- Implemented AST (Abstract Syntax Tree) structure
- Expression nodes
- Boolean expression
- Call expression
- Function literal
- Identifier
- If expression
- Infix expression
- Integer literal
- Prefix expression
- Typed identifier
- String literal
- Array literal
- Hash literal
- Index expression
- For expression
- While expression
- Match expression
- Range expression
- Pipe expression (|> Elixir
β₯οΈ ) - Defer expression
- Await expression ??????????? (let's ignore this for now)
- Asy--------------------------^^^^^^^^^^^^^^^^^^^
- Cool little dot to call local Enums just like in
Zig
orSwift
- Statement nodes
- Block statement
- Declare statements
- Let statements
- Const statements
- Var statements
- Mutability
- Functionning type system
- Expression statements
- Return statements
- Expression nodes
- Lexer implementation
- Parser implementation
- REPL (Read-Eval-Print Loop) implementation
- Evaluation system
- Boolean object
- Integer object
- Null object
- Prefix expressions
- Infix expressions
- If expressions
- Return statements
- Let statements
- Function objects
- Function application
- Closures
- Built-in functions
- First-class functions
- Higher-order functions
- String object
- Array object
- Hash object
- Index expressions
- Type system implementation
- Type checking
- Compile time type checking ???? (Does this language even compile?)
- Error handling
- Error logging
- Warning logging
- Error handling
- Warning handling
- Help logging
- REPL (Read-Eval-Print Loop) implementation
- Garbage collector
- Memory Allocators
- Stack allocator
- Page allocator
- Bump allocator
- Slab allocator
- Object pool allocator
- LSP (Language Server Protocol)
- Standard Library
- Dynamic Dispatch (Generics ???????)
- Powerful Pattern Matching (Elixir Like)
- Module or Namespace system
- Macros
- Documentation
- Code formatting
- Structs, Enums and Custom Types
- Package Manager (AHAHAHHAHAHAHAHAHDAZUIHUDIAHUIDHZAUIHDA, maybe something like zig's package manager, e.g:
build.zig.zon
) - Complete the main program
- Comprehensive testing
- Documentation
- Additional features (Add more items as you progress!)
- Contributions Welcome: I don't mind a little pull request that implements async/await as well as wasm portability. I'm sure it's not that hard to implement, right? π
- Feedback Welcome: I'm sure you have some great ideas for this project. Let me know what you think!
- Issues Welcome: If you find a bug, let me know! I'll try to fix it as soon as possible.
- Questions Welcome: If you have any questions, feel free to open an issue or contact me on Discord:
adia31
This project is licensed under the MIT see the LICENSE file for details
Discord: adia31
(preferred)
Linkedin: Abdoulaye DIA