{"id":19297203,"url":"https://github.com/nau/lasca-compiler","last_synced_at":"2025-04-22T08:31:14.535Z","repository":{"id":71692343,"uuid":"87207043","full_name":"nau/lasca-compiler","owner":"nau","description":"Lasca is Scala shifted towards Haskell.","archived":false,"fork":false,"pushed_at":"2018-10-27T13:57:35.000Z","size":9122,"stargazers_count":128,"open_issues_count":12,"forks_count":5,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-09T23:02:23.438Z","etag":null,"topics":["haskell","immutability","scala","simplicity"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-04T15:57:39.000Z","updated_at":"2024-10-14T01:36:29.000Z","dependencies_parsed_at":"2023-05-15T06:30:38.815Z","dependency_job_id":null,"html_url":"https://github.com/nau/lasca-compiler","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nau%2Flasca-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nau%2Flasca-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nau%2Flasca-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nau%2Flasca-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nau","download_url":"https://codeload.github.com/nau/lasca-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250206147,"owners_count":21392195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","immutability","scala","simplicity"],"created_at":"2024-11-09T23:01:47.707Z","updated_at":"2025-04-22T08:31:14.529Z","avatar_url":"https://github.com/nau.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"Lasca Language\n==============\n\n[![Build Status](https://travis-ci.org/nau/lasca-compiler.svg?branch=master)](https://travis-ci.org/nau/lasca-compiler)\n[![Join the chat at https://gitter.im/lasca-lang/compiler](https://badges.gitter.im/lasca-lang/Lobby.svg)](https://gitter.im/lasca-lang/compiler?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nLasca is Scala shifted towards Haskell.\n\nLasca is a LLVM-based statically or dynamically typed strict functional programming language. Simplified OCaml if you will.\n\nIt has a 'dynamic' compilation mode, meaning instant code generation without compile time type checking/inference, allowing instant compilation/execution cycle, and more freedom dynamic languages give.\n\nIt has a full type inference, parametric polymorphism, GC, algebraic data types, pattern matching,\nand type classes are coming soon.\n\nImagine\n\n- Scala with fast compilation/start time, optional dynamic typing, and without null\n- Go with ADTs, global type inference, and parametric polymorphism\n- Haskell with decent records syntax, runtime polymorphism, and string interpolation\n- OCaml with typeclasses, overloaded +-*/ for ints and floats, and do-notation\n- Rust with garbage collector without \u003c::\u003e!?\n- Erlang with types and fast execution\n- Python with multithreading, pattern matching, and multiline lambdas\n- TypeScript with indentation significant syntax, and LLVM\n- Julia with static type checking, and zero-based indexing\n\nInspired by:\n\n- Scala\n- Haskell, Liquid Haskell, Linear Haskell, Idris\n- OCaml/SML/F#/1ML\n- Clojure (persisted data structures, HAMT/CHAMP)\n- Go (CSP)\n- Erlang (actors, immutability, minimalism)\n- Python (docstrings, doctests, syntax)\n- Julia\n- Swift\n- Nim\n- Pony\n- [Koka](https://github.com/koka-lang/koka) (algebraic effects)\n\nIdeas\n---\n\n- light, non-symbol-polluted syntax (Python)\n- indentation-based\n- readability first\n- fast development cycle\n- presentation compiler for IDE integration\n- IDE-friendly (intellisence 'dot-autocomplete', auto-formatting, compiler API)\n- type-safe\n- strict functional\n- expression-based\n- practical first, but as clean and concise as possible\n- prefer things done one way\n- LLVM backend\n- JavaScript/WebAssembly backend (native or via LLVM/emscripten)\n- GraalVM backend?\n- no OOP and data subclassing/inheritance?\n- syntactic sugar is ok\n- no null\n- annotations (Java/Python-style)\n- annotation-based extensions\n- macros based metaprogramming (like Scala Macros, Template Haskell)\n- Concurrency Oriented Programming (Erlang). Objects are out. Concurrency is in.\n- [Gradual Typing](http://homes.soic.indiana.edu/jsiek/what-is-gradual-typing/)\n- Deferred Type Errors (runtime compilation mode, Haskell)\n- Linear/affine types (Rust, Linear Haskell)?\n- Liquid Type system (refinement types, [Leon](http://leon.epfl.ch), [Liquid Haskell](https://github.com/ucsd-progsys/liquidhaskell)) and\n  [Z3](https://github.com/Z3Prover/z3)/[CVC4](https://cvc4.cs.stanford.edu/web/) as proof assistant.\n- [Algebraic Subtyping for module system](https://www.cl.cam.ac.uk/~sd601/thesis.pdf)\n- import features (Scala-like)\n- compile-time and runtime reflection\n- save/distribute AST (Scala TASTY). Full program optimization/reflection\n- important things must be greppable and googlable, call it searchability :)\n- compiler as a service: [Language Server Protocol](https://langserver.org/)\n- markdown/rst comments/docs, doctest (Julia, Python)\n- CPS/Actors/π-calculus/STM?, non-blocking IO, reactive\n\nExample\n---\n\nCurrent implementation uses braces and semicolons, but I consider adding indentation-based syntax, or semicolon inference.\n\n```haskell\n-- Algebraic data type a la Haskell\ndata JValue\n    = JNull\n    | JNum(n: Float)\n    | JString(s: String)\n    | JBool(v: Bool)\n    | JArray(v: [JValue])\n    | JObject(v: Map String JValue)\n\n-- function argument type annotations are optional, compiler infers those\ndef jsonToString(js: JValue) = match js {\n    JObject(m) -\u003e\n        if Map.isEmpty(m) then \"{}\" else {\n            println(toString(m));\n            res = Array.makeArray(m.size, \"\");\n            var idx = 0;\n            Map.foreachWithKey(m, { k, v -\u003e\n                setIndex(res, idx.readVar, \"\\\"${k}\\\": ${jsonToString(v)}\");\n                idx := idx.readVar + 1;\n            });\n            s = String.join(\", \", res);\n            \"{ ${s} }\"\n        }\n    JNull -\u003e \"null\"\n    JNum(n) -\u003e toString(n)\n    JBool(v) -\u003e toString(v)\n    JString(v) -\u003e \"\\\"${v}\\\"\"\n    JArray(v) -\u003e {\n        values = Array.map(v, jsonToString);\n        toString(values);\n    }\n}\n```\n\nWhat Works Right Now\n---\n\n- JIT and AOT compilation and execution (via LLVM OrcJIT)\n  - lasca -e hello.lasca to execute\n  - lasca hello.lasca to create a binary\n- type inference\n- dynamic typing mode (```lasca -e --mode dynamic hello.lasca```)\n- ADTs, inner functions, out of order function definitions\n- pattern matching\n- calling external C functions\n- string interpolation, UTF8 encoded immutable strings\n- builtin types: `String`, `Bool`, `Int`, `Byte`, `Int16`, `Int32`, `Float`, `Array`, `ByteArray`, `Var`, `FileHandle`\n- implemented `List`, `Option`, `Either`, `Map`, `ArrayBuffer`\n- regular expressions with [PCRE-2](https://www.pcre.org/)\n- overloaded `+` `-` `*` `/` operators\n\nPackage System\n---\n\nConsider [Nix](https://nixos.org/nix/) as package manager\n\nCompiler Modes\n----\n\n- Dynamic Mode, aka Prototype Mode.\n  Syntax is checked.\n  All types are dynamically checked.\n- Static Mode.\n  Syntax is checked.\n  Typechecking/inference, faster execution.\n- Hardcore\n  Liquid types enabled.  (See Liquid Haskell)\n  Proves checked.\n  Array bounds checks eliminated.\n\nType System\n---\n\n- Hindley-Milner by default, dependent types if needed\n- traits, kind of type classes\n- Liquid types as in Liquid Haskell\n\nMemory Management\n----\n\nGC, concurrent mark and sweep\nper actor/green thread GC\nConsider [MultiCore Ocaml GC](http://kcsrk.info/multicore/gc/2017/07/06/multicore-ocaml-gc/)\n\nfor now, use [Boehm conservative GC](http://www.hboehm.info/gc/)\n\nOther\n---\n\n- indentation significant (i.e. Python, Haskell)\n- uppercase Typenames, lowercase idents and type arguments (Haskell/Scala style)\n- pattern-matching\n- ADT, traits, type classes\n- easy C interoperability\n- no exceptions (Go/Rust panic style errors)\n- don't overuse `'~!@#$%^\u0026* symbols\n- default immutability\n- string interpolation: \"${ident} = ${expression}\"\n- multiline strings\n- Uniform Function Call Syntax (Rust, D).\n  For example, any function can be a method for its first argument:\n\n```scala\n    def toString(s: String) = ...\n    \"Hello\".toString\n    def plus(l: Num, r: Num)\n    1.plus(2)\n```\n\n- uniform select principle. Use (.) for record field selection, func calls, package name resolution etc\n- UTF-8 strings\n- Haskell-like application for type functions: Option Int, Either Int String, etc\n\nInstall on Mac OS using Homebrew\n---\n\n    brew install boehmgc pcre2\n    brew install nau/lasca/lasca-compiler\n\nSetup LASCAPATH environment variable. Add this to your .bash_profile\n\n    export LASCAPATH=\"$(brew --prefix lasca-compiler)/src\"\n\nTry it!\n\n    echo 'def main() = println(\"Hello Lasca!\")' \u003e hello.lasca\n    lasca -e hello.lasca\n    \u003e Hello Lasca!\n\nAdd bash completion config for lasca compiler options:\n\n    lasca --bash-completion-script lasca \u003e $(brew --prefix)/etc/bash_completion.d/lasca\n\nBuild on Mac OS\n---\n\nYou need LLVM 6.0 installed, and latest Haskell Stack.\n\n    brew install cmake boehmgc pcre2\n\n    brew install llvm-hs/llvm/llvm-6.0 # this compiles llvm from sources, make take some time\n\n    brew install haskell-stack\n\n    stack setup\n\nSetup LASCAPATH environment variable. Add this to your .bash_profile\n\n    export LASCAPATH=\"${lasca-compiler-src-dir}/libs/base\"\n\nAdd your `~/.local/bin` directory to your `PATH`\n\n    export PATH=$PATH:~/.local/bin\n\nBuild and install lasca compiler\n\n    make install\n\nAdd bash completion config for lasca compiler options:\n\n    lasca --bash-completion-script lasca \u003e $(brew --prefix)/etc/bash_completion.d/lasca\n\nRun hello.lasca\n\n    lasca --exec examples/hello.lasca\n\nBuild on Ubuntu\n---\n\nRequirements: Haskell Stack \u003e 1.6, Cabal \u003e 2.0, LLVM 6, CMake\n\nDon't install Haskell Stack from apt. [It's likely to be older than 1.6 and won't be able to upgrade](https://askubuntu.com/questions/986596/how-to-upgrade-haskell-stack-on-ubuntu-16-04)\n\nDo this instead:\n\n    curl -sSL https://get.haskellstack.org/ | sh\n\n    sudo apt install llvm-6.0-dev libgc-dev zlib1g-dev cmake\n    sudo add-apt-repository universe\n    sudo apt install libpcre2-dev\n    export LASCAPATH=\"${lasca-compiler-src-dir}/libs/base\"\n    export PATH=$PATH:~/.local/bin\n    stack setup\n    make install\n    lasca -e examples/hello.lasca\n\nCurrent n-body run\n---\n\nThere are several implementation of [n-body problem](\nhttp://benchmarksgame.alioth.debian.org/u64q/nbody.html)\nCurrently it's quite slow due to boxing.\n\n    $ time lasca -e -O2 examples/nbody.lasca -- 50000000\n    -0.169075164\n    -0.169059907\n\n    real      7m13.261s\n    user      7m39.476s\n    sys       0m38.716s\n\n    find src -name \"*.hs\"  | xargs cat | wc -l\n    4738\n\n    cat rts/runtime.c rts/builtin.c rts/lasca.h | wc -l\n    1324\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnau%2Flasca-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnau%2Flasca-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnau%2Flasca-compiler/lists"}