Kit: a magical, high performance programming language, designed for game development

Related tags

Miscellaneous kit
Overview

Build Status License: LGPL v3 Discord Chat roadmap on_trello Website URL: https://www.kitlang.org

Kit logo

                       ,  ,
  _,-=._              /|_/|
  `-.}   `=._,.-=-._.,  @ @._,
     `._ _,-.   )      _,.-'
        `    G.Q-^^u`u'

  oooo    oooo   o8o      ,
  `888   .8P'    `V'    ,o8
   888  d8'     oooo  .o888oo
   88888[       `888    888
   888`88b.      888    888
   888  `88b.    888    888 ,
  o888o  o888o  o888o   '888'

Kit is a programming language designed for creating concise, high performance cross-platform applications. Kit compiles to C, so it's highly portable; it can be used in addition to or as an alternative to C, and was designed with game development in mind.

Why you should use Kit in place of:

C/C++ a higher level language
Modern language features: type inference, algebraic data types, pattern matching, explicit function inlining, automatic pointer dereferencing, generics, implicits. Full control over performance: pointers, manual memory management, no GC (unless you introduce it yourself, which is easy!)
A more expressive type system, including traits for polymorphism, and abstract types, which provide custom compile-time behavioral and type checking semantics to existing types with no runtime cost. Metaprogramming via a typed term rewriting system; use rules to transform arbitrary expressions at compile time based on their type information. Create your own interface or DSL.
A sane, easy to use build system. Kit features modules, imports, and standard package structure, plus a simple but powerful build tool: manage your project via a simple YAML configuration file and kit build, kit test, or kit run. (coming soon...) Take advantage of existing C libraries without any wrappers; just include the header and directly use types/functions/variables.
function main() {
    var s: CString = "Hello from Kit!";
    printf("%s\n", s);
}

See more code examples here

Kit is pre-alpha and not all features are fully implemented; see the roadmap on Trello.

License

The Kit compiler is licensed under the GNU Lesser General Public License; see the accompanying LICENSE.md file. This applies to modifications to the compiler source itself; any code you write and compile with Kit is yours to license however you choose.

The Kit standard library (.kit files contained in this repo) is released under the MIT license.

Design goals and philosophy

  • Magic and abstracting away complexity are good! Developers should write the most concise and declarative version of their code, and use syntax transformations to convert it into what a performance-conscious developer would've written by hand.

  • Expose the necessary low-level details to write high performance code, and make it easy to abstract them away without entirely giving up control.

  • Kit provides more compile-time safety than C, but never chooses safety at the expense of ergonomics.

Building from source

The Kit compiler, kitc, is written in Haskell. Building the compiler requires GHC; the easiest path is to install Stack and run:

stack build

This will install all other dependencies locally, including a local GHC binary, and build the compiler.

To run the compiler unit tests:

stack test

To install:

stack install

This will copy the kitc binary to Stack's binary install directory (~/.local/bin on Linux); make sure this directory is part of your executable paths.

You'll also need to set two environment variables:

  • KIT_STD_PATH, pointing to the std directory in the repo
  • KIT_TOOLCHAIN_PATH, pointing to the toolchains directory in the repo

Windows setup

  • Kit is currently known to work with mingw64; anything else is unsupported at this time.

Install from package

Windows

Kit provides a Scoop package. Follow the instructions at scoop.sh to install scoop, then run scoop install 'https://raw.githubusercontent.com/kitlang/kit/dev/.packages/scoop/kitlang-prerelease.json'

macOS

Debian/Ubuntu

  • Setup Bintray's APT key:

(Debian might need to install dirmngr first - sudo apt install dirmngr, and the HTTPS transport for apt - sudo apt install apt-transport-https)

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61

  • Using the command line, add the following to your /etc/apt/sources.list system config file:

For prereleases:

echo "deb https://dl.bintray.com/kitlang/kitlang-prerelease-ubuntu bionic universe" | sudo tee -a /etc/apt/sources.list.d/kitlang-prerelease.list

For stable releases:

echo "deb https://dl.bintray.com/kitlang/kitlang-stable-ubuntu bionic universe" | sudo tee -a /etc/apt/sources.list.d/kitlang-stable.list

Or, add the repository URLs using the "Software Sources" admin UI:

deb https://dl.bintray.com/kitlang/kitlang-prerelease bionic universe

  • Update apt and install:

sudo apt update

sudo apt install kitlang

RedHat/CentOS

  • Run the following to get a generated .repo file:

For prereleases:

wget https://bintray.com/kitlang/kitlang-prerelease-redhat/rpm -O bintray-kitlang-prerelease-redhat.repo

For stable releases:

wget https://bintray.com/kitlang/kitlang-stable-redhat/rpm -O bintray-kitlang-stable-redhat.repo

- or -

  • Copy this text into a 'bintray-kitlang-prerelease-redhat.repo' file on your Linux machine:
#bintraybintray-kitplummer-kitlang-prerelease-redhat - packages by kitplummer from Bintray
[bintraybintray-kitplummer-kitlang-prerelease-redhat]
name=bintray-kitplummer-kitlang-prerelease-redhat
baseurl=https://dl.bintray.com/kitlang/kitlang-prerelease-redhat
gpgcheck=0
repo_gpgcheck=0
enabled=1
  • Then, move the config

sudo mv bintray-kitlang-rpm.repo /etc/yum.repos.d/

  • Update yum with:

sudo yum update

  • Install with yum:

sudo yum install kitlang

Hello world

After building/installing kitc:

  • Create a a new file, "helloworld.kit", and copy the following into it:
function main() {
    printf("%s\n", "Hello from Kit!");
}
  • Run kitc helloworld.kit --run to compile and run your program

Copyright

Copyright (C) 2018 Ben Morris. (See the LICENSE.)

Issues
  • Compiling error with SDL2 on windows

    Compiling error with SDL2 on windows

    Describe the problem. What did you see? What did you expect to see?

    When I tried to compile a simple sdl2 hello-world, the compiler gave me an error.

    kitc HelloWorld.kit --run -I 3rdparty\SDL2\include
    [2019-03-18 12:02:02.2754] ===> parsing and building module graph
    [2019-03-18 12:02:02.3255] ===> processing C includes
    ----------------------------------------
    Error: Parsing C header "build\\include\\__clibs.h" failed: C:/Users/madic/scoop/apps/gcc/current/x86_64-w64-mingw32/include/psdk_inc/intrin-impl.h:835: (column 222) [ERROR]  >>> Syntax Error !
      Syntax error !
      The symbol `)' does not fit here.
    
    [2019-03-18 12:02:03.0012] ERR: compilation failed (1 errors)
    

    If this is a code issue, provide a minimal code example:

    It's just a line of SDL_Init

    include "SDL.h";
    
    function main(){
        SDL_Init(${SDL_INIT_EVERYTHING:Uint32});
    }
    

    Environment

    [2019-03-18 12:11:15.5615] ===> kitc version
    [2019-03-18 12:11:15.5655] DBG: 0.1.0
    [2019-03-18 12:11:15.5685] ===> OS
    [2019-03-18 12:11:15.5715] DBG: mingw32
    [2019-03-18 12:11:15.5755] ===> Source paths
    [2019-03-18 12:11:15.5805] DBG: ["src","C:\\Users\\madic\\scoop\\apps\\kitlang-prerelease\\0.1.0-prerelease-0\\std"]
    [2019-03-18 12:11:15.5855] ===> Standard prelude location
    [2019-03-18 12:11:15.5905] DBG: C:\Users\madic\scoop\apps\kitlang-prerelease\0.1.0-prerelease-0\std\prelude.kit
    [2019-03-18 12:11:15.5965] ===> ** COMPILER **
    [2019-03-18 12:11:15.6005] ===> Toolchain
    [2019-03-18 12:11:15.6035] DBG: C:\Users\madic\scoop\apps\kitlang-prerelease\0.1.0-prerelease-0\toolchains\windows-mingw[2019-03-18 12:11:15.6105] ===> Compiler
    [2019-03-18 12:11:15.6135] DBG: gcc
    gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    [2019-03-18 12:11:15.6546] ===> Include paths
    [2019-03-18 12:11:15.6585] DBG: []
    [2019-03-18 12:11:15.6625] ===> Compiler flags
    [2019-03-18 12:11:15.6655] DBG: ["-D__USE_MINGW_ANSI_STDIO","-std=c99","-pedantic","-O3","-Os","-Wno-missing-braces","-Wno-shift-op-parentheses"]
    [2019-03-18 12:11:15.6735] ===> Linker flags
    [2019-03-18 12:11:15.6765] DBG: ["-std=c99","-pedantic","-O3","-Os","-Wno-missing-braces","-Wno-shift-op-parentheses"]
    
    bug 
    opened by MadIcecream 11
  • helloworld.kit: kitc: Prelude.head: empty list

    helloworld.kit: kitc: Prelude.head: empty list

    • Kit version: v0.1.0 (heads/master-0-g68f4515772c9f333858995270320589a87780056)
    • OS/Platform: Linux

    Describe the problem. What did you see? What did you expect to see?

    codehz-pc :: /tmp/kit » kitc helloworld.kit -I /usr/include [2018-12-20 14:42:58.161347] ===> parsing and building module graph [2018-12-20 14:42:58.184124] ===> processing C includes kitc: Prelude.head: empty list

    If this is a code issue, provide a minimal code example:

    function main() {
        printf("%s\n", "Hello from Kit!");
    }
    
    bug 
    opened by codehz 7
  • Calling functions with trait constraints doesn't seem to work correctly

    Calling functions with trait constraints doesn't seem to work correctly

    • Kit version: 5c1e92607958
    • OS/Platform: Mac

    Describe the problem. What did you see? What did you expect to see?

    This code should (according to https://www.kitlang.org/examples.html#trait-constraints) write "hello" to /tmp/greeting:

    import kit.sys.file;
    
    function greet[W: Writer](w: W) {
        w.write("hello");
    }
    
    function main() {
        var f = File.write("/tmp/greeting");
        greet(f);
    }
    

    It produces a warning when building, but it builds successfully:

    [2018-10-04 13:44:22.247710] ===> compiling main.greet
    [2018-10-04 13:44:22.248143] /usr/bin/cc -Ibuild/include -c build/lib/main/kit_greet.c -o build/obj/main/kit_greet.o -D_GNU_SOURCE -D_BSD_SOURCE -D_DEFAULT_SOURCE '-std=c99' -pedantic -O3 -Os -U__BLOCKS__ -Wno-expansion-to-defined -Wno-gnu-zero-variadic-macro-arguments
    build/lib/main/kit_greet.c:5:30: warning: incompatible pointer types passing 'FILE **' (aka 'struct __sFILE **') to parameter of type 'char *' [-Wincompatible-pointer-types]
        kit_sys_file_File__write(&w);
                                 ^~
    build/include/main.h:85:40: note: passing argument to parameter 'path' here
    FILE * kit_sys_file_File__write(char * path);
                                           ^
    1 warning generated.
    

    After running it:

    % ls -h /tmp/greeting
    ls: /tmp/greeting: No such file or directory
    % ./main 
    % ls -lh /tmp/greeting
    -rw-r--r--  1 kuba  wheel     0B Oct  4 13:57 /tmp/greeting
    

    I had a look at the generated code, see below.

    lib/kit_main.c:

    #include "main.h"
    
    int main()
    {
        {
            FILE * f = kit_sys_file_File__write((char *) "/tmp/greeting");
            main_greet__fac4fab0400c4242(f);
        }
        return 0;
    }
    

    `lib/main/kit_greet.c':

    #include "main.h"
    
    void main_greet__fac4fab0400c4242(FILE * w)
    {
        kit_sys_file_File__write(&w);
    }
    

    And kit_sys_file_File__write (in lib/kit/sys/file/kit_File.c) is the static function that opens the file in the first place - it's done again by main_greet... above.

    `lib/kit/sys/file/kit_File.c':

    // ...
    FILE * kit_sys_file_File__write(char * path)
    {
        return fopen(path, (char *) "w");
    }
    
    //...
    

    After some digging it seems that the presence of the static write function (the same name as the write function in the Write trait) in the File Abstract silences the issue, because if the names differ the code won't compile and we know right away something's fishy:

    % cat ../kitbox/main.kit      
    import kit.sys.file;
    
    trait Blablaber[T] {
        public function blabla(value: T): Void;
    }
    
    implement Blablaber[CString] for File {
        public function blabla(value: CString) {
            fwrite(value, sizeof Char, strlen(value), this);
        }
    }
    
    function greet[B: Blablaber](b: B) {
        b.blabla("hello");
    }
    
    function main() {
        var f = File.write("/tmp/greeting");
        greet(f);
    }
    
    % kitc -s ./std -s ../kitbox main
    [2018-10-04 14:05:24.635907] ===> parsing and building module graph
    [2018-10-04 14:05:24.647979] ===> processing C includes
    [2018-10-04 14:05:24.852206] ===> resolving module types
    [2018-10-04 14:05:24.855792] ===> typing module content
    ----------------------------------------
    Error: ../kitbox/main.kit:14: Field access is not allowed on FILE
    
      @../kitbox/main.kit:14:5-12
          14        b.blabla("hello");
                    ^^^^^^^^
    
    [2018-10-04 14:05:24.865898] ===> total time: 0.230116s
    [2018-10-04 14:05:24.866340] ERR: compilation failed (1 errors)
    

    I tried to narrow the issue down and got lost somewhere around following/unifying types so I decided to leave a report instead, hope it helps.

    opened by jstasiak 7
  • Fix unification of pointer to void and pointer to an unknown type

    Fix unification of pointer to void and pointer to an unknown type

    Previously the code would unconditionally refuse to unify pointer to void with any other pointer. That lead to a test failure on Mac OS:

    tests/Kit/CompilerSpec.hs:52:11:
    1) Kit.Compiler, Successful compile tests, tests/compile-src/std/sys/utils.kit
       expected: Nothing
        but got: Just KitErrors [KitErrors [BasicError "The type of this expression is ambiguous; not enough information to infer a type for type var #153.\n\nTry adding a type annotation: `expression: Type`" (Just @std/kit/sys/utils.kit:16:23-26)]]
    

    The compiler output when called manually:

    $ kitc -s ./std -s ./tests/compile-src/std/sys utils
    [2018-10-03 19:59:42.650042] ===> parsing and building module graph
    [2018-10-03 19:59:42.665697] ===> processing C includes
    [2018-10-03 19:59:43.087041] ===> resolving module types
    [2018-10-03 19:59:43.090047] ===> typing module content
    [2018-10-03 19:59:43.093123] ===> generating intermediate representation
    ----------------------------------------
    Error: ./std/kit/sys/utils.kit:16: The type of this expression is ambiguous; not enough information to infer a type for type var #153.
    
    Try adding a type annotation: `expression: Type`
    
      @./std/kit/sys/utils.kit:16:23-26
          16        gettimeofday(&tv, null);
                                      ^^^^
    
    [2018-10-03 19:59:43.097176] ===> total time: 0.4465s
    [2018-10-03 19:59:43.097729] ERR: compilation failed (1 errors)
    

    The test wasn't failing on Linux, because on Linux gettimeofday is declared like this:

    extern int gettimeofday (struct timeval *__restrict __tv,
        __timezone_ptr_t __tz) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1)));
    

    While on Mac OS gettimeofday is declared as:

    int gettimeofday(struct timeval *restrict, void *restrict);
    

    Since this case is being handled now I let myself remove two no longer necessary Ptr[Void] annotations.

    opened by jstasiak 5
  • Compiling error when using special keyword empty on a heap allocated struct

    Compiling error when using special keyword empty on a heap allocated struct

    • Kit version: v0.1.0
    • OS/Platform: (Linux)

    Describe the problem. What did you see? What did you expect to see?

    build/lib/sobreviver/kit_Chunk.c: In function 'sobreviver_chunk__new':
    build/lib/sobreviver/kit_Chunk.c:7:23: error: expected expression before '{' token 
    (*chunk).blocks = {0};
    

    If this is a code issue, provide a minimal code example:

    struct Chunk
    {
       private var blocks : CArray[Block, 4096];
    
       public static function new(allocator : Box[Allocator]) : Ptr[Chunk]{
         var chunk : Ptr[Chunk] = allocator.alloc(sizeof Chunk);
         chunk.blocks = empty;
         return chunk;
       }
    }
    
    function main(){
    var chunk = Chunk.new();
    }
    
    opened by Gamerfiend 4
  • Handling of imported names clashing

    Handling of imported names clashing

    • Kit version: 828881970de4
    • OS/Platform: Mac

    Let's have a couple of modules:

    % cat src/kitbox/mod1.kit 
    include 'stdio.h';
    
    function hello() {
        printf("Hello from mod1\n");
    }
    
    % cat src/kitbox/mod2.kit
    include 'stdio.h';
    
    function hello() {
        printf("Hello from mod2\n");
    }
    
    % cat src/kitbox.kit 
    include "stdio.h";
    import kitbox.mod1;
    import kitbox.mod2;
    
    function main() {
        hello();
    }
    

    The application, when run, prints:

    Hello from mod1
    

    I'd expect a compilation error here with an instruction to disambiguate. If I understand correctly there's currently no disambiguation mechanism in place. This issue could also affect types, traits and variables.

    As one data point, in C# this would be solved by one of the following (just some proof of concept samples):

    • fully qualifying the reference:
    import kitbox.mod1;
    import kitbox.mod2;
    
    function main() {
        kitbox.mod1.hello();
        kitbox.mod2.hello();
    }
    
    • creating a namespace alias:
    import kitbox.mod1 as mod1;
    import kitbox.mod2 as mod2;
    
    function main() {
        mod1.hello();
        mod2.hello();
    }
    
    • creating a symbol alias (probably not applicable here but I'm mentioning it just in case):
    import kitbox.mod1.hello as mod1_hello;
    import kitbox.mod2.hello as mod2_hello;
    
    function main() {
        mod1_hello();
        mod2_hello();
    }
    

    Regardless of whether it's a good practice or not to have clashing identifiers in different modules - what should happen here? Implementing disambiguation mechanism seems like a fun task but, as with #10, I'd need some assistance to tackle it if it's actually a good idea.

    opened by jstasiak 4
  • Using `match` as an expression

    Using `match` as an expression

    • Kit version: 0.1.0
    • OS/Platform: Mac

    Describe the problem. What did you see? What did you expect to see?

    The docs say that match can be used as an expression. I would like to return the result of a match from a function. I can't figure out how to do so. Returning the match doesn't work -- Kit doesn't like wrapping it in parentheses -- and just leaving the match as the body of the function also does not work.

    If this is a code issue, provide a minimal code example:

    enum Exp {
        IntLit(value: Int);
    }
    
    function toString(e: Exp): CString {
        return (match e {
            IntLit(v) => "hello";
            default => "uh oh";
        });
    }
    
    // OR this
    
    function toString(e: Exp): CString {
        match e {
            IntLit(v) =>= "hello";
            default => "uh oh";
        })
    }
    

    The top toString is a syntax error and the bottom toString generates a function that does not return any value in C:

    char * ast__toString(struct ast__Exp e)
    {
        if (e.__dsc == ast_Exp__IntLit)
        {
            int v = e.__var.variant_IntLit.value;
            (char *) "hello";
        }
        else
        {
            (char *) "uh oh";
        }
    }
    

    Additionally, it doesn't appear as though this would work anyway -- do the string literals live long enough?

    opened by tekknolagi 4
  • Weird bahaviour in the playgound's printf

    Weird bahaviour in the playgound's printf

    Describe the problem. What did you see? What did you expect to see?

    In the playgound.

    I change this line:

        printf("%s, %s!", greeting.firstWord, greeting.secondWord);
    

    to:

        printf("%s, %s %s %s %s %s!", greeting.firstWord, greeting.secondWord);
    

    And it prints:

    Hello, world Hello world (null) (null)!
    

    I would expect either (if it's supposed to cycle)

    Hello, world Hello world Hello world!
    

    Or this

    Hello, world (null) (null) (null) (null)!
    
    opened by tuket 3
  • Error when comparing CString literal to CString variable

    Error when comparing CString literal to CString variable

    • Kit version: 0.1.0
    • OS/Platform: (Windows)

    Describe the problem. What did you see? What did you expect to see?

    When comparing a CString literal to a stored CString variable using the == operator, comparison is false even when value of CString is the same.

    If this is a code issue, provide a minimal code example:

    import kit.map;
    import kit.array;
    
    trait Component{
        function type(): CString;
    }
    
    struct PositionComponent{
        public var x: Int;
        public var y: Int;
        public var z: Int;
    }
    
    implement Component for PositionComponent{
        function type(): CString{
            return "Position";
        }
    }
    
    function main() {
    
        var myMap: Map[CString, Box[Component]] = Map.new(10);
    
        var myPosStruct = struct PositionComponent{
            x: 12,
            y: 12,
            z: 23
        };
    
        var myPosStructBox: Box[Component] = myPosStruct;
        myMap.put(myPosStructBox.type(), myPosStructBox);
    
        var keys = myMap.keys();
    
        printf("myMap has PositionComponent: %s\n", if myMap.exists(myPosStructBox.type()) then "true" else "false");
        printf("myMap has PositionComponent: %s\n", if myMap.exists(keys[0]) then "true" else "false");
        printf("myMap has PositionComponent: %s\n", if myMap.exists("Position") then "true" else "false");
    }
    

    Which outputs:

    myMap has PositionComponent: true
    myMap has PositionComponent: true
    myMap has PositionComponent: false
    

    However all three should be true.

    opened by Gamerfiend 3
  • Empty prelude kill the std, including Types;

    Empty prelude kill the std, including Types;

    • Kit version: git, commit 866ae15;
    • OS/Platform: Linux.

    Describe the problem. What did you see? What did you expect to see?

    Creating an empty prelude file in root of the project overwrite the std.

    If this is a code issue, provide a minimal code example:

    function main() {
    	var zero = 0;
    }
    

    this lead to:

    Error: Sanity check failed: couldn't required trait kit.numeric.Numeric, which should be provided by the standard library; check your kitc installation
    ----------------------------------------
    Error: Sanity check failed: couldn't required trait kit.numeric.Integral, which should be provided by the standard library; check your kitc installation
    ----------------------------------------
    Error: Sanity check failed: couldn't required trait kit.numeric.NumericMixed, which should be provided by the standard library; check your kitc installation
    ----------------------------------------
    Error: Sanity check failed: couldn't required trait kit.iterator.Iterator, which should be provided by the standard library; check your kitc installation
    ----------------------------------------
    Error: Sanity check failed: couldn't required trait kit.iterator.Iterable, which should be provided by the standard library; check your kitc installation
    
    opened by quasioy 2
  • Compiler can't determine memory for nested generics

    Compiler can't determine memory for nested generics

    • Kit version: 0.1.0
    • OS/Platform: (Linux)

    Describe the problem. What did you see? What did you expect to see?

    When using generics, and a tuple in an Array, I get an error.

    [email protected]:~/Documents/Sobreviver$ kitc map --lib
    [2018-10-28 13:57:55.517743] ===> parsing and building module graph
    [2018-10-28 13:57:55.532441] ===> processing C includes
    [2018-10-28 13:57:55.728193] ===> resolving module types
    [2018-10-28 13:57:55.737627] ===> typing module content
    [2018-10-28 13:57:55.772649] ===> generating intermediate representation
    ----------------------------------------
    Error: /usr/lib/kit/kit/array.kit:6: Couldn't find underlying type for type
        param map.Map.K; this is probably an error with monomorph generation!
    
      @/usr/lib/kit/kit/array.kit:6:5-12
           6        var data: Ptr[T];
                    ^^^^^^^^
    

    If this is a code issue, provide a minimal code example:

    Here are the relevant parts of the code:

    struct Map[K, V]
    {
        private var size: Int;
        private var allocator: Box[Allocator];
        private var internalArray : Array[(K, V)];
    
        public static function new(allocator: Box[Allocator]): Map[K, V] using implicit allocator
        {
            var internalArray: Array[(K, V)] = Array.new(10);
            return struct Self
            {
                size: 0,
                allocator,
                internalArray,
            };
    
        }
    
    }
    
    opened by Gamerfiend 2
  • Comparing CArray and CString is accepted as valid code but leads to random results

    Comparing CArray and CString is accepted as valid code but leads to random results

    The compiler accepts comparison between a char CArray and a CString but it is not compiled/executed as a string comparison correctly! (results here are random).

    struct Instr {
        var mnem: CArray[Char, 8]; // mnemonic of op
        var valF: Float32;
    }
    
    // interpret instruction
    function interp(instr: Instr, stack: Ptr[Stack]) {
        if (instr.mnem) == "PUSHCF  " {
            stack.arr[stack.idx++] = instr.valF; // push
            printf("PUSH\n");
        }
        else if instr.mnem == "LININTER" {
            var intr = stack.arr[stack.idx--];
            var b = stack.arr[stack.idx--];
            var a = stack.arr[stack.idx--];
            
            stack.arr[stack.idx++] = a*(1.0-intr) + (b-a)*intr;
            printf("LININTER\n");
        }
    }
    
    opened by PtrMan 0
  • Type inference is not working correctly

    Type inference is not working correctly

    The compiler should infer types correctly and not push type-inference to the backend (C).

    If this is a code issue, provide a minimal code example:

    include "math.h";
    function exp(v:(Float64,Float64)):(Float64,Float64) {
        var r = expf(v[0]);
        var d = 0.0;
        return (r,d);
    }
    

    gives a compile error from the gcc:

    Error: build/lib/kit_test0.c: In Funktion »test0__exp«:
    build/lib/kit_test0.c:19:12: Fehler: unverträgliche Typen bei Rückgabe von Typ »struct tuple2bf0b99cc56f6aa69d896315«, aber »struct tuplee7731a893109b41a186a62ef« wurde erwartet
       19 |     return (struct tuple2bf0b99cc56f6aa69d896315) {.__slot0 = r, .__slot1 = d};
          |            ^
    
    opened by PtrMan 0
  • -vvv is broken and crashes the compiler

    -vvv is broken and crashes the compiler

    I tried to see what the compiler is doing and got a crash trying to compile a simple hello world with kitc -vvv test0.kit

    function main() {
        printf("%s\n", "Hello from Kit!");
    }
    

    Result:

    CallStack (from HasCallStack):
      error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
      undefined, called at src/Kit/Ast/Definitions/EnumVariant.hs:38:24 in kitlang-0.1.0-7uWjdU81ybAH34QXJWKK6w:Kit.Ast.Definitions.EnumVariant
    
    opened by PtrMan 0
  • Multiple definition errors (unguarded generated main.h?)

    Multiple definition errors (unguarded generated main.h?)

    I made a simple file hello.kit file containing:

    function main() {
        printf("%s\n", "Hello from Kit!");
    }
    

    and tried to compile it using kitc hello.kit. At the linking stage I get a bunch of "multiple definition" errors for all kinds of symbols (e.g. kit_mem_Allocator__...). This seems logical, as the generated build/include/main.h file contains these definitions, but it is included in every .c-file and does not contain a header guard or similar. I assume this is not intended behavior, so what could be going wrong on my side?

    Environment

    [2020-08-01 16:26:57.1947] ===> kitc version
    [2020-08-01 16:26:57.2686] DBG: 0.1.0
    [2020-08-01 16:26:57.3465] ===> OS
    [2020-08-01 16:26:57.4413] DBG: mingw32
    [2020-08-01 16:26:57.4813] ===> Source paths
    [2020-08-01 16:26:57.5721] ===> Standard prelude location
    [2020-08-01 16:26:57.6480] DBG: C:\tools\kit\std\prelude.kit
    [2020-08-01 16:26:57.6900] ===> ** COMPILER **
    [2020-08-01 16:26:57.7339] ===> Toolchain
    [2020-08-01 16:26:57.7898] DBG: C:\tools\kit\toolchains\windows-mingw
    [2020-08-01 16:26:57.8433] ===> Compiler
    [2020-08-01 16:26:58.6820] DBG: gcc
    gcc (Rev1, Built by MSYS2 project) 10.2.0
    Copyright (C) 2020 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO 
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    [2020-08-01 16:26:59.4545] ===> Include paths
    [2020-08-01 16:26:59.4745] DBG: []
    [2020-08-01 16:26:59.5274] ===> Compiler flags
    [2020-08-01 16:26:59.5723] DBG: ["-D__USE_MINGW_ANSI_STDIO","-std=c99","-pedantic","-O3","-Os","-Wno-missing-braces","-Wno-shift-op-parentheses"]
    [2020-08-01 16:26:59.7491] ===> Linker flags
    [2020-08-01 16:26:59.7810] DBG: ["-std=c99","-pedantic","-O3","-Os","-Wno-missing-braces","-Wno-shift-op-parentheses"]
    

    I see mingw32 here, not mingw64, is that a problem? I got it from the scoop package, but am using my existing install of gcc-mingw64 via msys2.

    opened by nardi 3
  • Feature request : Freebsd

    Feature request : Freebsd

    It does not compile on Freebsd 12.1. Error : /home/x/_kit/kit-dev x> $stack build Preparing to install GHC (ino64) to an isolated location. This will not interfere with any system-level installation. Downloaded ghc-ino64-8.4.3.
    rts-1.0: Warning: .:464:1: The field "hugs-options" is deprecated. hugs isn't supported anymore Installed GHC.
    Found an invalid compiler at "/usr/home/x/.stack/programs/x86_64-freebsd/ghc-ino64-8.4.3/bin/ghc-8.4.3": Control.Exception.Safe.throwString called with:

    Could not find any of: ["/usr/home/x/.stack/programs/x86_64-freebsd/ghc-ino64-8.4.3/bin/haddock-8.4.3","/usr/home/x/.stack/programs/x86_64-freebsd/ghc-ino64-8.4.3/bin/haddock-ghc-8.4.3","/usr/home/x/.stack/programs/x86_64-freebsd/ghc-ino64-8.4.3/bin/haddock","/usr/home/x/.stack/programs/x86_64-freebsd/ghc-ino64-8.4.3/bin/haddock-ghc"] Called from: throwString (src/Stack/Setup.hs:721:25 in stack-2.1.3.1-inplace:Stack.Setup)

    Used stack version : hs-stack-2.1.3.1 Default ghc: ghc-8.6.5_3

    opened by devosalain 0
Owner
Kit Programming Language
Kit Programming Language
cdk is a minimal cross-platform c language development kit.

Overview cdk is a minimal cross-platform c language development kit. Requirement Based on c11 standard. Compile create a build directory under the cdk

Red 19 Jul 26, 2022
jai programming language starter kit (minimal modules)

jai starter kit modules jai programming language starter kit (minimal modules) Modules List sk_Window : minimal window creation and input module. sk_B

null 4 Jan 20, 2022
jai programming language starter kit (minimal modules)

jai starter kit modules jai programming language starter kit (minimal modules) Modules List sk_Window : minimal window creation and input module. sk_B

null 4 Jan 20, 2022
Internal Software Development Kit for Battlefield 2042

battlefield-2042-internal-sdk Internal Software Development Kit for Battlefield 2042 SDK Includes the following: Entity Classes Player Classes Vehicle

Skengdo 11 Jun 27, 2022
🎮 Cross platform development kit for Z80 and SM83 based consoles.

cdk ?? Cross platform development kit for Z80 and SM83 based consoles. Platform We planned to support the following consoles: Nintendo Game Boy Ninten

Micro Console 4 Jan 10, 2022
bl_mcu_sdk is MCU software development kit provided by Bouffalo Lab Team for BL602/BL604, BL702/BL704/BL706 and other series of RISC-V based chips in the future.

bl mcu sdk is an MCU software development kit provided by the Bouffalo Lab Team for BL602/BL604, BL702/BL704/BL706 and other series of chips in the future

Bouffalo Lab 125 Aug 8, 2022
PLP Project Programming Language | Programming for projects and computer science and research on computer and programming.

PLPv2b PLP Project Programming Language Programming Language for projects and computer science and research on computer and programming. What is PLP L

PLP Language 5 Jun 23, 2022
StarkScript - or the Stark programming language - is a compiled C-based programming language that aims to offer the same usability as that of JavaScript's and TypeScript's

StarkScript StarkScript - or the Stark programming language - is a compiled C-based programming language that aims to offer the same usability as that

EnderCommunity 5 May 10, 2022
An eventing framework for building high performance and high scalability systems in C.

NOTE: THIS PROJECT HAS BEEN DEPRECATED AND IS NO LONGER ACTIVELY MAINTAINED As of 2019-03-08, this project will no longer be maintained and will be ar

Meta Archive 1.7k Aug 8, 2022
cake is a programming language designed to be conventional as well as incredibly fast, natively available on these platforms.

cake The fast crossplatform programming language What's cake? cake is a programming language designed to be conventional as well as incredibly fast, n

Shadoww 4 Mar 6, 2022
A programming language designed to be stack-based and concatenative with reverse polish notation. (Mirror)

VIRNA IS STILL UNDER-DEVELOPMENT. PLEASE USE AT YOUR OWN RISK! Virna A programming language designed to be stack-based and concatenative with reverse

aiocat 9 Jul 14, 2022
Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.

Unix pager (with very rich functionality) designed for work with tables. Designed for PostgreSQL, but MySQL is supported too. Works well with pgcli too. Can be used as CSV or TSV viewer too. It supports searching, selecting rows, columns, or block and export selected area to clipboard.

Pavel Stehule 1.8k Aug 7, 2022
Gunyah is a Type-1 hypervisor designed for strong security, performance and modularity.

Gunyah is a Type-1 hypervisor, meaning that it is independent of any high-level OS kernel, and runs in a higher CPU privilege level. It does not depend on any lower-privileged OS kernel/code for its core functionality. This increases its security and can support a much smaller trusted computing base than a Type-2 hypervisor.

Qualcomm Innovation Center 71 Aug 9, 2022
frost is a programming language with a focus on low-friction systems programming.

❄️ frost frost programming language About frost is a programming language with a focus on low-friction systems programming.

null 4 Nov 12, 2021
The Wren Programming Language. Wren is a small, fast, class-based concurrent scripting language.

Wren is a small, fast, class-based concurrent scripting language Think Smalltalk in a Lua-sized package with a dash of Erlang and wrapped up in a fami

Wren 5.8k Aug 9, 2022
Arduino sample code to help you get started using the Soracom IoT Starter Kit!

Soracom IoT Starter Kit The Soracom IoT Starter Kit includes everything you need to build your first connected device. It includes an Arduino MKR GSM

Soracom Labs 13 Jul 30, 2022
ESP32 Audio Kit based multitrack looper

esp32_multitrack_looper ESP32 Audio Kit based multitrack looper The project can be seen in my video https://youtu.be/PKQmOsJ-g1I The project has been

Marcel 34 Jul 22, 2022
Modo Kit that includes a command for packing UVs, powered by UVPackmaster 2

uvpackit Modo Kit that includes a command for packing UVs, powered by UVPackmaster 2 The included command can be executed with uvp.pack which will ope

null 5 Jul 4, 2022