FUN is a simple, structured, imperative, dynamic, object-oriented, functional and high-level programming language with JIT compilation, garbage collection and Perl-compatible regular expressions. Wisdom ZHANG built it in 2010 as a scripting language to reuse Pascal resources. FUN grew out of the Nuva language (2006), which in turn evolved from TemplateScript (2005). FUN has run in production for years. Its language lineage underpins commercial software used by customers in more than 130 countries, including Fortune 500 companies such as Microsoft, Intel and IBM, as well as high-end hotels and Michelin- and Black Pearl-rated restaurants.
fun say() ?. 'Hello, fun!'; end fun; say(); // prints: Hello, fun! var f = a -> a * 2; // lambda / anonymous function ?. f(21); // prints: 42
fun.exe of only about
300 KB, with no external dependencies.For a detailed tour of the language, read the overview, the manual and the feature highlights.
var f = a -> a * 2; var g = a -> a + 3; ?. g(f(1+2)+3); // prints: 12 ?. 1+2|f+3|g; // prints: 12
class Number(me) this['#'] = you -> (me + you) * me * you; end class; var $ = Number(2); ?. $ .# 3; // custom operator # ?. $[1](3); // method access via index
use 'lib-jit.fun'; var ii = 0; fun cb(a, b) ii = a * 2^32 + b; ?, 'cb'; ?. ii; result = ii; end fun; var s = `#!asm i:i mov ecx, dword ptr [esp+04] @sum1ton push eax push edx mov eax, <test> call eax `; var jit = NewJit(s, names: [test: cb.@toCallback(nil, 'ii:i', true)]); ?. jit.Run(100000000); jit.Delete(); ?. 'Ok';
fun-install.bat inside the folder to register the .fun file association..fun script to run it with fun.exe, or launch the bundled IDE. Open one of the examples to get started.The latest release of the FUN runtime library is 9.0 (contains the IDE):
The runtime itself (fun.exe) is only about 300 KB; the zip adds the IDE and 40+ demos.
Forty-plus runnable .fun samples ship with the runtime, covering functions, classes, closures,
regex, JSON, WinAPI/WinOLE, and more:
Read the HTML version of the FUN man pages and the Chinese manual, overview or syntax (EBNF) / fun.ebnf.
The author has written 100+ technical essays over more than a decade, covering the FUN language, self-taught programming, AI experiments and more:
Machine-readable content for large language models and generative AI engines: llms.txt / llms-full.txt / sitemap / robots.txt.
To report a problem with the FUN runtime library, or to make a feature request, please contact us. Language facts & tags: dynamic typingobject-orientedfunctional JITGCregex