April 22, 2013
My Delphi Language for Mobile Development white paper is now available as a free download.
I wrote a 40 pages technical white paper covering all of the language changes in XE4 for mobile development (tied to the new ARM LLVM-based Delphi compiler). The document covers the reasons for the changes (technical and not), covers these language changes in detail, and offers best practices for keeping your code compatible with both the desktop and mobile compilers.
I might blog sections from the paper in the coming weeks, but I recommend getting the free PDF (basically this is
a short book I wrote
as part of my job at Embarcadero), you can get the PDF at http://www.embarcadero.com/resources/white-papers/application-development.
Here is the Table of Contents (which is not in the document itself):
1. A NEW COMPILER ARCHITECTURE
1.1: Introducing LLVM
1.2: Delphi and LLVM
1.3: Why Changes in the Delphi Language?
1.4: What Stays the Same?
1.5 The Delphi Compilers in XE4
2. THE STRING TYPE
2.1: Only One String Type
2.2: Reference-Counted Strings
2.3: Copy-On-Write and Immutable Strings
2.4: Using the TStringBuilder class
2.5: Zero-Based Access
2.6: Using the TStringHelper Intrinsic Type Helper
2.7: Managing One-Byte Strings
3. AUTOMATIC REFERENCE COUNTING
3.1: ARC Coding Style
3.2: The Free and DisposeOf methods under ARC
3.3: Weak References
3.4 Checking for Memory Problems
3.5: The Unsafe Attribute
3.6 Low-Level Reference Counting Operations
3.7 Summary of TObject’s Construction and Destruction Methods under ARC
3.8: Bonus Feature: Operator Overloading for Classes
3.9: Mixing Interfaces and Classes
4. OTHER LANGUAGE CHANGES
5. RTL CONSIDERATIONS
5.1: RTL and Cross Platform
5.2: File Access
5.3 Replacing String Lists With a Generic Dictionary
5.4: Libraries and Packages
6. CONCLUSION
Hope you like it. Feel free to ask for more information here or (even better) email me. The plan is to update the document in the coming months.
posted by
marcocantu @ 4:13PM | 13 Comments
[0 Pending]
13 Comments
Delphi Language for Mobile Development Paper
Thanks Marco. We continue to depend on you to put it
down on paper. Cheers!
Comment by Wilfred Oluoch
[http://www.ideaz.co.ke]
on April 22, 18:32
IOS database
Is it possible to create an IOS app that can access a
SQL Server database that is on the Internet?
Comment by Rob on April 23, 14:24
Delphi Language for Mobile Development Paper
Hi Marco,
Since this ARM thing now exists, will it be possible for
Delphi at some point create true WinRT applications?
Comment by Leonardo Herrera
[http://www.monserratinformatica.cl/]
on April 23, 15:39
Delphi Language for Mobile Development Paper
Thank you, that's really good and detailed information.
I still don't like most of the incompatibilites that
you are introducing, but at least now I understand
your reasoning. The public statements however sounded
much worse than what is documeted here when it comes
to platform compatibility. Communication on this could
be improved.
I'd love to test the ARM compiler for targets that I'm
actively working on (Linux/ARM instead of iOS which I
don't care about), hopefully this will become possible
in the future.
Comment by Simon Kissel
[]
on April 24, 00:33
For a true datasnap...
Hi Marco
Thanks for this paper. It's an exciting news. I think
that you work with Delphi community and you know our
needs. We all know the resources of Delphi that are old
or never offered a solution for the real world. This is
the case of datasnap ... I would tell you that we want a
robust solution for distributed applications. We do not
want a datasnap weak as we have today. We are still
expecting a datasnap that goes beyond small "hello
world". A datasnap that can be more than a fun. I wonder
how long we still have to wait. thank you
Comment by Marcelo Sanches on April 24, 00:50
Delphi Language for Mobile Development Paper
Maybe the incompatibilites will be a forceful
justification to move to C# Java C++ etc.
Comment by ChinaStone on April 24, 09:57
Delphi Language for Mobile Development Paper (Some Answers)
Some short answers:
- To access SQL server directly form iOS you'd need a client library you
can compile into your application. Not easy.
- WinRT requires an ARM compiler, but also an open RTL SDK. Current
one if very hard to use from native (VC++ uses a workaround)
- For Linux/ARM I'd be interested in usage scenarios and some evidence
this is not a niche platform
- For DataSnap we are going to push it, but we are also willing to help
building clients for other solutions
- If moving to Delphi ARM is an issue, I wonder about moving to another
language
-Marco
Comment by Marco Cantu
[http://www.marcocantu.com]
on April 24, 12:45
Delphi Language for Mobile Development Paper
Does LLVM intermediate code mean that you could
create your own virtual machine, that would run this
intermediate code (like java), and allow to run a
delphi vcl app into a browser ? just in theory of
course ;)
Comment by wchris on April 24, 12:52
Delphi Language for Mobile Development Paper
Marco:
ARM/Linux is a niche, it's mostly relevant on the
server-side embedded stuff and for hobbiysts projects,
which however get good public coverage and young
people to start using Object Pascal again - the
Raspberry Pi, for example, which uses ARM/Linux, has
sold over 1 Million units, and keeps growing like mad.
We have tons of experience on that field, we have our
own ARM/Linux based hardware platform deployed in very
high numbers, it's one of our main hardware platforms
besides x86/Linux. Windows x86 and MacOS x86 are used
for GUI-based tools and product infrastructure.
Also, if you have an ARM compiler and the needed stuff
for Android, you pretty much already are done for
ARM/Linux, too. Libc should be used there. For RTL
compatibility, you can re-use much of the still
existing Kylix RTL. FMX support (which is not a must,
as GUIs will be the exception on this platform) should
be a no-brainer.
In other words: Not that much R&D involved. But makes
sense most if combined with a "let's get hobbyists and
beginners back to our platform" offering targetting
that platform. This is not an audience that would be
willing to pay bigger chunks of money for such a
project (unlike, for example, my company).
Not sure if it fits E's current strategy. That's why
we are investing into compiler technology ourselves
for quite some time to be able to target the platforms
we need.
Comment by Simon Kissel
[]
on April 24, 18:25
For a true datasnap
Marco
Like I said, it seems to me good to see you working
for the future of Delphi. But there is an urgent
question: after all, what can we expect from new
developments of DataSnap? We all know of urgent
problems: security, scalability, stability etc..
Essential features that did not even exist in the old
Datasnap. The new datasnap attempted to implement that
features by a suspected combination of Indy and
DBExpress. And is full of bugs...
Marco
We like Delphi. We need robust solutions for
distributed computing. But I'm not accepting DataSnap
for this purpose. I believe that I am not the only
one. So what can we expect from DataSnap in the short
term?
Thanks again.
Comment by Marcelo Sanches on May 3, 13:15
Delphi Language for Mobile Development Paper
Could you post this on your site, every time I try
download it from the http://www.embarcadero.com
website, the file claim's to be corrupt..
Comment by Shaun Churchyard on May 3, 14:01
Removing 8-bit strings is a bad move
> If moving to Delphi ARM is an issue, I wonder about
> moving to another language
This kind of attitude will only result in customers
leaving for other solutions.
Some changes are necessary (I would love to see ARC
on the desktop because it solves long stanting issues
with object and interfaces), but some changes are
rather questionable. Remember, one of the advantages
of Delphi Mobile is ability to reuse existing code
and libraries. Making unnecessary changes (like
removing 8-bit) strings from the language will only
make that task harder. And not only we want to port
existing code to mobile, but we want to use same
libraries on both desktop and mobile.
It is not always possible or desirable to convert 8-
bit strings to unicode on the app edges (slowness
and/or memory consumption). And TBytes are not
adequate replacement for processing strings in 8-bit
form.
Removing features that do not stand in a way of
language going forward is sending bad message to your
customers. If Embarcadero is unable to recognise our
needs or completely ignore them, we will be only more
inclined to go elswhere, especially when Delphi cross-
platform solution is still in it's infancy.
Add ridiculous currency exchange rate for European
customers and Delphi can lose it's appeal quite
quickly.
Comment by Dalija Prasnikar
[]
on May 10, 10:28
Delphi Language for Mobile Development Paper
Hi Marco, thanks for this useful paper, it is good to
see that you are working at Embarcadero, I look
forward to more examples like this.
I'm a big fan of TStringList too and use it for a lot
of lookups. I'll try using TDictionary but I think the
example code you used is a bit disingenuous to prove
the performance of TDictionary. You compare it to
lookups with TStringList using IndexOf - no one using
a TStringList as a dictionary would not have it sorted
and be using Find instead. I suspect there would be
little difference between a sorted TStringList and a
TDictionary?
It would be great to see a native implementation of
UTF8String based on the code that you included on
pages 19-20, we can roll our own based on that but why
not include something along those lines in the iOS
compiler?
The paper was very timely as I was migrating Huffman
compression code over to iOS app and I was getting
weird exception. It was due to the ARC memory clearing
and by adding in __ObjAddRef I was able to stop the
issue and get compression working.
I now have compression and encryption working for iOS
so I can securely exchange serialised objects between
my client and server without having to 'pollute' my
client apps with TDataset code. I'm an OO purist and
believe datasets belong only on the server side. The
excellent new live bindings allow me to associate UI
with object properties to get clean MVC
implementation.
Marco, this is very exciting progress to be able to
target iOS from Delphi and soon Android and maybe
Linux apps too?
Comment by Paul Heffernan on May 19, 17:14
Post Your Comment
Click
here for posting
your feedback to this blog.
There are currently 0 pending (unapproved) messages.