{"id":50965893,"url":"https://github.com/hanez/fun","last_synced_at":"2026-06-18T20:31:36.376Z","repository":{"id":316890941,"uuid":"1065189066","full_name":"hanez/fun","owner":"hanez","description":" The programming language that makes you have fun! (mirror from: https://git.xw3.org/fun/fun) ","archived":false,"fork":false,"pushed_at":"2026-06-12T16:45:26.000Z","size":2162,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T18:25:41.187Z","etag":null,"topics":["fun","interpreter","language","programming"],"latest_commit_sha":null,"homepage":"https://fun-lang.xyz","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanez.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-27T08:17:04.000Z","updated_at":"2026-06-12T16:45:31.000Z","dependencies_parsed_at":"2025-09-27T12:19:54.620Z","dependency_job_id":"0dd0b33a-eae3-433c-aabe-b299bab0092b","html_url":"https://github.com/hanez/fun","commit_stats":null,"previous_names":["hanez/fun"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/hanez/fun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanez%2Ffun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanez%2Ffun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanez%2Ffun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanez%2Ffun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanez","download_url":"https://codeload.github.com/hanez/fun/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanez%2Ffun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34507154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-18T02:00:06.871Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fun","interpreter","language","programming"],"created_at":"2026-06-18T20:31:35.529Z","updated_at":"2026-06-18T20:31:36.370Z","avatar_url":"https://github.com/hanez.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fun ([https://fun-lang.xyz](https://fun-lang.xyz))\n\n## What is Fun?\n\nFun is a small, strict, and simple programming language that runs on a compact stack-based virtual machine. The C core is intentionally minimal; most functionality and standard libraries are implemented in Fun itself.\n\nFun is dynamically typed with optional static type annotations, featuring first-class functions, classes with inheritance, pattern matching, and a rich standard library. It supports everything from basic scripting to TCP sockets, serial communication, threading, cryptography (MD5, SHA-1/256/384/512, CRC-32, AES-256), and a built-in debugger.\n\nFun is an experiment \u0026mdash; just for fun \u0026mdash; but Fun works!\n\nInfluenced by **[Bash](https://www.gnu.org/software/bash/)**, **[C](https://en.wikipedia.org/wiki/The_C_Programming_Language)**, **[Lua](https://www.lua.org/)**, PHP, **[Python](https://www.python.org/)**, and **[Rust](https://www.rust-lang.org/)**.\n\nFun is and will ever be 100% free under the terms of the [Apache-2.0 License](https://opensource.org/license/apache-2-0).\n\n## Idea\n\n- Simplicity\n- Consistency\n- Simple to extend\n- Hackable\n- Joy in coding\n- Fun!\n\n## Characteristics\n\n- **Dynamic typing** with optional **static type annotations** (`number`, `string`, `boolean`, `float`, `byte`, `uint8`\u0026ndash;`uint64`, `int8`\u0026ndash;`int64`)\n- **Stack-based bytecode VM** written in C99 with ~220 opcodes\n- **First-class functions**, anonymous functions (`fn`), and higher-order operations (`map`, `filter`, `reduce`)\n- **Classes** with constructors, methods, and single inheritance\n- **Exception handling** with `try`/`catch`/`finally`\n- **Built-in data structures**: arrays (with slicing), maps/objects, strings\n- **Concurrency**: threads (`thread_spawn`, `thread_join`) and cooperative async scheduler\n- **Networking**: TCP and Unix domain sockets with non-blocking I/O polling\n- **Serial communication**: full termios-based serial port control\n- **Cryptography**: pure-Fun implementations of MD5, SHA-1/256/384/512, CRC-32/CRC-32C, AES-256 ECB\n- **Built-in debugger** with breakpoints, step/next/finish, and stack inspection\n- **Minimal C core** \u0026mdash; most standard libraries are implemented in Fun itself\n- **Internal style**: `snake_case` for functions and variables, `CamelCase` for class names\n\n## The Fun Manifesto\n\nFun is a programming language built on a simple idea:\nCoding should be enjoyable, elegant, and consistent.\n\n### Philosophy\n\n- **Fun is Fun**\u003cbr\u003e\n  Programming should spark creativity, not frustration. Code in Fun feels light, playful, and rewarding.\n- **Fun Uses Nothing**\u003cbr\u003e\n  Minimalism is power. No unnecessary features, no endless syntax variations, no formatting debates. Just clean, uniform code.\n- **Indentation is Truth**\u003cbr\u003e\n  Two spaces, always. No tabs, no four-space wars. Code should look the same everywhere, from your laptop to /usr/bin/fun.\n- **One Way to Do It**\u003cbr\u003e\n  No clutter, no 15 ways of writing the same thing. Simplicity means clarity.\n- **Hackable by Nature**\u003cbr\u003e\n  Fun should be small and embeddable, like Lua. Easy to understand, extend, and tinker with \u0026mdash; true to the hacker spirit.\n- **Beautiful Defaults**\u003cbr\u003e\n  A language that doesn't need linters, formatters, or style guides. Beauty is built in.\n\n## The Community\n\nFun is not about being the fastest or the most feature-rich. It's about sharing joy in coding. The community should be:\n\n- Respectful\n- Curious\n- Creative\n- Open for everyone\n\nLike the name says: Fun Unites Nerds.\n\nPlease visit the [Fun Community Page](https://fun-lang.xyz/community/) to get in touch.\n\n## The Goal\n\nA language that feels like home for developers who:\n\n- Love minimal, elegant tools\n- Believe consistency is freedom\n- Want to write code that looks good and feels good\n\nFun may not change the world \u0026mdash; but it will make programming a little more fun.\n\n## Language Features\n\n### Core Syntax \u0026 Types\n\n- Indentation-based blocks (2-space), line and block comments\n- Static type annotations with automatic runtime range clamping for fixed-width integers\n- `typeof()`, `to_string()`, `to_number()`, `cast()` \u0026mdash; type introspection and conversion\n- `exit` statement with optional exit code, `#include` for source includes\n\n### Operators\n\n- Arithmetic: `+`, `-`, `*`, `/`, `%`\n- Comparison: `\u003c`, `\u003c=`, `\u003e`, `\u003e=`, `==`, `!=`\n- Logical: `\u0026\u0026`, `||`, `!` (short-circuit)\n- Bitwise: `band()`, `bor()`, `bxor()`, `bnot()`, `shl()`, `shr()`, `rol()`, `ror()`\n- Ternary: `condition ? true_expr : false_expr`\n\n### Control Flow\n\n- `if` / `else if` / `else`\n- `while` with `break` and `continue`\n- `for var in array` \u0026mdash; iteration\n- `for var in range(start, end)` \u0026mdash; numeric range\n- `for (key, value) in map` \u0026mdash; map destructuring\n- `match` expression (stdlib)\n- `try` / `catch` / `finally`\n\n### Functions\n\n- `fun name(params) body` \u0026mdash; named functions\n- `fn(params) body` \u0026mdash; anonymous function literals\n- First-class: pass as arguments, store in variables, recursion\n- `return` with optional value (implicit nil)\n\n### Object-Oriented Programming\n\n- `class Name(typed params) body` with `_construct(this, ...)` auto-invoked constructor\n- `this` keyword, `obj.method(args)` method call sugar, `obj.field` dot property access\n- `class Child(...) extends Parent` with method overriding\n\n### Data Structures\n\n- **Arrays**: literal `[1, 2, 3]`, index `arr[0]`, slice `arr[1:3]`, negative indices; `len()`, `push()`, `pop()`, `insert()`, `remove()`, `contains()`, `indexOf()`, `clear()`, `enumerate()`, `zip()`, `join()`, `map()`, `filter()`, `reduce()`\n- **Maps**: literal `{key: value}`, bracket `map[\"key\"]`, dot `map.key` access; `has()`, `keys()`, `values()`\n- **Strings**: concatenation with `+`, `len()`, `substr()`, `find()`, `split()`, `join()`\n\n### Mathematics\n\n- Built-in: `abs`, `min`, `max`, `fmin`, `fmax`, `clamp`, `pow`, `sqrt`, `floor`, `ceil`, `trunc`, `round`, `sin`, `cos`, `tan`, `exp`, `log`, `log10`, `gcd`, `lcm`, `isqrt`, `sign`\n- Random: `random_seed()`, `random_int()`, `random_number()` (cryptographic)\n- Integer clamping: `sclamp()`, `uclamp()`\n\n### I/O \u0026 Platform\n\n- `print()`, `echo()` \u0026mdash; output\n- `read_file()`, `write_file()` \u0026mdash; file I/O\n- `input_line()` \u0026mdash; stdin with optional prompt\n- `env()`, `env_all()` \u0026mdash; environment variables\n- `proc_run()`, `system()` \u0026mdash; process execution\n- `os_list_dir()` \u0026mdash; directory listing\n- `time_now_ms()`, `clock_mono_ms()`, `date_format()`, `sleep()`\n\n### Networking (Built-in, Unix)\n\n- TCP: listen, accept, connect, send, recv, close\n- Unix domain sockets: listen, connect\n- Non-blocking I/O: `fd_set_nonblock()`, `fd_poll_read()`, `fd_poll_write()`\n\n### Serial Communication (Unix)\n\n- `serial_open()`, `serial_config()`, `serial_send()`, `serial_recv()`, `serial_close()`\n\n### Concurrency\n\n- `thread_spawn(fn, args)` returns thread ID; `thread_join(id)` returns result\n- Cooperative async scheduler in stdlib\n\n### Debugging \u0026 Tooling\n\n- Built-in debugger with 64 breakpoints, step/next/finish/continue\n- `--trace` / `-t` for opcode-level execution tracing\n- `--repl-on-error`: enter REPL on runtime error with stack preserved\n- Full-featured REPL with history, tab completion, multi-line input, commands (`:help`, `:load`, `:edit`, `:save`, `:debug`, `:trace`, `:type`, and more)\n- `funstx` \u0026mdash; syntax checker with optional `--fix` mode\n\n## Standard Library (lib/)\n\nWritten primarily in Fun itself:\n\n- **Strings**: trim, starts/ends-with, split, replace-all, case conversion, repeat\n- **Arrays**: slice, reverse, concat, unique, flatten\n- **Math**: `abs`, `clamp`, `gcd`, `lcm`, `powi`, min3, max3, array min/max\n- **Encoding**: hex encode/decode, base64 encode/decode\n- **Cryptography** (pure Fun): MD5, SHA-1, SHA-256, SHA-384, SHA-512, CRC-32, CRC-32C, AES-256 ECB\n- **Functional**: Option (Some/None), Result (Ok/Err), pattern matching\n- **Ranges**: `range(n)`, `range2(start, end)`, `range3(start, end, step)`\n- **Date/Time**: `DateTime` class with formatting, timers, sleep\n- **CLI**: `argv()`, `parse_args()` with flag support\n- **Console**: `Console` class with prompt, ask, hidden input, progress bar\n- **Thread**: `Thread` class, **Process**: `Process` class\n- **Socket classes**: `TcpClient`, `TcpServer`, `UnixClient`\n- **Serial**: `Serial` class\n- **Async**: Cooperative scheduler with I/O polling\n- **HTTP**: Static file server, CGI-capable server\n- **IRC**: `IRCClient` with full protocol support\n- **CGI**: `CGI` class for web applications\n\n## Optional Extensions (Build-time)\n\nEnabled via CMake flags, wrapping mature C libraries:\n\n| Extension                                                     | Backend     |\n|---------------------------------------------------------------|-------------|\n| [JSON](./web/documentation/extensions/json/json.md)           | json-c      |\n| [cURL](./web/documentation/extensions/curl/curl.md)           | libcurl     |\n| [SQLite](./web/documentation/extensions/sqlite/sqlite.md)     | libsqlite3  |\n| [PCRE2](./web/documentation/extensions/pcre2/pcre2.md)        | libpcre2    |\n| [OpenSSL](./web/documentation/extensions/openssl/openssl.md)  | libcrypto   |\n| [INI](./web/documentation/extensions/ini/ini.md)              | iniparser   |\n| [XML](./web/documentation/extensions/xml2/xml2.md)            | libxml2     |\n| [PC/SC](./web/documentation/extensions/pcsc/pcsc.md)          | libpcsclite |\n| [KCGI](./web/documentation/extensions/kcgi/kcgi.md)           | libkcgi     |\n| [Redis/Valkey](./web/documentation/extensions/redis/redis.md) | hiredis     |\n\nSome extensions also have a corresponding stdlib wrapper class (e.g., `JSON`, `INI`, `XML`, `PCSC`, `PCRE2`, `KCGI`).\n\n## Quick start\n\n\u003cpre\u003e$ git clone https://git.xw3.org/fun/fun.git\n$ cd fun\n$ cmake -B build -DCMAKE_BUILD_TYPE=Release\n$ cmake --build build --target fun\n$ ./build/fun\nfun\u003e print(\"Hello, World!\")\nHello, World!\nfun\u003e :quit\u003c/pre\u003e\n\n## Build Options\n\n- **`-DCMAKE_BUILD_TYPE=Debug`** \u0026mdash; debug build with asserts\n- **`-DCMAKE_BUILD_TYPE=Release`** \u0026mdash; optimized build with LTO and stripping\n- **`-DFUN_BUILD_MUSL=ON`** \u0026mdash; static musl build\n- Toggle each extension: `-DFUN_WITH_JSON=ON`, `-DFUN_WITH_CURL=ON`, etc.\n- **`-DFUN_BUILD_DOXYGEN=ON`** \u0026mdash; API reference\n\n## Documentation\n\n- Handbook: [./web/documentation/handbook/handbook.md](./web/documentation/handbook/handbook.md)\n- Types: [./web/documentation/types/types.md](./web/documentation/types/types.md)\n- REPL: [./web/documentation/repl/repl.md](./web/documentation/repl/repl.md)\n- Testing: [./web/documentation/testing/testing.md](./web/documentation/testing/testing.md)\n- Spec: [./web/documentation/spec/v0.4.md](./web/documentation/spec/v0.4.md)\n- Changelog: [CHANGELOG.md](./CHANGELOG.md)\n- Examples: [./examples/features.fun](./examples/features.fun)\n\n## Author\n\nJohannes Findeisen - \u003cyou@hanez.org\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanez%2Ffun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanez%2Ffun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanez%2Ffun/lists"}