Giter Site home page Giter Site logo

gmh5225 / schmu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tjammer/schmu

0.0 0.0 0.0 3.07 MB

A WIP programming language inspired by ML and powered by LLVM

License: GNU General Public License v3.0

Shell 0.07% C++ 0.05% C 0.03% Emacs Lisp 1.54% OCaml 98.16% Nix 0.11% Makefile 0.04%

schmu's Introduction

schmu

A WIP small, mostly functional programming language which compiles to native code.

Disclaimer schmu is a passion project which I develop for fun. Please don't use it for anything too serious.

schmu is the language I'd like to program in: A strongly typed, type-inferred compiled language that can be programmed in a functional way (see below). It prefers stack- over heap allocations, and can easily interface with C code.

Here's what it looks like:

Fibonacci example

-- Variable binding
(val number 35)

-- Calculate fibonacci number
(fun fib [n]
  (match n
    ((or 0 1) n)
    (_ (+ (fib (- n 1)) (fib (- n 2))))))

-- and print it
(print (fmt-str (fib number)))

A note on syntax: For ease of development, schmu currently uses an s-expression based syntax. The plan is to switch back to a more traditional syntax once the semantics are closer to being finalized.

More examples can be found in the test directory. It is still WIP, see the roadmap below.

Features

  • Functional schmu is a functional language based on a Hindley-Milner type system. This means all the basic features one might expect from a functional language are (will be) present, like

    • Higher order functions and automatic closures
    • Sum types and pattern matching
    • Recursive data types
  • Simple schmu is a small and simple language. Apart from parametric polymorphism (and hopefully a robust module system in the future), there are no advanced features like GADTs or type classes, not even operator overloading. The goal is to strike a balance between keeping the user focused on writing clean abstractions without overwhelming them with many competing options, while at the same time providing an expressive type system that doesn't feel like it's holding them back from being productive.

  • Practical schmu aims to be a practical language. It allows impure functions and the use of immutable data types such as arrays (and vectors, their growable cousins) for their simplicity and performance. Data types are unboxed (as long as they are non-recursive, anyway) to make interop with C code straightforward. It doesn't try to compete with the fastest languages out there, but should be reasonably fast thanks to LLVM. The memory management story is not fully fleshed out yet, right now there is a builtin malloc which gets freed at the end of scope automatically, RAII style, but that's all.

Roadmap

  • Higher order functions and (downward) closures
  • Polymorphic functions and monomorphization
  • Type-parametrized records
  • Algebraic data types and pattern matching
  • Module system
  • Recursive data types
  • C ABI compatibilty. WIP, the machinery is in place and it's mostly done for x86_64-linux-gnu. Other targets will be added in the future.

schmu's People

Contributors

tjammer 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.