Top 1,000 Features Creators Resources Extensions Blog Explorer CSV Download
GitHub icon


< >

Bel is a programming language created in 2019 by Paul Graham.

#1408on PLDB 5Years Old

Example from the web:
; Bel in Bel. 9 October 2019, 9:14 GMT (def no (x) (id x nil)) (def atom (x) (no (id (type x) 'pair))) (def all (f xs) (if (no xs) t (f (car xs)) (all f (cdr xs)) nil)) (def some (f xs) (if (no xs) nil (f (car xs)) xs (some f (cdr xs)))) (def reduce (f xs) (if (no (cdr xs)) (car xs) (f (car xs) (reduce f (cdr xs))))) (def cons args (reduce join args)) (def append args (if (no (cdr args)) (car args) (no (car args)) (apply append (cdr args)) (cons (car (car args)) (apply append (cdr (car args)) (cdr args)))))

Language features

Feature Supported Token Example
Macros โœ“
; A macro is essentially a function that generates code. I would have
; liked the first example of a macro to be something simpler, but fn
; is the one we need first. So I'll introduce macros using a simpler
; macro that isn't part of Bel, then explain fn.
; Here is a very simple macro:
(mac nilwith (x)
  (list 'cons nil x))
Strings โœ“
(\h \e \l \l \o)
; can also be represented as
Booleans โœ“
; The symbol nil represents falsity as well as the empty list.
; The symbol t is the default representation for truth, but any object other than nil also counts as true.
Functions โœ“
(fn (x) (+ x 1))
Expressions โœ“
(+ 1 2)
Streams โœ“
Lists โœ“
; here is a list of a, b, and c:
(a . (b . (c . nil)))
; can be written as
(a b c)
Characters โœ“
; Characters that aren't letters may have longer names. For example the bell character, after which Bel is named, is
hasSymbols โœ“
Pairs โœ“
(foo . bar)
Print() Debugging โœ“ prn
Comments โœ“
; A comment
Line Comments โœ“ ;
; A comment
Semantic Indentation X
Case Insensitive Identifiers X

View source

- Build the next great programming language ยท About ยท Acknowledgements ยท Published by Breck's Lab