Archive for February 16, 2013

Saturday, February 16, 2013

ReactiveCocoa Explanation

Josh Abernathy:

Because we treat all the inputs to our app as different things—a touch event here, a web response there—we can’t combine them in any meaningful way. We can’t transform them uniformly. And so our only tool for dealing with all these different things is state. When our only tool is state, every problem looks like a stateful nail.

But happily this perspective of our app’s output as a function of its inputs over time gives us a new tool: functional reactive programming. Functional reactive programming (FRP) is a paradigm built around the idea of time-varying values produced by time-varying functions.

He also has a basic example of what this looks like in Objective-C. I have not had a chance to look into ReactiveCocoa deeply yet, but from what I’ve seen so far it looks very exciting. It looks like what Cocoa Bindings should have been, designed to scale up from the easy cases to the harder ones, and taking full advantage of blocks.

Update (2013-02-18): Mattt Thompson:

Bindings replace a lot of boilerplate glue code and allow programming to be done in Interface Builder, but they’re severely limited and impossible to debug. RAC offers a clear, understandable, and extensible code-based API that works in iOS and is apt to replace all but the most trivial uses of bindings in your OS X application.

RXCollections

Rob Rix’s RXCollections offers:

Folds, maps, filters, and detects for Cocoa collections (including your own), with as little chaff as possible.

The interesting part is that:

Maps and filters take a second argument, a collection into which to place their results. This can be a set or an array currently, and if you pass nil, RXMap and RXFilter will build a collection of the same type as the collection being mapped or filtered.

And they can work with custom collection types that conform to the proper protocol.

Markdown.css

Markdown.css is a stylesheet that converts HTML to Markdown (via Mark Christian).

Update (2017-01-03): See also: Hacker News.

Cocoa to HTML

Intel:

The Intel® HTML5 App Porter Tool - BETA is an application that helps mobile application developers to port native iOS code into HTML5, by automatically translating portions of the original code into HTML5.

Via Brent Simmons, who says:

I don’t know why.