English 中文
FUN IDE

FUN - Fun Programming Language

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.

A quick taste

fun say()
  ?. 'Hello, fun!';
end fun;

say();              // prints: Hello, fun!

var f = a -> a * 2;   // lambda / anonymous function
?. f(21);           // prints: 42

Why FUN

For a detailed tour of the language, read the overview, the manual and the feature highlights.

Features in code

Pipeline & function composition

var f = a -> a * 2;
var g = a -> a + 3;
?. g(f(1+2)+3);      // prints: 12
?. 1+2|f+3|g;        // prints: 12

Object-oriented programming & custom operators

class Number(me)
  this['#'] = you -> (me + you) * me * you;
end class;

var $ = Number(2);
?. $ .# 3;      // custom operator #
?. $[1](3);     // method access via index

JIT compilation & low-level interaction

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';

Quick start

  1. Download the latest FUN runtime + IDE (currently 9.0) from the download section.
  2. Unzip the package, then run fun-install.bat inside the folder to register the .fun file association.
  3. Now you can double-click any .fun script to run it with fun.exe, or launch the bundled IDE. Open one of the examples to get started.

Download

The latest release of the FUN runtime library is 9.0 (contains the IDE):

Download fun.zip (~1.1 MB)

The runtime itself (fun.exe) is only about 300 KB; the zip adds the IDE and 40+ demos.

Examples

Forty-plus runnable .fun samples ship with the runtime, covering functions, classes, closures, regex, JSON, WinAPI/WinOLE, and more:

Documentation

Read the HTML version of the FUN man pages and the Chinese manual, overview or syntax (EBNF) / fun.ebnf.

Essays

The author has written 100+ technical essays over more than a decade, covering the FUN language, self-taught programming, AI experiments and more:

Read the essays

For AI

Machine-readable content for large language models and generative AI engines: llms.txt / llms-full.txt / sitemap / robots.txt.

Contact

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