Git Product home page Git Product logo

crux's Introduction

Crux is a principled, practical language that aims to provide an easy, familiar programming environment that does not compromise on rock-solid fundamentals.

Big Ideas

Crux is all about small, well-understood ideas that fit together without clumsy seams or weird corner cases.

We won't try to guess what you're trying to say because we don't think your customers should be the ones to tell you that we guessed wrong.

Our intent with Crux is to capture

  • the joy and human factors of Python
  • the ability to run the same code on the frontend and backend
  • the straightforward performance and operational semantics of ML
  • the safety under overloading of Haskell
  • and the lightweight M:N concurrency of Go, Haskell or Python

What does it look like?

fun getFolderContents(folder) {
    let rv = []

    let contents: Array String = fs.readdirSync(folder)
    for entry in contents {
        let absEntry = combine(folder, entry)
        let stat = fs.lstatSync(absEntry)
        if stat.isFile() && (entry->endsWith(".jpeg") || entry->endsWith(".jpg")) {
            rv->append(entry)
        }
    }

    return rv
}

Status

Working:

  • Type inference
  • Sums
  • Pattern matching
  • Row-polymorphic records
  • if-then-else
  • "imperative" control flow: return, break, continue
  • Loops
  • Type aliasing
  • Mutability
  • "everything is an expression"
  • Tail Calls

Partially done:

  • JS FFI
  • Modules
  • Exceptions

Not done:

  • Asynchrony
  • Class definitions
  • Native code generation
  • Interpreter
  • Type classes / traits

Compiling

The Crux compiler is a Haskell program, but you don't need to be a Haskell programmer to build or use it.

If you're familiar with building Haskell software, we expect the compiler to build either with cabal or stack.

If not, read on:

  1. Get stack. https://docs.haskellstack.org/en/stable/README/
  2. git clone https://github.com/cruxlang/crux
  3. cd crux
  4. stack install

This will build crux and install it to ~/.local/bin/crux.

A Tour of the Code

  1. Lex.hs converts bytes into Tokens (see Token.hs)
  2. Parse.hs converts Tokens into the AST (see AST.hs)
  3. Typecheck.hs type-checks the AST, producing a typed AST (see TypeVar.hs and Unify.hs)
  4. Gen.hs converts the AST into an IR
  5. JSBackend.hs converts the IR into JS
  6. JSTree.hs converts the JS AST into output bytes

Main.hs is the general command-line interface.

Look at Module.hs and Project.hs for the code to load modules and projects.

crux's People

Contributors

andyfriesen avatar chadaustin avatar jwatte 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.