2025-10-06 19:51:54 +02:00
# Fun ([https://fun-lang.xyz](https://fun-lang.xyz))
2025-09-11 02:07:59 +02:00
2025-09-30 22:52:12 +02:00
## What is Fun?
2025-09-11 02:07:59 +02:00
2025-09-30 22:52:12 +02:00
Fun is a highly strict programming language, but also highly simple. It looks like Python (My favorite language), but there are differences.
2025-10-08 04:00:26 +02:00
Influenced by * * [Bash ](https://www.gnu.org/software/bash/ )**, * * [C ](https://en.wikipedia.org/wiki/The_C_Programming_Language )**, Go, * * [Lua ](https://www.lua.org/ )**, * * [Python ](https://www.python.org/ )**, and Rust (Most influences came from linked languages).
2025-09-30 22:52:12 +02:00
2025-10-08 04:07:00 +02:00
Fun is and will ever be 100% free under the terms of the [Apache-2.0 License ](https://opensource.org/license/apache-2-0 ).
2025-09-30 22:52:12 +02:00
## Idea
2025-10-02 00:53:51 +02:00
- Simplicity
- Consistency
- Joy in coding
- Fun!
2025-09-30 22:52:12 +02:00
2025-10-09 00:43:17 +02:00
### Extras
2025-11-22 01:27:12 +01:00
- [JSON ](https://www.json.org/ ) support builtin using [json-c ](https://github.com/json-c/json-c ) (optional, planned, maybe write a parser in Fun for stdlib)
2025-11-22 01:28:28 +01:00
- [ODBC ](https://learn.microsoft.com/en-us/sql/odbc/reference/odbc-overview?view=sql-server-ver16 ) support builtin for flexible database connectivity using [unixODBC ](https://www.unixodbc.org/ ) (optional, planned)
2025-11-22 01:27:12 +01:00
- [PC/SC ](https://pcscworkgroup.com/ ) smart card support builtin using [PCSC lite ](https://pcsclite.apdu.fr/ ) (optional, in progress)
2025-10-15 02:01:21 +02:00
- [SQLite ](https://sqlite.org/ ) support builtin (optional, planned)
2025-11-22 01:27:12 +01:00
- [Tk ](https://www.tcl-lang.org/ ) support builtin for GUI application development (optional, planned)
2025-10-09 00:43:17 +02:00
2025-09-30 22:52:12 +02:00
## Characteristics
2025-10-02 00:53:51 +02:00
- Dynamic and optionally statically typed
- Type safety
2025-10-09 00:43:17 +02:00
- Written in C (C99) and Fun
2025-10-08 02:48:55 +02:00
- Internal libs are written with no_camel_case even when written in Fun, except class names
2025-10-02 00:53:51 +02:00
- Only a minimal function set is written in C, and most other core functions and libraries are implemented in Fun
2025-09-30 22:52:12 +02:00
## The Fun Manifesto
Fun is a programming language built on a simple idea:
Coding should be enjoyable, elegant, and consistent.
### Philosophy
- **Fun is Fun**<br>
Programming should spark creativity, not frustration. Code in Fun feels light, playful, and rewarding.
- **Fun Uses Nothing**<br>
Minimalism is power. No unnecessary features, no endless syntax variations, no formatting debates. Just clean, uniform code.
- **Indentation is Truth**<br>
Two spaces, always. No tabs, no four-space wars. Code should look the same everywhere, from your laptop to /usr/bin/fun.
- **One Way to Do It**<br>
No clutter, no 15 ways of writing the same thing. Simplicity means clarity.
- **Hackable by Nature**<br>
Fun should be small and embeddable, like Lua. Easy to understand, extend, and tinker with — true to the hacker spirit.
- **Beautiful Defaults**<br>
A language that doesn’ t need linters, formatters, or style guides. Beauty is built in.
## The Community
Fun is not about being the fastest or the most feature-rich. It’ s about sharing joy in coding. The community should be:
- Respectful
- Curious
- Creative
Like the name says: Fun Unites Nerds.
2025-10-13 00:03:18 +02:00
Please visit the [Fun Community Page ](https://fun-lang.xyz/community/ ) to get in touch.
2025-09-30 22:52:12 +02:00
## The Goal
A language that feels like home for developers who:
- Love minimal, elegant tools
- Believe consistency is freedom
- Want to write code that looks good and feels good
Fun may not change the world — but it will make programming a little more fun.
## Documentation
2025-10-12 23:21:43 +02:00
I am writing documentation only actually, but this is work in progress, since debugging and bug fixing includes this task.
2025-10-13 00:04:45 +02:00
Current documentation is only found in the [Fun Handbook ](https://git.xw3.org/fun/fun/src/branch/main/docs/handbook.md ).
2025-10-12 23:21:43 +02:00
2025-10-13 00:04:45 +02:00
In the [examples/ ](https://git.xw3.org/fun/fun/src/branch/main/examples ) directory should be an example of most Fun features.
2025-10-12 23:21:43 +02:00
A complete API documentation will follow.
2025-09-30 22:52:12 +02:00
## Development
This section is a work in progress... Please excuse the lack of more information. There are daily updates here.
### Rules
- Every commit message must contain the version at the end in the following format (1.2.3)
2025-10-12 23:44:42 +02:00
- Every commit requires a version incrementation in CMakeLists.txt before committing. Documentation updates do not increment the version but must contain the current version in each commit message.
2025-09-30 22:52:12 +02:00
- Version numbering follows "[Semantic Versioning 2.0.0 ](https://semver.org/spec/v2.0.0.html )"
2025-10-02 00:53:51 +02:00
### Development systems
2025-09-30 22:52:12 +02:00
- [GNU ](https://gnu.org/ )/[Linux ](https://kernel.org/ ) ([Arch ](https://archlinux.org/ )/[Artix ](https://artixlinux.org/ ), [Debian ](https://www.debian.org/ )) using [GCC ](https://gcc.gnu.org/ ) and the [GNU C library ](https://www.gnu.org/software/libc/ ) ([glibc ](https://en.wikipedia.org/wiki/Glibc ))
- GNU/Linux ([Alpine ](https://alpinelinux.org/ )) using GCC and the [musl libc ](https://musl.libc.org/ )
- [FreeBSD ](https://www.freebsd.org/ ) using [Clang ](https://clang.llvm.org/ ) and the [BSD libc ](https://en.wikipedia.org/wiki/C_standard_library#BSD_libc )
2025-10-02 23:01:22 +02:00
- [Windows ](https://en.wikipedia.org/wiki/Microsoft_Windows ) using [Cygwin ](https://www.cygwin.com/ ) and GCC.
2025-09-30 22:52:12 +02:00
### Other systems
- [macOS ](https://en.wikipedia.org/wiki/MacOS ), [NetBSD ](https://netbsd.org/ ), [OpenBSD ](https://www.openbsd.org/ ), etc. should fully work, but I don't know. I do not use these systems actually. You wanna try and report?
### To Do
Everything... ;) No, a lot of stuff works already, but only a tiny set of functionality is available in the Fun programming language. It grows from day to day...
### Build Fun
Linux/UNIX only covered here for now.
Clone repository:
2025-10-06 19:51:54 +02:00
```bash
2025-09-30 22:52:12 +02:00
git clone https://git.xw3.org/fun/fun.git
```
Change directory:
2025-10-06 19:51:54 +02:00
```bash
2025-09-30 22:52:12 +02:00
cd fun
```
Build:
2025-10-06 19:51:54 +02:00
```bash
2025-11-25 00:51:48 +01:00
# Note: Every -D flag must be of the form NAME=VALUE (e.g., -DFUN_WITH_REPL=ON)
cmake -S . -B build -DFUN_DEBUG=OFF -DFUN_WITH_PCSC=OFF -DFUN_WITH_REPL=ON -DFUN_WITH_JSON=ON
2025-10-06 20:49:27 +02:00
cmake --build build --target fun
2025-09-30 22:52:12 +02:00
```
2025-11-25 00:51:48 +01:00
CMake options you can toggle (all require NAME=VALUE):
- FUN_DEBUG=ON|OFF — verbose debug logging in the VM (default OFF)
- FUN_WITH_REPL=ON|OFF — enable building the interactive REPL (default ON)
- FUN_WITH_PCSC=ON|OFF — enable PC/SC smart card support (default OFF)
2025-11-25 02:07:16 +01:00
- FUN_WITH_JSON=ON|OFF — enable JSON support via json-c (default OFF)
2025-11-25 00:51:48 +01:00
2025-10-06 19:51:54 +02:00
That's it! For testing it, run:
2025-09-30 22:52:12 +02:00
2025-10-06 19:51:54 +02:00
```bash
2025-10-06 19:53:13 +02:00
FUN_LIB_DIR="$(pwd)/lib" ./build/fun ./demo.fun
2025-09-30 22:52:12 +02:00
```
2025-10-06 19:51:54 +02:00
To see what's going on, run:
```bash
FUN_LIB_DIR="$(pwd)/lib" ./build/fun --trace ./demo.fun
2025-09-30 22:52:12 +02:00
```
2025-10-06 19:51:54 +02:00
To switch into the REPL after an error, run:
```bash
FUN_LIB_DIR="$(pwd)/lib" ./build/fun --repl-on-error --trace ./demo.fun
```
2025-10-08 02:48:55 +02:00
Both --repl-on-error and --trace are optional but can always be combined. To get
2025-10-06 19:51:54 +02:00
more debug information, you need to build Fun with -DFUN_DEBUG=ON.
To directly run the REPL, you have to run:
```bash
FUN_LIB_DIR="$(pwd)/lib" ./build/fun
```
But be sure to build Fun with -DFUN_WITH_REPL=ON.
2025-11-25 00:51:48 +01:00
Tip: If you saw an error like this when configuring with CMake:
CMake Error: Parse error in command line argument: FUN_WITH_JSON
Should be: VAR:type=value
it means a -D flag was passed without a value. Always specify options as -DNAME=VALUE, for example:
-DFUN_WITH_JSON=ON
2025-09-30 23:26:34 +02:00
## Author
2025-10-13 00:03:18 +02:00
Johannes Findeisen <you@hanez .org>