Git Product home page Git Product logo

m-language's Introduction

M Language

travis build

The M programming language is a minimal Lisp for the JVM, JS, and Native, designed from the ground up to be as simple as possible for fast compilation and reusable optimizations.

Getting Started

See the getting started guide.

What it looks like

;; This is a comment

;; Definitions are global and unordered
(def list/empty ())

;; Functions are single argument curried lambdas
(def id (fn x x))
(def const (fn x _ x))

;; Application is also curried
(def swap (fn f x y (f y x)))

;; New forms can be constructed using macros
(macro defn ...)   ; implementation elided
(defn compose f g x (f (g x)))

;; Quotes can be used for special symbols
(def "a name with spaces in it" ...)

;; Pound is syntax sugar for applying a macro to the whole file
#(package demo)

;; Everything after this point is provided as a library
;; and not as part of the language

;; Imports are defined in package.m
#(import nat)

;; Natural numbers are defined in nat.m
(def inc (+ 1))
(def dec ((swap -) 1))

;; Lists are defined in list.m
(defn sum list
  (fold list 0 +))

;; If expressions are macros defined in bool.m
(defnrec factorial x
  (if (= x 0) 1
    (* x (factorial (dec x)))))

;; Processes are used for IO
(defrec echo
  (do
    (x (read-line stdin))
    (_
      (run-async
        (write-line stdout x)
        (write-line (file-out (string "out.log")) x)))
    (_ echo)))

;; Data types are defined in data.m
(defdata point x y)
(def origin (point 0 0))

For more information, an in-depth tutorial can be found here, and the specification can be found here (also available as markdown and html).

Current State

M is currently in pre-alpha; some parts of the language and many parts of the standard library are unimplemented, while others are not heavily tested or are subject to unhelpful errors. Progress is being made every day, but there is still a lot of work to be done, so it will be a while before the language is easily useable.

Contributing

There's a lot of work to be done on M, and any help is greatly appreciated. If there's a feature you want to add, please open an issue and I'll help however I can. If you want to add an editor plugin, language backend, or other tooling, please contact me personally and I'll add it to the organization.

If you want to help M succeed but don't want to contribute code, please consider starring this repository to help others find it.

m-language's People

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.