Giter Site home page Giter Site logo

eheh-lang's Introduction

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.

πŸ“š Table of Contents

πŸ“– About

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:

  1. 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 and cargo 1.69.0 It should work with newer versions, but if you encounter any problems, please open an issue.

  2. Clone this repository to your local machine:

git clone https://github.com/adia-dev/eheh-lang.git
  1. Navigate to the project directory:
cd eheh-lang
  1. Run the REPL (Read-Eval-Print Loop):
cargo run
  1. 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 ~

πŸ§™β€β™‚οΈ There are some pretty amazing warnings and errors too!

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) }
    |           ^       ^^^^^^^^^^^^

πŸ—ΊοΈ Roadmap

  • 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 or Swift
    • Statement nodes
      • Block statement
      • Declare statements
        • Let statements
        • Const statements
        • Var statements
        • Mutability
        • Functionning type system
      • Expression statements
      • Return statements
  • 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!)

🀝 Contributing

  • 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

πŸ“œ License

This project is licensed under the MIT see the LICENSE file for details

πŸ“ž Contact

Discord: adia31 (preferred)

Linkedin: Abdoulaye DIA

eheh-lang's People

Contributors

adia-dev avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.