Hacker News new | ask | show | jobs
by blueprint 3085 days ago
What exactly is wrong with view controllers..? That strikes me as rather like saying there's something wrong with 3GLs. Are you suggesting React solves the programming language problem completely? If not, I'd like to ask you again what is wrong with view controllers. I've had frankly endless success with them once I got over my lackings.
1 comments

Well there's nothing absolutely 'wrong' with them. You can write good and bad apps with view controllers (I've done both). But they're an architectural blank slate, mainly offering access to UI objects & lifecycle callbacks. You need some architecture on top in anything but the most trivial app. The naive approach is to have 'no architecture', which actually is an architecture of just throwing masses of state, ad hoc, into the view controller, and using this to effect the UI any old how (so a 3rd party has no idea where to look to find out where things happen). Or you can go maximalist and select from MVC, MVP, etc, all of which are an improvement on the naive approach.

It just so happens that I've found RN (React Native) to be the nicest improvement, to my taste. Simple unidirectional data flow & UI state being a simple function of app state make for a beautifully clean and unambiguous model for how everything fits together.

One can argue the costs and benefits of app architectures all day, but there's really no substitute for trying them out, for the sake of curiosity & learning. All the devs I know who have written RN groan a bit when they're back in iOS and/or Android native development, and absolutely not because they love javascript!

Check out Andy Matuschak's celebrated Tweet on RN (https://twitter.com/andy_matuschak/status/560511204867575808). I point to it not as an argument from authority. But if one of the people who wrote UIKit thinks RN's model is the superior one, surely that should pique curiosity just a bit?

> Are you suggesting React solves the programming language problem completely

I'm not sure what you're getting at here. What 'programming language problem'? And why would an improvement have to solve something 'completely' to be of value?

> Simple unidirectional data flow & UI state being a simple function of app state make for a beautifully clean and unambiguous model for how everything fits together.

Not an iOS expert (I work on Android) but can't you have this in native in the first place ? Many Android apps are already using this kind of arch without React Native. I don't see why it can't be the same on iOS.

Yes, but it doesn't come for free. You have to adopt an architecture & write the relevant boilerplate, or use a library where relevant. In the RN case, the least trivial part is applying UI diffs representing the move from a previous to next app state.

Have a look at my parent post -- what I was expressing a wish for was a cross-platform Kotlin library implementing RN-like UI rendering. I'd love to get a combination of the benefits of the RN approach, but written natively in Kotlin.