3 ms·
My latest project is written in Swift. It was honestly a no-brainer to switch. ObjC seems a bit cobbled together, and a lot of things look a bit more verbose t
by lordnacho 11y ago
My latest project is written in Swift. It was honestly a no-brainer to switch.
ObjC seems a bit cobbled together, and a lot of things look a bit more verbose that they need to be. And there's some type safety issues lurking in various places, too. And then there's the whole having .h and .m files, an inconvenient way to organise things in this day and age. Sure, I was used to it from c++, but that isn't the fastest language to code in, either.
One needs to get over the trepidation of a new language. I was talking to another CTO about this, a guy who's been coding for 30 years. Once you understand the domain and you can solve the problem, language is not a big deal. Of course you need a language that contains the abstractions of the solution, but generally any OO language will be able to do it. What's left then is whether the language lends itself to coding tools, terseness, library availability, and the level of granularity you need.
As a language that's focused on building nice apps, Swift strikes a good balance. If I'm going to be doing UI stuff, I can assume I won't need the fine-tuning that something like c++ gives me. I generally don't want to be bothered by the memory management, and I don't expect performance to be a big deal (people can wait dozens of ms for something, they won't notice). If anything takes a long time, I can use GCD just like in ObjC. I care that things are easy to find in the code, and there aren't many contortions (eg pull out something as an id and cast it. Concat a string by using a ludicrously long function with an unobvious name). There's library compatibility, so I can pretty quickly glue together an app from the same pieces as ObjC, with less glue.
- masklinn 11y ago> ObjC seems a bit cobbled together Of course it is, the original ObjC stapled smalltalk features to C with a preprocessor (Cox's original project was called OOPC "Object-Oriented Pre-Compiler"). It later grew a genuine frontend and its own runtime, but the core idea remained: a thin dynamically typed language layer over raw C.
- benguild 11y agoI've been able to convert a few key modules over to Swift without any major issues. I can see that the 2-3 week estimate for getting comfortable in it versus Objective-C is probably about right.