Skip to content

Genesis is a general-purpose programming language designed with a focus on web development. Similar to JavaScript, Genesis is flexible enough to handle a wide range of tasks but is optimized for use within web applications

Notifications You must be signed in to change notification settings

Simpleboi/Genesis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

56 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Genesis Programming Language

Version License Node


⚠️ Pre-Release Notice

Genesis is currently in pre-1.0 development and is NOT production-ready. Many features are still being implemented and the language specification is subject to change. Use at your own risk and expect breaking changes.

Current Status: Version 0.9.4 - Active Development


πŸ“– Table of Contents


🎯 About

Genesis is a general-purpose programming language designed with a focus on:

  • Familiarity - C++-style syntax that's easy to learn for developers from C, C++, Java, or JavaScript backgrounds
  • Type Safety - Stricter typing than JavaScript while maintaining simplicity
  • JavaScript Integration - Transpiles to clean, readable JavaScript for seamless ecosystem integration
  • No Runtime Overhead - Runs anywhere JavaScript runs (browsers, Node.js, Deno) without additional dependencies

Genesis combines the familiar syntax of compiled languages with the flexibility and ubiquity of JavaScript.


✨ Features

Currently Implemented

βœ… Static Typing - Declare variables with types (int, float, string, char, bool, double, void) βœ… Functions - Full function support with typed parameters and return values βœ… Control Flow - If/else statements and conditionals βœ… Operators - Arithmetic, comparison, and logical operators βœ… Built-in Functions - print() function for console output βœ… Clean Transpilation - Generates readable, well-formatted JavaScript βœ… CLI Tool - Command-line interface for building and running Genesis code

In Development

🚧 Loops - For and while loops (parser support exists, transpiler in progress) 🚧 Arrays - Array types and operations 🚧 Classes - Object-oriented programming support 🚧 Modules - Import/export system 🚧 Standard Library - Comprehensive built-in utilities


Installation

Global Installation (Recommended)

npm install -g genesis-project

Local Development

git clone https://github.com/Simpleboi/Genesis.git
cd Genesis
npm install
npm run build
npm link

Quick Start

1. Create a Genesis file

Create a file named hello.gen:

void greet(string name) {
    print("Hello, ");
    print(name);
}

int add(int x, int y) {
    return x + y;
}

greet("World");

int result = add(5, 3);
print(result);

2. Build and run

# Transpile to JavaScript
genesis build hello.gen --out hello.js

# Or transpile and run immediately
genesis run hello.gen

3. Output

Hello,
World
8

πŸ“š Language Guide

Variable Declarations

Genesis requires explicit type declarations:

int age = 25;
float price = 19.99;
string name = "Alice";
bool isActive = true;
double pi = 3.14159265359;

Transpiles to:

let age = 25;
let price = 19.99;
let name = "Alice";
let isActive = true;
let pi = 3.14159265359;

Functions

Functions use C-style syntax with typed parameters and return types:

// Function with return value
int multiply(int a, int b) {
    return a * b;
}

// Void function
void sayHello(string name) {
    print("Hello, " + name);
}

// Function calls
int product = multiply(4, 5);
sayHello("Genesis");

Transpiles to:

function multiply(a, b) {
    return a * b;
}

function sayHello(name) {
    print("Hello, " + name);
}

let product = multiply(4, 5);
sayHello("Genesis");

Control Flow

int x = 10;

if (x > 5) {
    print("x is greater than 5");
} else {
    print("x is 5 or less");
}

Expressions

int a = 10;
int b = 20;
int sum = a + b;
int difference = a - b;
int product = a * b;
int quotient = b / a;

bool isEqual = (a == b);
bool isGreater = (a > b);

πŸ”§ CLI Usage

Commands

# Build (transpile) a Genesis file
genesis build <file.gen> [--out <output.js>]

# Run (transpile and execute) a Genesis file
genesis run <file.gen>

# Show version
genesis --version

# Show help
genesis --help

Examples

# Transpile and save to file
genesis build src/main.gen --out dist/main.js

# Transpile and print to stdout
genesis build src/main.gen

# Transpile and run immediately
genesis run src/main.gen

πŸ“š Standard Library

Genesis automatically injects essential built-in functions into all transpiled code.

Built-in Functions

print(...args)

Outputs values to the console.

print("Hello");
print("Sum:", 5 + 3);

Transpiles to:

console.log("Hello");
console.log("Sum:", 5 + 3);

More standard library functions coming soon!


πŸ’‘ Examples

Example 1: Basic Calculator

int add(int a, int b) {
    return a + b;
}

int subtract(int a, int b) {
    return a - b;
}

int multiply(int a, int b) {
    return a * b;
}

int divide(int a, int b) {
    return a / b;
}

int x = 10;
int y = 5;

print("Addition:", add(x, y));
print("Subtraction:", subtract(x, y));
print("Multiplication:", multiply(x, y));
print("Division:", divide(x, y));

Example 2: Conditional Logic

int max(int a, int b) {
    if (a > b) {
        return a;
    } else {
        return b;
    }
}

int larger = max(15, 20);
print("The larger number is:", larger);

Example 3: Nested Functions

int square(int n) {
    return n * n;
}

int sumOfSquares(int a, int b) {
    return square(a) + square(b);
}

int result = sumOfSquares(3, 4);
print("3Β² + 4Β² =", result);  // Output: 25

More examples can be found in the src/examples/ directory.


Roadmap

Version 0.9.4 (Current)

  • Basic lexer and parser
  • Variable declarations with types
  • Function declarations and calls
  • Return statements
  • If/else statements
  • Binary expressions
  • Built-in print function
  • CLI tool

Version 1.0.0 (Target: March 2025)

  • While loops
  • For loops
  • Arrays and array operations
  • String manipulation
  • Type checking and validation
  • Better error messages
  • Comprehensive standard library
  • Full test coverage

Version 1.1.0 and Beyond

  • Classes and objects
  • Interfaces
  • Generics
  • Module system (import/export)
  • Enums
  • Switch statements
  • Try/catch error handling
  • Async/await support
  • Package manager integration
  • IDE support (syntax highlighting, LSP)
  • Sourcemap generation
  • Watch mode
  • REPL (Read-Eval-Print Loop)

See Issues for detailed feature requests and bug reports.


🀝 Contributing

Contributions are welcome! Genesis is an open-source project and we'd love your help.

How to Contribute

Please read CONTRIBUTING.md for detailed guidelines on:

  • Development setup
  • Project architecture
  • Coding standards
  • Testing requirements
  • Pull request process
  • How to add new language features

Good First Issues

Looking for a place to start? Check out issues tagged with good first issue.


πŸ“„ License

Genesis is licensed under the ISC License.

Copyright (c) 2024 Nathaniel E. Paz

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

πŸ”— Links


πŸ™ Acknowledgments


Made with ❀️ by Nathaniel E. Paz

⭐ Star this repository if you find it interesting!

About

Genesis is a general-purpose programming language designed with a focus on web development. Similar to JavaScript, Genesis is flexible enough to handle a wide range of tasks but is optimized for use within web applications

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published