Git Product home page Git Product logo

doran-dark's Introduction

DaRKSTEP

A NeXTSTEP-like object system entirely in c11 with clang extensions. This is not objective-c, this is c. Instead of method lists, I'm using vtables. Instead of messages, I'm using the selector as a generic function.

clang c11, using extensions:

  • BlocksRuntime
  • attribute((ext_vector_type(n)))
  • attribute((overloadable))
  • attribute((constructor(n)))
  • attribute((cleaup(destructor)))

Why?

'I want a new C' - catchy. Maybe I'll write a song. C is simple. It compiles fast. I didn't like Borland C++ 2.0 when it came out - too 'gimicky'. It's gotten better, but I still think it has a noisy syntax.

This library is adequate for non-critical use. Probably 1/2 the internet runs or did run on hacks that emulate classes in javascript.

"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off" -- Bjarne Stroustrup

testing

cd test
doran update
mkdir build
cd build
make
./unit

example

a port of the breakout game from learnopengl.com

dependancies (windows)

pacman -S mingw-w64-x86_64-libblocksruntime
pacman -S mingw-w64-x86_64-gc

dependancies (linux)

sudo apt install libblocksruntime-dev
sudo apt install libgc-dev

example

#include <dark/Foundation.h>
/**
 * Extend the List class with an iterator
 */
method void ForEach(List* this, void (^iter)(String*))
{
    for (auto curr = this->head; curr != nullptr; curr = curr->next) {
        iter(curr->data);
    }
}

int main(int argc, char **argv) {

    Log("Hello World");
    /**
     * $ wraps primitive values with corresponding Type
     */
    auto pi = $(3.1415f);
    Log("pi = %$", pi);
    Log("typeof(pi) = %s", typeof(pi));

    List* ls = new(List);
    Add(ls, $("first"));
    Add(ls, $("second"));
    ForEach(ls, ^(String* s) {
        Log("item = %d) %$", Length(s), s);
    });

    Log("this string %$", $(20.0f));

    auto s = $Join($("the "), $("answer "), $("is "), $(42));
    Log("%$", s);
    Log(ToString(s));

    return 0;
}

doran-dark's People

Contributors

darkoverlordofdata avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

happy-ferret

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.