GithubHelp home page GithubHelp logo

isabella232 / sinkline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facebookarchive/sinkline

0.0 0.0 0.0 38 KB

Sinkline is a C++ library which makes it easy to compose callbacks together and write them using a declarative style.

License: MIT License

Python 5.13% Objective-C 7.68% Objective-C++ 11.18% Shell 1.37% C++ 73.61% C 1.02%

sinkline's Introduction

Sinkline Build Status

Sinkline is a C++14 library for structuring callbacks in a declarative, composable way, inspired by functional reactive programming (FRP), Reactive Extensions (Rx), and ReactiveCocoa (RAC).

Sinkline’s fundamental unit of abstraction is the sink. Sinks are used just like normal callbacks (e.g., lambdas or functions), but can be inspected and composed in interesting ways, using functional primitives like map and filter.

Design goals

Sinkline is designed with the following goals in mind, in no particular order.

Although it is sometimes impossible to satisfy all of these goals at once, the principles underlying the goals are the most important, and all changes to the library should be made with them in mind.

Easy to get started

It should be easy to “get your feet wet” with Sinkline, and start using it immediately without having to read a bunch of accompanying documentation or literature.

This means that the library should be accessible and offer incremental benefits. It should be possible to start using it within an existing codebase—even within just one function—and see some benefit.

Easy to reason about

One of the problems with Observables in Rx (and SignalProducers in ReactiveCocoa) is that they make it very difficult to reason about effects. Does subscribing to an Observable start work each time, just once, or never? Are values buffered, multicasted, or neither?

Unfortunately, it is very difficult for any library to definitively answer those questions. Instead, Sinkline should be a transparent abstraction that doesn't make it harder to reason about the underlying code.

Works transparently with existing code

Existing code should not have to be refactored to “speak in the language” that Sinkline uses.

Instead, the library should offer transparent interoperability with other methods of asynchronous programming. For example, it should be possible to use sinks instead of callbacks without needing to refactor the callback-based APIs.

Abstracts away concurrency and state

Concurrency and state are extremely difficult to manage correctly, so the library should take responsibility for both whenever possible.

Practically, this might mean handling synchronization automatically "behind the scenes," or offering ways to replace stateful variables with functional primitives (e.g. scan instead of a stateful accumulator).

“Zero overhead”

The sink abstractions should not impose a performance penalty.

Although true “zero overhead” abstraction is more-or-less impossible, the library should do as much as possible to eliminate overhead. Ideally, sink-based code should match the performance of imperative equivalents (though not necessarily imperative code that has been extensively optimized by hand).

Getting started

Sinkline uses Buck to build. Once you have installed Buck, you can build the library like so:

buck build //sinkline

To run the tests:

buck test //sinkline

There is also an example iOS application which uses Sinkline. To build and run it in the iOS simulator:

buck install -r //example:GIFList#iphonesimulator-x86_64

GCC instructions

The above instructions assume the Clang compiler. To use GCC instead, you must specify a configuration file:

buck build --config //buildfile.includes=//script/gcc_defs.py

This same --config flag can also be passed to buck test.

License

Sinkline is MIT licensed.

sinkline's People

Contributors

jspahrsummers avatar

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.