June 11, 2014

Swift Development for iOS... and Android with C++ and Object Pascal

Swift is the name of the new programming language by Apple... but I think RAD Studio offers faster development and for more platforms, and adopt two equally powerful languages, C++ and modern Object Pascal.

Swift is the name of the new programming language by Apple, announced last week at the company developers conference. I'm pretty sure you've heard about it.

Swift Roundup

Here are some interesting links and blogs, with widely different opinions:

Language Considerations (C++ and Object Pascal)

I think that RAD Studio, with C++ and modern Object Pascal, offers faster development and for more platforms. Development is based on an equally powerful language, but it is more visual, offers component previews and live data at design time. This is due to the libraries, but there is a clear language influence. Anyway with RAD Studio a single source code will work both on iOS and Android, not to mention Windows and Mac.

By comparison, Swift can be used only for Mac and iOS development, and given it is a proprietary language, it might remain limited to those two platform. Not that the scenario was very different in ObjectiveC, and certainly Swift seems a better and more modern language from what I've read so far.

What does this new language mean for the languages used by RAD Studio?

  • C++ remains a more open and flexible option. With C++Builder and Appmethod you use the same LLVM engine Apple leverages and embrace the same ARC memory management on mobile, you have a similar features set... but a more standard language and many common C++ libraries to use.
     
  • Object Pascal is very similar to Swift features-wise, again uses the same underlying architecture and can gain the same speed of compiled code. Given iOS developers will have to learn a new language, why not learn one that will give them support for more platforms (Android included)?

Swift vs. Object Pascal

How can we compare Swift to Object Pascal on mobile language-wise? Both languages can compile via LLVM, use ARC memory management, are strongly typed, have full support for object-oriented programming with single inheritance and multiple interfaces, both support generics, both have closures. The languages even share some keywords like self and override. And AnyValue looks a lot like TValue.

One more thing. From Tim Anderson article: "There is an interesting feature called Extensions which lets you add methods to any existing type. For example, you could extend Int with a prettyprint method and then call 3.prettyprint." Object Pascal has the same exact feature, it is called helpers and can be applies to classes, records, and native data types. You can write "3.ToString" in Delphi XE6 on all platforms.

Where Swift has more flexibility is in the use of implicit types, tuples, and distinction between nullable and non-nullable types. What seems missing is exception handling, which I personally find quite odd. What I like more in Object Pascal is the use of properties, published, and streaming; named and virtual constructors and destructors, plus class references and class operations, along with rich reflection and attributes. I also prefer the way closures capture the execution context. But this could lead a lengthly debate on languages features, which I really don't want to get into.

Temporary Conclusion

Personally, it is very interesting to see a new programming language coming, and I'm sure Swift will have a good following, because it seems nicer than ObjectiveC and many iOS and Mac developer will move to it. It might also be easier for C# developers to adopt it. Again, it is nice to see some ideas from Object Pascal in Swift, but I'm quite sure there are a couple of nice ideas in Swift that Object Pascal could borrow in the future.

One final question: With more (new) languages gettign wider adoption, will the language barriers reduce and will developer be more willing to be fluent in multiple languages?





 

5 Comments

Swift Development for iOS... and Android with C and Object Pascal 

To be honest, I could never stand Objective-C.
As a Delphi developer, I was always asking myself "why 
does it have to be like this?" (inlets, outlets, etc). 
Comment by Wilfred Oluoch [http://www.ideaz.co.ke] on June 11, 15:28

Swift Development for iOS... and Android with C and Object Pascal 

Here are some generic Delphi Tuples for you 
Marco ;-) 

https://github.com/malcolmgroves/generics.tup
les
Comment by Malcolm [http://www.malcolmgroves.com ] on June 11, 21:30

Swift Development for iOS... and Android with C and Object Pascal 

 Swift has some great language features I miss in
Pascal such as Enum Functions, Multiple Return Types.

It is great that you look into the new stuff around
and consider new Delphi language features!
Comment by Gad D Lord [] on June 11, 23:23

Swift Development for iOS... and Android with C and Object Pascal 

I am looking forward to any improvements and new 
features in Object Pascal language. 

When you talk about learning new languages, you have 
to keep in mind that learning language is piece of 
cake. Any decent developer can pick up basic syntax 
and structure within days (depending on how nice and 
elegant language is). Of course, gaining deeper 
knowledge takes more time, but that will not prevent 
you from using and learning as you go.

The part that is more complex to learn is new 
platform, and frameworks. Since Objective-C 
developers already know their platform and frameworks 
switching to new language should be fairly easy. And 
switching to Delphi would not include learning new 
language, but new frameworks (FMX) too. 

Covering Android part as well as iOS, could look 
interesting to some, but to be more appealing you 
would have to have better compiler support for 
various devices. 

What keeps Delphi developers tied up with Delphi is 
not inability to learn new languages, but investment 
in code they already have. Also, despite of ever 
growing mobile market, Windows platform is still and 
will remain strong when it comes to business use. 
Having Linux support would make Delphi even stronger 
in that area.
Comment by Dalija Prasnikar on June 12, 07:49

Swift Development for iOS... and Android with C and Object Pascal 

Objective-C started out as a Good Idea, but they've added so much to 
it in terms of annotations and quirky stuff for implicit run-time 
support needs, as well as non-standard syntax, that it's not terribly 
easy to read without a lot of tacit knowledge about the platforms and 
run-time environment.

I can't really tell if the main feature around Swift is the language or 
the development environment they've introduced.

The language, however, seems to have been tweaked so it reduces 
several commonly used (and relatively lengthy) idiomatic expressions 
into far more compact expressions. So where are all of the "C/C++ is 
far too cryptic!" bigots?

I don't think I've ever seen a language that collapses common idioms 
into specific syntactic constructs with the idiomatic semantics implied 
in the new syntax. Part of me thinks, "Way cool!" while another part 
wants to gag. It's like ... APL mashed up with a bunch of proprietary 
run-time semantics.

I did notice that Swift supports the use of strings in case statements. 
Given so much resistance to such a simple thing in Delphi, I can't 
really see many of the other simplifications Swift introduces showing 
up in Delphi any time soon -- as much room as there is for 
simplifying the language that I'd love to see.

Another thing I noticed is ... Swift does not perform ANY implicit type 
conversions, which seems rather odd for a language that's relatively 
loosely-typed on the declarative end.

But I'd sure love to see ANY improvements in the Dephi language in 
terms of reducing its verbosity for commonly used idioms.
Comment by David Schwartz [] on June 16, 08:13


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.