This sounds neat, but I want to ask others here as I am not (yet) a Cocoa developer - is all Cocoa code this ugly? In these short examples I honestly can't fathom what is happening due to the syntactic 'oddities'. Maybe my C-variant-fu is not as strong as it should be.
It's not so bad if you give it space to spread out a little. The wrapping in the column makes it much more difficult to follow, especially when used with Xcode's unusual indent style.
I guess the blocks-in-blocks code can get quite unreadable at times. Personally I like to store blocks in variables in such situations and add the variable to a function that required the block parameter. Makes code so much more readable when blocks are nested.
Yeah, we played around with a bunch of different styles, including defining the block before its use. It looked cleaner but the code locality of defining them inline won.
This sounds neat, but I want to ask others here as I am not (yet) a Cocoa developer - is all Cocoa code this ugly?
I am a Cocoa developer, and I have to say that the presentation of this idea on the blog leaves something to be desired. It seems to be oriented towards people already familiar with Reactive Programming and FP, but it doesn't set up that expectation at all. At the same time, it's very confusing and a little unintentionally off-putting for devs who aren't familiar with those notions, even for those who already know Objective-C and KVO.
The problem with Rx / RAC is there's a big learning curve, especially coming from procedural programming. It's much bigger than 1 blog post can cover. My hope at least is that it will drive at least some people to dive deeper.
The Objective-C syntax doesn't look strange to me, yet its verbosity make the whole picture more difficult to grasp than in Ruby in my opinion. It's somehow like difference between a document and a bullet point reppresentation of it.
However, I haven't made my mind yet about RubyMotion. There are some propositions for it and some against and a lot has to come in the next weeks. Let's see what will happen.
Note: I have been coding in Objective-C for two years and in Ruby for 1-2 months.
For those not familiar, it looks like this is the take on ideas from Reactive Extensions (Rx): http://msdn.microsoft.com/en-us/data/gg577609. I'm not sure if Rx itself has a direct predecessor or not, but it's great to see the idea taking hold in other communities. I've long suspected that there is a lot of great stuff in the .Net world that most open-source-oriented programmers never see, simply because they don't have exposure to Microsoft technology.
Here's what Rx is: The idea of a list are some items in an order (a Sequence in FP-speak). On top of a Sequence you can implement all kinds of interesting operations like map/filter/reduce.
If you look at an Event like KeyUp, you'd end up with some items, in a particular order. Thus, you realize, that events and lists really are the same thing. In fact, they're not only ostensibly the same, they are mathematically provable to be the same.
Rx therefore, gives you all the operations you can do to a list, and applies it to an event (or a callback, which is just an event that only happens once).
I've just spent a few hours getting to know ReactiveCocoa better, and what a great framework! Props to GitHub for open sourcing it, and I'm already looking at how to integrate it into some of my apps. I blogged about my first impressions here: http://cleveryou.net/post/22447309056/rac-first-impressions
34 comments
[ 2.5 ms ] story [ 80.7 ms ] threadYeah, it can be ugly, but once you know what's going on it all reads pretty quickly.
At 80-300 characters per line it's fine and very readable.
What
? The
blog is displaying
the text narrow-
er than it shows up in
a source file
. This
makes it
uglier than it is in
actual prac-
tice
My point was, it is hard to print 300 chars wide code. Ideal code width for printing is < 80 chars...
I'm pretty sure I've never printed ObjC
I am a Cocoa developer, and I have to say that the presentation of this idea on the blog leaves something to be desired. It seems to be oriented towards people already familiar with Reactive Programming and FP, but it doesn't set up that expectation at all. At the same time, it's very confusing and a little unintentionally off-putting for devs who aren't familiar with those notions, even for those who already know Objective-C and KVO.
It still might be a good idea, though.
The problem with Rx / RAC is there's a big learning curve, especially coming from procedural programming. It's much bigger than 1 blog post can cover. My hope at least is that it will drive at least some people to dive deeper.
However, I haven't made my mind yet about RubyMotion. There are some propositions for it and some against and a lot has to come in the next weeks. Let's see what will happen.
Note: I have been coding in Objective-C for two years and in Ruby for 1-2 months.
If you look at an Event like KeyUp, you'd end up with some items, in a particular order. Thus, you realize, that events and lists really are the same thing. In fact, they're not only ostensibly the same, they are mathematically provable to be the same.
Rx therefore, gives you all the operations you can do to a list, and applies it to an event (or a callback, which is just an event that only happens once).
If anyone wants a simple introduction to Rx, Paul Betts (and Jesse Liberty) wrote one last year.
http://www.amazon.com/Programming-Reactive-Extensions-Jesse-...
Edit: it appears that the MS Reactive Extensions are LINQ-y. Not sure if ReactiveCocoa is the same.
It will detangle some big apps I'm on.
[1] https://github.com/Reactive-Extensions/rxjs-html