• Stars
    star
    227
  • Rank 175,900 (Top 4 %)
  • Language
  • Created over 8 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

List of languages that compile to python

We have variants of Python that can use Python libs: welcome to Dogelang, Mochi, Hy, Coconut and Hask.

We can also have languages that target the Python platform without being necessarily compatible with Python, and domain-specific languages.

For more ressources related to functional programming in Python, see the Awesome Functional Python list.

Table of Contents

Variants of Python. They can use Python libs.

The following languages can make use of the Python libraries.

Dg - it's a Python ! No, it's a Haskell !

NOT'REALLY®

Dogelang  
sources https://github.com/pyos/dg
doc https://pyos.github.io/dg/
v1 ? yes, april 2015
created june, 2012
  • compiles to CPython 3.4. Dg is an alternative syntax to Python 3.
  • compatible with all the libraries
  • runs on PyPy

Language features

  • function calls without parenthesis:
print "wow" "two lines" sep: "\n"
  • reverse pipe operator:
print $ "> {}: {}".format "Karkat" "Reference something other than Doge"
  • pipe and reverse pipe (on the same line, unlike Mochi)
print <| 'What' + 'ever.' : 'This is the same thing ' + 'in a different direction.' |> print
  • function notation (arrow -> notation)
function = arg1 arg2 -> : print (arg1.replace "Do " "Did ") arg2 sep: ", " end: ".\n"
function "Do something" "dammit"
  • infix notation (with backticks)
  • function composition (with <-)
  • first class operators
f = (+)
f 1 2 == 3
  • partial application (and bind is functools.partial)
f = (2 *)
f 10 == 20
  • new functional builtins: foldl and foldl1, scanl, flip, takewhile and dropwhile (from itertools), take and drop, iterate, head and fst, tail, snd, last and init.

  • decorators don't need special syntax, they're just called with a function

    wtf = the~decorator~ $ ->
    

Install

    pip3 install git+<https://github.com/pyos/dg>

Editors

Editor  
Gedit https://github.com/pyos/dg-gedit/
Sublime https://github.com/pyos/dg-textmate/

Pygments support.

Example projects

Project  
dogeweb , a functional web framework atop asyncio https://pyos.github.io/dogeweb/

Hissp - It's Python with a Lissp!

Hissp is a modular Lisp implementation that compiles to a functional subset of Python—Syntactic macro metaprogramming with full access to the Python ecosystem!

Hissp  
sources https://github.com/gilch/hissp
doc https://hissp.readthedocs.io/
v1 ? no, v0.2 as of May 2021
created 2019
discuss gitter

The Hissp compiler is written in Python 3.8.

Language features

The Hissp compiler should include what it needs to achieve its goals, but no more. Bloat is not allowed.

Hissp compiles to an unpythonic functional subset of Python.

Hissp's basic macros are meant to be just enough to bootstrap native unit tests and demonstrate the macro system. They may suffice for small embedded Hissp projects, but you will probably want a more comprehensive macro suite for general use.

You do not need Hissp installed to run the final compiled Python output

(defmacro attach (target : :* args)
  "Attaches the named variables as attributes of the target.

  Positional arguments use the same name as the variable.
  Names after the ``:`` are key-value pairs.
  "
  (let (iargs (iter args)
        $target `$#target)
    (let (args (itertools..takewhile (lambda (a)
                                       (operator..ne a ':))
                                     iargs))
      `(let (,$target ,target)
         ,@(map (lambda (arg)
                  `(setattr ,$target ',arg ,arg))
                args)
         ,@(map (lambda (kw)
                  `(setattr ,$target ',kw ,(next iargs)))
                iargs)
         ,$target))))

Hy - A dialect of Lisp that's embedded in Python

Hy  
sources https://github.com/hylang/hy/
doc http://hylang.org/
v1 ? no
created december, 2012
online REPL https://try-hy.appspot.com/
discuss google group
IRC hy on freenode
  • Hy compiles to Python bytecode (AST)
  • Hy can use python libraries, and we can import a Hy module into a Python program.

Language features

  • it's python: context managers, named and keyword arguments, list comprehensions,...
  • macros, reader macros
  • threading macros (like Clojure), with -> and ->> (similar to pipes)
(-> (read) (eval) (print) (loop))
(import [sh [cat grep wc]])
(-> (cat "/usr/share/dict/words") (grep "-E" "^hy") (wc "-l"))  ; => 210
(require hy.contrib.anaphoric)
(list (ap-map (* it 2) [1 2 3]))  ; => [2, 4, 6]
  • fraction literal (like Clojure)
  • unicode support (I mean for symbols)
  • pattern matching (in libraries, like Hyskell)
  • monads (in libraries, like Hymn)

Install

    pip install hy

Editors

Editor  
Emacs https://github.com/hylang/hy-mode
All lisp modes for any editor

Example projects

Project  
Github trending https://github.com/trending/hy
Live coding Blender https://github.com/chr15m/blender-hylang-live-code

Good reads

Title  
How Hy backported "yield from" to Python 2 http://dustycloud.org/blog/how-hy-backported-yield-from-to-python2/

Mochi - Dynamically typed programming language for functional programming and actor-style programming

Mochi  
sources https://github.com/i2y/mochi
doc many examples
v1 ? no
created v0.1 on december, 2014
  • translates to Python3's AST/bytecode

Language features

  • Python-like syntax
  • pipeline operator (multiline ok)
range(1, 31)
|> map(fizzbuzz)
|> pvector()
|> print()
  • tail-recursion optimization (self tail recursion only)
  • no loop syntax
  • re-assignments are not allowed in function definition
  • persisent data structures (using Pyrsistent)
  • Pattern matching / Data types, like algebraic data types
  • Syntax sugar of anonymous function definition (-> notation and $1 for the arguments)
  • Actor, like the actor of Erlang (using Eventlet)
  • Macro, like the traditional macro of Lisp
  • Anaphoric macros
  • Builtin functions includes functions exported by itertools module, recipes, functools module and operator module

Install

    pip3 install mochi

Editors

Editor  
Atom https://github.com/i2y/language-mochi

Good reads

Coconut - Simple, elegant, Pythonic functional programming

Coconut  
sources https://github.com/evhub/coconut
doc https://coconut.readthedocs.io
v1 ? yes, on june, 2016
created february, 2015 (v0.1)
  • Coconut compiles to Python (not CPython bytecode, so it supports other Python implementations: PyPy, Jython, etc)

  • Coconut code runs on any major Python version, 2 or 3

  • all valid Python 3 is valid Coconut: you can write standard Python3 in Coconut.

  • ipython / jupyter support (installed by default)

Language features

  • pipelines
(1, 2) |*> (+) |> sq |> print

For multiline pipes, surround them with parenthesis (python rule that every newline inside parenthesis is ignored):

(
    "hello"
    |> print
)
  • pattern matching (match x in value:), guards
  • algeabric data types
  • partial application ($ sign right after a function name)
expnums = map(pow$(2), range(5))
expnums |> list |> print
  • lazy lists (surround comma-separated lists with (| and |))
  • destructuring assignment
  • function composition (with ..)
fog = f..g
  • prettier lambdas (-> syntax)
  • parallel programming
  • tail recursion optimization
  • infix notation (like in Haskell with backticks)
  • underscore digits separators (10_000_000)
  • decorators support any expression
@ wrapper1 .. wrapper2 $(arg)
  • code pass through the compiler
  • ...

Install

    pip install coconut

Editors

  • Pygments support
Editor  
Emacs https://github.com/NickSeagull/coconut-mode
Sublime https://github.com/evhub/sublime-coconut
Vim https://github.com/manicmaniac/coconut.vim

Hask - Haskell language features and standard libraries in pure Python.

Hask  
sources https://github.com/billpmurphy/hask
doc on github
v1 ? no
created july, 2015

Hask is a pure-Python, zero-dependencies library that mimics most of the core language tools from Haskell, including:

  • Full Hindley-Milner type system (with typeclasses) that will typecheck any function decorated with a Hask type signature. Also, typed functions can be partially applied.
@sig(H/ "a" >> "b" >> "a")
def const(x, y):
    return x
  • Easy creation of new algebraic data types and new typeclasses, with Haskell-like syntax
  • Pattern matching with case expressions
def fib(x):
    return ~(caseof(x)
                | m(0)   >> 1
                | m(1)   >> 1
                | m(m.n) >> fib(p.n - 1) + fib(p.n - 2))
  • Automagical function currying/partial application and function composition
  • Efficient, immutable, lazily evaluated List type with Haskell-style list comprehensions
  • All your favorite syntax and control flow tools, including operator sections, monadic error handling, guards, and more
  • Python port of (some of) the standard libraries from Haskell's base, including:
    • Algebraic datatypes from the Haskell Prelude, including Maybe and Either
    • Typeclasses from the Haskell base libraries, including Functor, Applicative, Monad, Enum, Num, and all the rest
    • Standard library functions from base, including all functions from Prelude, Data.List, Data.Maybe, and more

Features not yet implemented, but coming soon:

- Python 3 compatibility
- Better support for polymorphic return values/type defaulting
- Better support for lazy evaluation (beyond just the List type and pattern matching)
- More of the Haskell standard library (Control.* libraries, QuickCheck, and more)
- Monadic, lazy I/O

Install

git clone https://github.com/billpmurphy/hask
python setup.py install

Rabbit - a functional language on top of Python (discontinued in favor of Coconut)

Rabbit  
sources https://github.com/evhub/rabbit
doc no doc
v1 ? yes, on oct, 2014. DISCONTINUED
created v0.1 on may, 2014

From the author's words: (src)

Coconut is my attempt to fix the mistakes I thought I made with Rabbit, namely:

  • Coconut is compiled, while Rabbit is interpreted, making Coconut much faster
  • Coconut is an extension to Python, while Rabbit is a replacement, making Coconut much easier to use

Quicksort:

qsort(l) = (
    qsort: (as ~ \x\(x @ x<=a)) ++ a ++ qsort: (as ~ \x\(x @ x>a))
    $ a,as = l
    ) @ len:l

Implemented in another language but target the Python platform. They can use Python libs.

Erg - General statically typed multiparadigm rusty programming language

A statically typed language that can deeply improve the Python ecosystem

Erg  
sources https://github.com/erg-lang/erg
doc https://erg-lang.github.io/
v1 ? no, v0.4.2 as of September 2022
created 2022

The Erg compiler is written in Rust.

Language features

Erg is a pure object-oriented language. Everything is an object; types, functions, and operators are all objects. On the other hand, Erg is also a functional language. Erg requires some kinds of markers to be placed on code that causes side effects or changes internal state, which can localize the complexity of code. This will greatly improve the maintainability of your code.

Erg is internally compatible with Python and can import the Python API at zero cost.

    # Functional style (immutable), same as `sorted(list)` in Python
    immut_arr = [1, 3, 2]
    assert immut_arr.sort() == [1, 2, 3]
    # Object-oriented style (mutable)
    mut_arr = ![1, 3, 2]
    mut_arr.sort!()
    assert mut_arr == [1, 2, 3]
    i = !1
    i.update! old -> old + 1
    assert i == 2

    # Functions cannot cause side effects
    inc i: Int! =
        i.update! old -> old + 1
    # SyntaxError: cannot call a procedural method in a function
    # hint: only methods of mutable types can change the state of objects

    # Code that uses a lot of side effects is redundant, so you will naturally write pure code
    Counter! = Inherit Int!
    Counter!.
        new i: Int = Self!::__new__ !i
        inc! ref! self =
            self.update! old -> old + 1

    c = Counter!.new 1
    c.inc!()
    assert c == 2

Other languages that target the Python platform

Haxe, the cross-platform toolkit

Haxe  
sources https://github.com/HaxeFoundation/haxe
official website https://haxe.org/
doc https://haxe.org/documentation/introduction/
online REPL _http://try.haxe.org/
v1 ? v3

Haxe is an open source toolkit that allows you to easily build cross-platform tools and applications that target many mainstream platforms (Python, ActionScript3, C++, C#, Flash, Java, Javascript, NekoVM, PHP, Lua).

class Test {
  static function main() {
    var people = [
      "Elizabeth" => "Programming",
      "Joel" => "Design"
    ];
    for (name in people.keys()) {
      var job = people[name];
      trace('$name does $job for a living!');
    }
  }
}

Domain-specific languages

ProbLog. Probabilistic Logic Programming.

Probabilistic logic programs are logic programs in which some of the facts are annotated with probabilities.

ProbLog  
official website https://dtai.cs.kuleuven.be/problog/
sources https://bitbucket.org/problog/problog
doc http://problog.readthedocs.io/en/latest/
v1 ? yes, even v2
online tutorial and REPL https://dtai.cs.kuleuven.be/problog/tutorial.html

ProbLog is built with Python. Its only requirement is Python2.7 or 3.

One can interact with ProbLog from within Python code.

Install

pip install problog

PyDatalog. Logic programming to use inside your Python program.

PyDatalog  
official website https://sites.google.com/site/pydatalog/
sources https://github.com/pcarbonn/pyDatalog
doc https://sites.google.com/site/pydatalog/Online-datalog-tutorial
v1 ? v0.17 (january, 2016)
PyPy ? yes

pyDatalog adds the logic programming paradigm to Python. Logic programmers can now use the extensive standard library of Python, and Python programmers can now express complex algorithms quickly.

from pyDatalog import pyDatalog
pyDatalog.create_terms('factorial, N')


factorial[N] = N*factorial[N-1]

factorial[1] = 1

print(factorial[3]==N)  # prints N=6

Installation

pip install pyDatalog pip install sqlalchemy

Example projects

No examples found, only testimonials.

RBQL: SQL dialect with Python expressions

RBQL  
official website https://rbql.org
sources https://github.com/mechatroner/RBQL
v1 ? no
PyPy ? pip install rbql

RBQL is both a library and a command line tool which provides SQL-like language with Python expressions
RBQL is integrated into "Rainbow CSV" text editor plugins available for VSCode, Vim, Sublime, Atom
Main Features:

  • Allows to use Python expressions inside SELECT, UPDATE, WHERE and ORDER BY statements
  • Result set of any query immediately becomes a first-class table on it's own
  • Works out of the box, no external dependencies

Usage example:

import rbql
input_table = [
    ['Roosevelt',1858,'USA'],
    ['Napoleon',1769,'France'],
    ['Dmitri Mendeleev',1834,'Russia'],
    ['Jane Austen',1775,'England'],
    ['Hayao Miyazaki',1941,'Japan'],
]
user_query = 'SELECT a.name, "birth century: {}".format(a.DOB // 100 + 1) WHERE a.name == "Roosevelt" or re.search("an", a.country, re.IGNORECASE) is not None ORDER BY random.random()'
output_table = []
warnings = []
rbql.query_table(user_query, input_table, output_table, warnings, input_column_names=['name', 'DOB', 'country'])
for record in output_table:
    print(','.join([str(v) for v in record]))

Other languages built in RPython

Monte - secure distributed computation

Monte is a "nascent dynamic programming language reminiscent of Python and E. It is based upon The Principle of Least Authority (POLA), which governs interactions between objects, and a capability-based object model, which grants certain essential safety guarantees to all objects".

Monte  
Sources https://github.com/monte-language
Doc https://monte.readthedocs.io/en/latest/intro.html
v0.1 ? yes, v2016.1

Built on Pypy.

Pixie, a lightweight and native lisp

Pixie  
Sources https://github.com/pixie-lang/pixie
Doc Examples: https://github.com/pixie-lang/pixie/tree/master/examples
v0.1 ? no
REPL, installer, test runner,… https://github.com/pixie-lang/dust
IRC #pixie-lang on Freenode

Pixie is built in RPython, the same language PyPy is written in, and as such "supports a fairly fast GC and an amazingly fast tracing JIT".

Inspired by Clojure.

Features

  • Immutable datastructures
  • Protocols first implementation
  • Transducers at-the-bottom (most primitives are based off of reduce)
  • A "good enough" JIT (implemented, tuning still a WIP, but not bad performance today)
  • Easy FFI
  • object system
  • continuations, async I/O inspired by nodejs (see talk)
  • Pattern matching (planned)

From the FAQ:

  • Pixie implements its own virtual machine. It does not run on the JVM, CLR or Python VM. It implements its own bytecode, has its own GC and JIT. And it's small. Currently the interpreter, JIT, GC, and stdlib clock in at about 10.3MB once compiled down to an executable.
  • The JIT makes some things fast. Very fast. Code like the following compiles down to a loop with 6 CPU instructions. While this may not be too impressive for any language that uses a tracing jit, it is fairly unique for a language as young as Pixie.
;;  This code adds up to 10000 from 0 via calling a function that takes a variable number of arguments.
;;  That function then reduces over the argument list to add up all given arguments.

(defn add-fn [& args]
  (reduce -add 0 args))

(loop [x 0]
  (if (eq x 10000)
    x
    (recur (add-fn x 1))))
  • Math system is fully polymorphic. Math primitives (+,-, etc.) are built off of polymorphic functions that dispatch on the types of the first two arguments. This allows the math system to be extended to complex numbers, matrices, etc. The performance penalty of such a polymorphic call is completely removed by the RPython generated JIT.

Good talks

RSqueak, a Squeak/Smalltalk VM written in RPython

RSqueak  
Sources https://github.com/HPI-SWA-Lab/RSqueak
Doc http://rsqueak.readthedocs.io

with all-in-one multiplatform bundles and 32 bits binaries.

More Repositories

1

cl-str

Modern, simple and consistent Common Lisp string manipulation library.
Common Lisp
261
star
2

cl-torrents

Searching torrents on popular trackers - CLI, readline, GUI, web client. Tutorial and binaries (issue tracker on https://gitlab.com/vindarel/cl-torrents/)
Common Lisp
89
star
3

cl-cookieproject

Generate a ready-to-use Common Lisp project
Common Lisp
48
star
4

cl-readline

Common Lisp bindings to the GNU Readline library
Common Lisp
37
star
5

lisp-maintainers

Common Lisp developers you can support.
34
star
6

awesome-no-js-web-frameworks

Isomorphic web frameworks solving the JavaScript Problem.
33
star
7

replic

Build a terminal application in no time from an existing library.
Common Lisp
29
star
8

curated-awesome-cl

A curated and non exhaustive list of Common Lisp libraries and resources.
28
star
9

cl-cookieweb

Cookiecutter template to start a web project.
Common Lisp
27
star
10

lisp-web-template-productlist

A web template with Hunchentoot, Easy-routes, Djula templates, Bulma CSS.
Common Lisp
25
star
11

cl-ansi-term

Colorized output on ANSI terminals and more
Common Lisp
24
star
12

demo-web-live-reload

Stating the obvious: using the REPL to live-reload a running website
Common Lisp
23
star
13

ABStock

Your catalogue of books and other products.
Common Lisp
23
star
14

colisper

Check and transform Lisp code with Comby (beta)
Emacs Lisp
21
star
15

common-lisp-course-in-videos

Learn Lisp effectively and become a happy programmer :)
Common Lisp
21
star
16

fuzzy-match

Fuzzy match candidates from an input string.
Common Lisp
19
star
17

print-licenses

Print licenses used by the given project and its dependencies.
Common Lisp
19
star
18

redbaron4emacs

Python code manipulation for text edition in emacs. With RedBaron's full syntax tree. MIrror of https://gitlab.com/vindarel/redbaron4emacs
Emacs Lisp
15
star
19

cl-sendgrid

Send emails with SendGrid's API
Common Lisp
14
star
20

abelujo

Free software for bookstores. http://www.abelujo.cc/ Mirror (out of sync) of https://gitlab.com/vindarel/abelujo
Python
13
star
21

cl-readline-example

Using readline in Common Lisp.
Common Lisp
12
star
22

indent-tools

(mirror) Emacs mode to indent, navigate around and act on indentation units: perfect for yaml, python and the like.
Emacs Lisp
11
star
23

list-of-languages-implemented-in-lisp

List of languages that were implemented in a dialect of Lisp, to your surprise !
11
star
24

nyxt-init.lisp

My Next browser init file
Common Lisp
10
star
25

shelisp

Mixing shell and lisp on the Lisp repl for easier everyday life
Common Lisp
9
star
26

ltk-tests

Trying out Tk GUIs in CL
Tcl
9
star
27

progressons

A progress bar.
Common Lisp
9
star
28

lem-init

My Lem editor's musings
Common Lisp
6
star
29

format-colors

(format t "~/blue/ :)" "Hello")
Common Lisp
5
star
30

open-nic

Use open-nic DNS right now
Python
5
star
31

termp

Trivial utility: are we in a terminal window or in a dumb one? (like Emacs' Slime)
Common Lisp
5
star
32

cl-torrents-web

self-contained, dynamic web app to search for torrents on popular trackers.
Common Lisp
5
star
33

lyrics-cli

Search lyrics, or songs (terminal interface)
Common Lisp
4
star
34

demo-ISSR-djula

Interactive web app with ISSR and without JavaScript (working POC)
Common Lisp
3
star
35

bookshops

Search for books, CDs and DVDs on real bookshops' websites. Mirror of https://gitlab.com/vindarel/bookshops/ (sometimes out of sync)
Python
3
star
36

getpid

Trivial and portable snippet to get (and save) the PID of the current Lisp image.
Common Lisp
3
star
37

gulp-rapyd

Compile RapydScript files
JavaScript
2
star
38

lisp-journey

Discovering the Common Lisp ecosystem. https://lisp-journey.gitlab.io/
Common Lisp
2
star
39

slime-load-this-project

M-x slime-load-this-project: find the .asd and load the system.
Emacs Lisp
2
star
40

pipelines-viewer

View the last Gitlab pipelines and their status from the command line (or the REPL). (not much to see, it's a 20 min script)
Common Lisp
2
star
41

lftp-wrapper

lftp wrapper, sftp client for Common Lisp
Common Lisp
2
star
42

lish-init

Playing with the Lish shell ! https://github.com/nibbula/lish
Common Lisp
1
star
43

cl-ghub

Minuscule Github api v3 client for Common Lisp
Common Lisp
1
star
44

minibookshop

Web app to search for books and manage their stock. https://gitlab.com/vindarel/minibookshop
Common Lisp
1
star
45

syp

Sync your packages with your dotfiles (and vice versa).
Python
1
star
46

git-commit-insert-issue

(mirror) Get and reference an issue in a commit message. Github, Gitlab, Bitbucket.
Emacs Lisp
1
star
47

cl-gitlab

Common Lisp interface to Gitlab's api - mirror of https://gitlab.com/vindarel/cl-gitlab (staling repository, I don't use it)
Common Lisp
1
star