Edit

kc3-lang/kc3

Branch :

  • README.md
  • KC3 v0.2.0-git

    A programming language providing and relying on facts-db.

    KC3 is a programming language with meta-programmation and a graph database embedded into the language. The graph database allows for all definitions in the language and can define special operators in KC3 or in C. With a graph database at its core it aims to be the language for semantic programming, and programming the semantic web. It's really easy to devise a data scheme that will persist and iterate in any order and call KC3 or C functions on it.

    For now there is no object abstraction nor reasoning on facts. Every operation on the database is controlled by C code in the end.

    You can easily convert each KC3 function to a C function. KC3 is both a language and a runtime with powerful, scaling data structures.

    This is a development branch, for the latest release see KC3 v0.1.17.

    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 C11 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).
    • kc3c compiles a cache of source files from stdin with .kc3c suffix.
    • 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.
    • DRM, X11 and Wayland backends are implemented in window/
    • GTK+4 bindings are in progress, you can find them in gtk4/.

    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
    • macppc
    • sparc64

    To install and test KC3 for yourself, you can follow the KC3 Installation Guide.

    Users

    There are now seven 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 which you can launch locally with make test_httpd with all the KC3 releases and documentation.
    • The www.kmx.io website 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.
    • The www.iabsd.fr website same as www.kmx.io.
    • The kmx.io git forge is also self-hosted in KC3 on OpenBSD.
    • site.kmx.io a multi domain fork of www.kmx.io.

    New in this release

    • libkc3

      • Struct update %Module{old | field1: value, field2: value}
      • Added List.map_join() for intermediate template rendering
      • Added List.map_filter() for macro-style mapping and filtering without adding a function frame per iteration
      • removed alloc calls from Callable call eval execution path
      • fixed EOF conditions in the parser
      • marshall facts db as full data structures and not as triples
      • created and used primehash hash function for every hash in libkc3
      • optimized primehash implementations using static xor tables
      • added AVX2 implementation for primehash_u64
    • kc3c

      • kc3c compiles (caches) loading of kc3 files to kc3c files
      • fixed lib files so that Makfile now builds the whole of lib/kc3/0.1
    • IKC3/KC3S

      • report errors with more context
    • EKC3

      • compile and load .ekc3 files from/to .ekc3c
    • Git

      • Use bloom filters when available (look for git commit graph if it exists)
      • Optimize kc3_git_log long requests (from more than a minute for some paths to a few milliseconds)
      • Support ODB cache for git.kmx.io (1024 repos in memory)
    • HTTPd

      • fixed bugs in the HTTP request parser
      • fix mmap of static files
      • range requests support
    • primehash32 and primehash64

      • added new byte rotation and incrementation hashing called PrimeHash. This is not a cryptographic hash, but only a hash table bucket selector. It competes with hashes commonly found in Node.JS and Google Chrome. Once disassembled in godbolt this implementation is even shorter. See our blog post about how we achieved perfect hashing with PrimeHash in git.kmx.io. https://www.kmx.io/blog/introducing-primehash-kc3-symbols-hash-table-perfect-hashing

    Contact

    Please contact us for support on the following channels.

    Mailing lists

    Send a mail to kc3-lang-x+subscribe@lists.mail.kmx.io to join the kc3-lang-x@lists.mail.kmx.io mailing-list.

    This is a public list with a public archive. The mailing list archive is available at https://lists.mail.kmx.io/kc3-lang-x/threads.html .

    Send a mail to kc3-lang+subscribe@lists.mail.kmx.io to join the kc3-lang@lists.mail.kmx.io mailing-list.

    This is a public list with a public archive. The mailing list archive is available at https://lists.mail.kmx.io/kc3-lang/threads.html .

    Discord invite

    Join us on kmx.io Discord server !

    Guides

    Follow the KC3 guides to discover how to use KC3 for your own projects.

    TODO

    • libkc3
      • kc3 to C
      • kc3 to Common Lisp
    • HTTPd
      • OAuth2 / jwt
      • dynamic router
        • def_route(:get, "/user/:id/articles/*slug/edit", UserArticlesController.edit)
    • 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)
      • errors (setjmp, longjmp)
        • ffi ?
          • libdwarf
      • livebook
        • gaussian