Giter Site home page Giter Site logo

ryzerproxy / terbium Goto Github PK

View Code? Open in Web Editor NEW

This project forked from terbium-lang/terbium

0.0 0.0 0.0 7.77 MB

The performant yet elegant and feature-packed programming language. Made with Rust.

License: GNU Affero General Public License v3.0

Rust 100.00%

terbium's Introduction

Terbium

The performant yet elegant and feature-packed programming language. Implemented with Rust.

Installation

Terbium is still a work in progress. You can contribute by simply cloning this repository, however.

This means some promises made here are merely goals we want to accomplish for Terbium.

Hello, world!

require std;

func main() {
    std.println("Hello, world!");
}

Goals

We want Terbium to meet the following:

  • A language that doesn't take long to learn
  • A language emphasizing strong and static types
    Types are static, but type inference will exist
  • A language which is fast and performant
  • A language which is elegant to write and emphasizes readability
  • A language that utilizes a comprehensive analyzer that catches bugs before runtime
  • A language which utilizes explicit mutability

Static types?

We want to enforce a static type system in Terbium that isn't too restrictive:

  • All variables, unless redeclared, will have a constant type
  • Default all types to the auto type (Type inference)
    • When a type cannot be inferred, use the any type unless explicitly disabled (@trb:strict)
  • Allow for a robust type system (think Generics)

Terbium designs static types like this so that while beginners don't have to learn Terbium with the complexity of a type system, and gradually implement these types as they learn more about them.

Ran at compile-time

The static-type checker, along with other types of analysis (such as optimization), is run at compile-time*. This ensures that your code will run as expected with minimal errors before even running.

* If you run Terbium using its interpreter, analysis will be run immediately before runtime.

Yes, we have null.

A very common pattern in more modernized languages are those which lack a "null" type.

We chose to keep null but make it required to explicitly handle and propagate null, specifically with the static type-checker which is run at compile-time. Luckily, doing such is easy.

There is also the ExplicitNullHandler class which you can use to utilize an "unwrap-like" interface over null. This type is used in many of the interfaces in Terbium's standard library.

Concise Code

We also want to make Terbium code as concise as possible, without sacrificing performance or readability.

Examples:

Statements are Expressions

Directly assign the result of an if statement to a variable:

let x = if 1 + 1 == 2 {
    std.println("1 + 1 is indeed 2!");
    2
}

std.println(x); // 2

Call a function with the result of a match statement:

std.println(match 1 + 1 {
   1 -> "one",
   2 -> "two",
   else "other",       
});

or... use non-expressions with match:

std.println(match 1 + 1 {
    2 -> {
       let message = "two";
       message
    },
    else {
        let message = "other";
        message
    },
});

(above three inspired by Rust)

Efficient null handling:

Null propagations and assertions:

std.println(x.y?.z!);

// equivalent to:
// if x.y { if x.y.z { std.println(x.y.z) } else { throw error } } else { std.println("null") }

(above inspired by TypeScript)

Repository Navigation

  • terbium_analyzer: Analyzes Terbium code and houses the static type-checker. This is run at compile-time and apart from ensuring type-safety, will try picking as many places that could be optimized, and as many places that could lead to errors at runtime.
  • terbium_bytecode: Transforms Terbium source code into Terbium bytecode, and intermediate representation of Terbium runtime code that can be either interpreted or compiled.
  • terbium_grammar: Tokenizes Terbium code and transforms it into an Abstract Syntax Tree (AST).
  • terbium_interpreter: The interpreter which interprets and evaluates code generated from terbium_grammar.
  • terbium: The top-level Rust crate providing access to all other Rust crates listed here. This also houses the source for Terbium's CLI implementation.
  • lib: The Terbium standard library and stub declarations for builtin objects/types.

Contributing

See CONTRIBUTING.md for details.

Credits

Terbium is a project by jay3332.

Thanks to the following core contributors:

terbium's People

Contributors

cryptex-github avatar jay3332 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.