0.0.1-alpha20 • Published 4 years ago

willet v0.0.1-alpha20

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Willet

The Willet Programming Language

Willet is an experimental functional programming language that compiles to JavaScript. Willet is heavily inspired by Clojure and tries to bridge the gap between JavaScript and Lisp without going all the way to a full Lisp syntax. Willet provides easy use persistent immutable data structures, a macro system, and a full featured standard library.

Try Willet in your browser

Install and Use

npm install willet
echo 'console.log("Hello Willet!")' > index.wlt
willet-compile index.wlt .
node index.js

Features

  • A fast and extensible* compiler written in JavaScript
  • Embraces JavaScript as a platform and leverages modern JS features
    • Async/await
    • Destructuring assignment, Rest and Spread
    • First class functions with default values
    • Easy integration with existing JavaScript code or libraries
    • Avoids some JS downsides such as the overly broad definition of false.
      • In Willet "false" is only literal false, null, and undefined
  • Persistent immutable data structures natively supported by language
    • Powered by Immutable
    • Literal syntax for maps, sets, and lists
    • Works with standard library functions
    • Equality by value*
  • Macro System allowing language level extensions
    • Helpful Built in macros
      • Chaining expressions - chain
      • Switching style - cond
      • List comprehensions - for
    • Major language features are written as macros
      • if and try catch
  • Standard Library with full set of functions/macros
    • Map, reduce, filter
    • Data structure walking*
    • Get, set, update deeply nested structures.
    • Partition, slice, and group data
    • And more

(* future feature)

Why Willet?

Modern JavaScript has a lot of great things like first class functions, promises and async/await, destructuring and a huge, well supported ecosystem. But its still got oddities from its past and is missing features that other modern functional programming languages have like macros and built-in immutable types.

Willet is an experiment.

If we start with JavaScript, its syntax, features, runtime, and libraries, and push it towards a Clojure-like Lisp how far do we have to go before we can get the same benefits? Can we get the same benefits of a homoiconic language and macros without going all the way to a Lisp syntax?

Other languages have done this like Elixir and there are other well supported languages that have these features in a JavaScript runtime such as ClojureScript. Willet is a chance to learn these things first hand and have fun building something.

What does Willet Look Like?

const quicksort = #([pivot ...others]) => {
  if (pivot) {
    concat(
      quicksort(filter(others #(v) => pivot >= v ))
      [pivot]
      quicksort(filter(others #(v) => pivot < v ))
    )
  }
}

Things to note:

  • No commas or semicolons needed.
    • Optional for readability or to remove ambiguity in certain situations.
  • No return statement necessary. Blocks always return the last result.
  • Data structures are immutable records automatically.
  • A built in standard library provides many functions like concat

More Information

Syntax Highlighting in Editors

Syntax highlighting is available for the Atom editor using the atom-language-willet package.

Setting Jupyter Notebook and Hydrogen in Atom Editor

Setting up jp-willet.

# Install willet lang globally
npm install -g willet-lang

# Install jupyter package
cd jp-willet
npm install
npm install -g
# Reference willet lang through symlink to global package which points to willet in this project
npm link willet
# Install the Jupyter Kernel
jp-willet-install
0.0.1-alpha20

4 years ago

0.0.1-alpha19

4 years ago

0.0.1-alpha18

4 years ago

0.0.1-alpha17

4 years ago

0.0.1-alpha16

4 years ago

0.0.1-alpha15

4 years ago

0.0.1-alpha13

4 years ago

0.0.1-alpha14

4 years ago

0.0.1-alpha12

4 years ago

0.0.1-alpha11

4 years ago

0.0.1-alpha10

4 years ago

0.0.1-alpha9

4 years ago

0.0.1-alpha8

4 years ago

0.0.1-alpha5

4 years ago

0.0.1-alpha7

4 years ago

0.0.1-alpha6

4 years ago

0.0.1-alpha4

4 years ago

0.0.1-alpha3

4 years ago

0.0.1-alpha2

4 years ago

0.0.1-alpha1

4 years ago