Hash :
bdbaf8d2
Author :
Thomas de Grivel
Date :
2025-10-12T15:36:41
README.md
KC3 is a programming language with meta-programmation and a graph database embedded into the language. It aims to be the language for semantic programming, and programming the semantic web.
You can easily convert each KC3 function to a C function. KC3 is both a language and a runtime.
This is a development branch, for the latest release see KC3 v0.1.15.
KC3 is currently a programming language project, inspired by C, Elixir and Common Lisp. It could be described as C with Elixir modules, pattern matching, and a semantic object system. The idea is to plug modules, closures, pattern matching, a graph database and metaprogramming into C99 with an extremely small set of dependencies.
Components :
libkc3 library is a full KC3 parser and interpreter. ikc3 is the interactive interpreter (verbose). kc3s is the script interpreter (same as ikc3 but terse). lib/kc3/0.1
using the make lib_links command. kc3_httpd. All binaries can be compiled for four targets :
assert is disabled. assert is enabled Supported operating systems (additional dependencies) :
Supported architectures :
To install and test KC3 for yourself, you can follow the KC3 Installation Guide.
There are now four full applications written in KC3 that we know of :
make demo make demo_gl make test_httpd with all the KC3 releases and
documentation. libkc3
(Facts*) → p_facts (U8*) 0x0 kc3_require and env_eval_do_block more careful about error
handling defcounter name = value Counter.decrease(Ident, Tag) as a cfn_macro, Tag must be a
positive integer (non-zero) Counter.get(Ident) as a cfn_macro Counter.increase(Ident, Tag) as a cfn_macro, Tag must be a
positive integer (non-zero) Counter module included at init libtls
ikc3
RPC.request("input") %RPC.Response{out: "plop\n",
err: "warning: message\n",
result: (Sw) 5}
build system
runj as a git submodule to parallelize configure
and update_sources sort as a git submodule to have a portable sort
algorithm that gives consistent results across Linux and BSD. test infrastructure
runj to call test_runner in parallel sleep 2 that slowed each ikc3 test HTTPd
def* into proper modules window
kpkg - KC3 package manager
while loop Join us on kmx.io Discord server !
Follow the KC3 guides to discover how to use KC3 for your own projects.
(Macro) fn (x) { x } \n) (TAG_VOID: 1, TAG_TUPLE: (1+ (max (height tuple->tags))))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
# KC3 v0.1.16-git
KC3 is a programming language with meta-programmation and a graph
database embedded into the language. It aims to be the language
for semantic programming, and programming the semantic web.
You can easily convert each KC3 function to a C function. KC3 is both
a language and a runtime.
This is a development branch, for the latest release see
[KC3 v0.1.15](https://git.kmx.io/kc3-lang/kc3/_tree/v0.1.15).
KC3 is currently a programming language project, inspired by C, Elixir
and Common Lisp. It could be described as C with Elixir modules,
pattern matching, and a semantic object system. The idea is to plug
modules, closures, pattern matching, a graph database and
metaprogramming into C99 with an extremely small set of dependencies.
Components :
- The pure C11 `libkc3` library is a full KC3 parser and interpreter.
- `ikc3` is the interactive interpreter (verbose).
- `kc3s` is the script interpreter (same as ikc3 but terse).
- There are several C libraries which are installed in `lib/kc3/0.1`
using the `make lib_links` command.
- There is a web server in httpd : `kc3_httpd`.
All binaries can be compiled for four targets :
- __main__ : speed optimizations from GCC/Clang -O2 and
debug code like `assert` is disabled.
- __debug__ : no optimization and debug code like `assert` is enabled
- __cov__ : code coverage instrumentation
- __asan__ : memory safety instrumentation with ASan, an absolutely
awesome tool to detect all memory leaks, double free, segmentation
faults, invalid read, invalid write, general memory corruption
errors, etc., just run the __asan__ target for a full report at
process exit, the report being empty if all is ok.
Supported operating systems (additional dependencies) :
- BSD
- Linux (libbsd, libmd)
- MacOS X (libmd)
- Windows (MSys2) (no network)
Supported architectures :
- aarch64 (arm64, Apple M1, Apple M2)
- amd64
- i386
- sparc64
To install and test KC3 for yourself, you can follow the
[KC3 Installation Guide](https://kc3-lang.org/doc/3_Guides/3.1_Install).
## Users
There are now four full applications written in KC3 that we know of :
- The KC3 Cairo demo which you can run with `make demo`
- The KC3 SDL2 OpenGL demo which you can run with `make demo_gl`
- The [KC3 website](https://kc3-lang.org/) which you can launch
locally with `make test_httpd` with all the KC3 releases and
documentation.
- The [www.kmx.io website](https://www.kmx.io/) which is closed
source and is hosted on kmx.io servers in France using OpenBSD
everywhere. We donate to OpenBSD every month because a healthy
software ecosystem is a funded ecosystem.
## New in this release
- libkc3
- dlopen inside lib/ only
- Typed pointer example : `(Facts*)` → `p_facts`
- Generic typed pointers : `(U8*) 0x0`
- make `kc3_require` and `env_eval_do_block` more careful about error
handling
- securelevel between 0 and 3
- API that can only increase securelevel between 0 and 2
- 0 → (cfn + system + dlopen + dlsym) + eval + def*
- 1 → eval + def*
- 2 → eval
- 3 → ø (no KC3 eval, C-mode only)
- MP-safe integer counters : `defcounter name = value`
- environment hash table for name resolution
- mp-safe
- `Counter.decrease(Ident, Tag)` as a `cfn_macro`, Tag must be a
positive integer (non-zero)
- `Counter.get(Ident)` as a `cfn_macro`
- `Counter.increase(Ident, Tag)` as a `cfn_macro`, Tag must be a
positive integer (non-zero)
- `Counter` module included at init
- libtls
- basic TLS client and server in test/tls/tls.kc3
- ikc3
- Remote procedure call
- client : ikc3 --client HOST PORT
- opens a prompt on stdin and forwards parsed tags to server
using `RPC.request("input")`
- reads structured response from server :
```elixir
%RPC.Response{out: "plop\n",
err: "warning: message\n",
result: (Sw) 5}
```
- server : ikc3 --server HOST PORT
- accepts only one connection and exits
- works with netcat (no prompt)
- TLS with libtls : ikc3 --tls (--client|--server) HOST PORT
- "ikc3: TLS server: listening on HOST PORT"
- "ikc3: TLS server: client connected: HOST PORT TLS-1.3"
- "ikc3: TLS client: connected to HOST PORT TLS-1.3"
- ship ikc3 as a standalone file that links to the right lib directory
on MacOS, this way you can open ikc3 using Finder in a Terminal.app
and the dynamic libraries will still be found
- build system
- use shipped `runj` as a git submodule to parallelize configure
and update_sources
- use shipped `sort` as a git submodule to have a portable sort
algorithm that gives consistent results across Linux and BSD.
- test infrastructure
- modular test infrastructure with test/test.subr and
test/test_runner
- use shipped `runj` to call test_runner in parallel
- removed ugly `sleep 2` that slowed each ikc3 test
- all tests suites run in under 30 seconds now compared to
more than 5 minutes before
- HTTPd
- limit acceptor loop using defcounter
- achieved securelevel(2) after load_app() by moving all
`def*` into proper modules
- window
- demo
- unified all OpenGL demos under window/demo
- SDL2
- OpenGLESv3
- Use [Angle](https://github.com/google/angle) GLESv3
implementation with Metal backend on MacOS. This provides
SDL2 with an EGL/GLESv3 driver on MacOS despite OpenGL support
being dropped by Apple.
- EGL backend
- XCB backend for X11
- VT backend on Linux and OpenBSD using DRM KMS and GBM
- kpkg - KC3 package manager
- Argument parsing as a `while` loop
- Added __libmd__, __libbsd__ and __kc3__ repo definitions
## Discord invite
[Join us on kmx.io Discord server !](https://discord.gg/A4MWkpUDsG)
## [Guides](https://kc3-lang.org/doc/3_Guides)
Follow the [KC3 guides](https://kc3-lang.org/doc/3_Guides)
to discover how to use KC3 for your own projects.
## TODO
- libkc3
- env_init: find lib dir for /usr/local/lib/kc3/0.1/
- HTTPd
- OAuth2 / jwt
- dynamic router
- def_route(:get, "/user/:id/articles/*slug/edit", UserArticlesController.edit)
- tls
- fx
- chaining of audio and video previews (folder as a playlist)
- tags
- create
- POST "/tag/:tag/*path"
- delete
- DELETE "/tag/:tag/*path"
- recursive
- properties
- recursive
- libkc3
- unions
- enums
- hash-table as a KC3 value (map ?)
- special operators hash table
- pass by reference and reference counting in all data structures
- array
- cow
- frame
- list
- map
- base-specific big floats
- macro cast : `(Macro) fn (x) { x }`
- pretty printer
- 80 columns (`\n`)
- tags
- generic walker
- height function `(TAG_VOID: 1, TAG_TUPLE: (1+ (max (height tuple->tags))))`
- has_ident
- collect_idents
- facts
- negative facts : 4 + 2n = not 3 + 2n
- with ignore variables
- math
- arbitrary precision floating point numbers (decimals)
- enums
- unions
- errors (setjmp, longjmp)
- ffi ?
- libdwarf
- control structures
- when
- unless
- switch/case/cond
- livebook
- gaussian
- buf_sha256
- buf_popen
- tests