3 ms·
The closest thing I can think of would be Lisp (any dialect) because of the ability to add embedded languages/DSLs to the language. Pure Common Lisp (no macros)
by malisper 12y ago
The closest thing I can think of would be Lisp (any dialect) because of the ability to add embedded languages/DSLs to the language. Pure Common Lisp (no macros), does not have any iteration constructs (besides goto). On top of these basic primitives you could build something much more complicated such as the 'loop' macro, a DSL for describing iteration. Here is the second problem on project euler (sum of even Fibonacci numbers up to 4,000,000) solved using loop.
(loop for n = 1 then (+ n n-1)
and n-1 = 0 then n
while (<= n 4000000)
if (evenp n) ; predicates in CL end in 'p'
sum n)
You can add almost any (AFAIK any) paradigm you want. Initially Lisp did not have any object system. When OOP became a thing it was added to Lisp. Today it exists in the form of CLOS, a very powerful object system which at its core is two macros, defclass[0] and defmethod[1]. Logic programming can also be added through the use of macros[2]. Here is an example of append written using logic programming in Lisp (compare it to the Prolog version).
(<- (append nil ?xs ?xs))
(<- (append (?x . ?xs) ?ys (?x . ?zs))
(append ?xs ?ys ?zs)
The thing is you can make Lisp any language you want it to be. Want a (better) language to write HTML, you can do that[3]. Want a language which can parse ATNs (augmented transition networks), you can do that[2]. You can add to Lisp almost any feature you can think of. This is what makes it appear (at least to me) as the "universal language".
[0] http://www.gigamonkeys.com/book/object-reorientation-classes.html http://www.gigamonkeys.com/book/object-reorientation-classes...
[1] http://www.gigamonkeys.com/book/object-reorientation-generic-functions.html http://www.gigamonkeys.com/book/object-reorientation-generic...
[2] http://ep.yimg.com/ty/cdn/paulgraham/onlisp.pdf http://ep.yimg.com/ty/cdn/paulgraham/onlisp.pdf
[3] http://allegroserve.sourceforge.net/aserve-dist/doc/htmlgen.html http://allegroserve.sourceforge.net/aserve-dist/doc/htmlgen....