3 ms·
> Swift also has a number of functional methods (map, reduce, etc) that are really nice for this. writing functional extensions for base classes in ObjC takes
by dinkblam 3y ago
> Swift also has a number of functional methods (map, reduce, etc) that are really nice for this.
writing functional extensions for base classes in ObjC takes like an hour and every seasoned ObjC programmer has those extensions in his toolkit/library anyway. so that doesn't sound like a killer argument for switching to Swift.
- happytoexplain 3y agoThis is unrealistic. Tons of "seasoned" ObjC programmers will take one or two orders of magnitude longer than an hour to write home-grown replacements for all the functional methods, and they frequently turn out limited in some way, or at least less performant. Maybe you're implicitly arguing that those developers are irrelevant to the conversation of Swift vs ObjC, and I would disagree there too. Languages need to strike a balance between catering only to the most highly experienced and specialized developers, and hobbling themselves to be "idiot proof".
- KerrAvon 3y agoThe problem with map/reduce/etc in ObjC is twofold: - Objective-C doesn't support generic value types for function arguments - Objective-C can't optimize away method calls and therefore value boxing What that means in practice is that you can't write a generic version of map/reduce/etc without it being very slow even for things that should be very fast. If you want one that works efficiently for value types like integers, you must write a specialized version for each type. (I have written and sometimes use for convenience ObjC map/reduce/etc implementations.)