Skip to content

Instantly share code, notes, and snippets.

@wandernauta
Last active December 21, 2015 06:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wandernauta/6261611 to your computer and use it in GitHub Desktop.
Save wandernauta/6261611 to your computer and use it in GitHub Desktop.
Dent: the phaseless programming language

dent

Dent is a compiled, barely functional, phaseless, statically type-inferred, homoiconic and almost syntaxless programming language. It compiles down to LLVM assembly, which is then optimized and compiled into native binaries. Output binaries are statically linked and stripped.

The primary difference between Dent and other programming languages is that, in Dent, there is no syntactic difference between functions executed at compile time (usually known as macro's in other languages) and functions executed at runtime.

Inspired by: Lisp Smalltalk Haskell Python

Syntax

In Dent, everything is a function call, passing blocks as arguments. There are no keywords, just builtin functions (if, def, fun are all just 'normal' functions).

Dent's main syntax is the indent:

fun main
    def x = 4
    
    if x .> 2
        return

Indents delineate blocks, the rest is just sugar. Braces for example also function as indents. An equals sign is shorthand for 'indent until next line'. A period in front of a name means 'infix this': for example, 4 .+ 4 is equal to +(4, 4), and "foo".reverse is equal to reverse("foo").

Parens can be used if needed.

Example 1: fibonacci

fun faculty 1 = 1
fun faculty n = n .* faculty(n .- 1)

Module system

Explicit deps is better than implicit deps. Dent starts out with an almost empty namespace (only fun, if, use etc). The use macro imports at current scope. Using a namespace is recommended. The ns:import function unpacks namespaces (compare static import in Java or import * in Python).

Dope

Package manager for dent. No central registry - assume GitHub if package name is of form foo/bar, assume dent organization on GitHub if just bar. Package description files are valid dent syntax:

package "fizzbuzz"
version "0.1RC3"
author  "Ty Coon"

url "http://example.com"
git hub fizzbuzz

Dope defines package etc, then evals the description file.

Library ideas

ns - namespace utility macro
safe - overwrites unsafe macros with nop
option - option type
list, dict, set, string - collections
iter - lisp like utilities for lists and trees
lang - compile-time cleverness
trace - debugging helpers
native - platform specific dl binding
eval - dent in dent
time - time and date handling functions
assert - compile time and run time ass.
test - testing dsl
math - libm bindings
dope - package decl dsl
detect - find out compile time env
os - abstract file io etc
io - reading lines and such
net - socket api
rex - compile-time regular expressions

struct - basic oop
class - complex oop with inheritance

router - pick callback from dict
future - asynchronous helpers
json, msgpack - native tree serializers
http - http client
xml - expat binding
event - libevent binding with http
zmq - zmq binding
db - abstract database interface
model - abstract orm modeling api
kv - abstract key/value store interface
rpc - abstract remote call interface

bdb mysql pgsql sqlite dbm memcached redis: client implementations in dent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment