Giter Site home page Giter Site logo

vcfxb / wright-lang Goto Github PK

View Code? Open in Web Editor NEW
20.0 4.0 3.0 1.87 MB

The wright programming language (WIP)

Home Page: https://wright.venusblon.de/

License: MIT License

Rust 99.22% HTML 0.78%
programming-language wright wright-programming-language rust language wright-language programming programming-languages

wright-lang's Introduction

The Wright Programming Language

A language that flies

Wright is an all-purpose programming language inspired by Rust, Ada, and Typescript. Pulling from all three of these excellent languages, Wright intends to offer a combination of speed, ergonomics, and precision.

Badges

Wright is automatically checked and tested using the latest available github runners for Ubuntu, MacOS, and Windows

Service Badge
Cargo Check Status Cargo Check status
Cargo Test Status Cargo Test status
Cargo Clippy Status Cargo Clippy status
Code Coverage (Coveralls) Coverage Status
Code Coverage (Codecov.io) codecov
Docs.rs Documentation
Crates.io Crates.io
GitHub release GitHub release
GitHub (pre-)release GitHub (pre-)release
Development Status Status
Downloads
Total Github All Releases
Releases Github Releases
Pre-Releases Github Pre-Releases
Crates.io Crates.io
Crates.io (Latest) Crates.io

Syntax Samples

// Hello World! 
use wright::io::println;

func main() {
    println("Hello World!");
}
// FizzBuzz 1 through 100
use wright::io::println;

type FizzBuzzInteger = integer constrain |i| { i <= 100 && i >= 0 };

func fizzbuzz(i: FizzBuzzInteger) {
    if i % 15 == 0 { println("FizzBuzz"); }
    else if i % 5 == 0 { println("Buzz"); }
    else if i % 3 == 0 { println("Fizz"); }
    else { println(i); }
}

func main() {
    // Compiler error here if we use a range iterator that contains a value violating the constraints of 
    // `FizzBuzzInteger`. 
    (1..=100).for_each(fizzbuzz);
}

The core goals of the language:

  • Developer experience -- Every error message, syntax choice, and standard library function should be friendly and well documented.
  • Robustness -- Wright's type system should be expressive enough to appropriately capture the domain, representation, and functionality of every symbol the programmer interacts with.
  • Speed -- Wright leverages the newest major version of LLVM (at the time of writing, LLVM 18), to compile code directly to assembly, avoiding the overhead of an interpreter, garbage collector, and other associated tools by default.
  • Memory Safety -- Wright pulls significant inspiration from Rust's lifetime system, with some modifications.

Installation:

There are several installation options.

  • Get the latest stable version from the releases page.
  • If you have rust, via cargo install wright.
  • Building from source, by cloning this repository, and running cargo build --release in the wright directory, and then adding wright/target/release to your system path. You will need LLVM 18 installed and appropriately configured to compile Wright. See the llvm-sys crate docs for tips on how to do this.

wright-lang's People

Contributors

dependabot-preview[bot] avatar io12 avatar kvverti avatar vcfxb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wright-lang's Issues

The Semicolon Operator and Expression Categories

Currently, the semicolon ; (used to sequence expressions) is a binary operator. However, in some cases, treating ; this way results in weird-looking code. For example,

func(1, 2; 3, 4)

would be equivalent to

func(1, 3, 4)

As well, this creates ambiguity with the hypothetical variable declaration

"let" Identifier "=" Expression

If Expression is a semicolon-expression.

let x = 5; 3
(let x = 5); 3
let x = (5; 3)

Some of the weirdness could be solved by having different categories of expressions for each of these cases, e.g. NonSemicolonExpression, ExpressionOrVariableDecl.

Block Parser

Block ::= "{" [[Expression [";"]] "}"

Notes:

  • Blocks do not need an expression list because the semicolon ; is a binary operator.
  • The unit value (of the type void) might be expressed as {}.

Treating blocks as expressions that return the value of Expression poses a parsing question: should blocks be valid anywhere an expression is? Examples include

3 + { "hello"; 4 }
func(3, { 2; 1 })

In this case, if ; keeps being an operator, blocks have the same grouping properties as parentheses ().

3 + ("hello"; 4)
func(3, (2; 1))

Should parenthesized expressions also be considered blocks by the grammar?

AstEq trait

Tracking issue for AstEq trait that compares AST nodes but ignores fragments.

Wright Expression Precedence

Here is a list of applicable Wright expressions with in suggested precedence order.

{
  a::b; // scope resolution
  a.b; // member access
  a..b; // half open range
  a * b / c % d // multiplication/division/remainder
  a + b - c; // addition/subtraction
  a & b; // bitwise and
  a ^ b; // bitwise/logical xor
  a | b; // bitwise or
  a && b; // logical and
  a || b; // logical or
  a < b > c <= d >= e; // comparison
  a == b != c; // equality
  a = b; // assign
  let a = b; // variable creation and jump expressions (e.g. return)
}

This order follows the precedence order in C-like languages, with the additions of variable creation and jump expressions binding at the lowest precedence.

Expressions like { a } and if a { b } else { c } don't need precedence because they do not expose a bare expression at the head or the tail.

Conditional Expression parser

Conditional expression parser tracking issue.

Syntax should be along the lines of

"if", expr, block, ("else", "if", expr, block)*, ["else", block] 

Targets

This is pretty far in the future, but I'll leave some platforms I'm considering targeting here, to look back at for reference later:

  • C
  • JVM
  • LLVM
  • Cretonne (If it still exists.)
  • Rust (maybe?)
  • MIPS (or some subset)
  • Brainfuck (maybe?)
  • WASM (maybe?)

Error module

Finishing up the error module and writing unit tests.

Multiline comments

Once #18 is merged we will need to add on to and modify it to also work for multiline comments. This is the tracking issue for that.

WebAssembly

Does the compiler run on WebAssembly (wasm)? Is such feature planned?

Type System

Tracking issue for the wright type system and type parsers

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.