Delphi Handbooks Collection

Delphi XE Handbook

Delphi 2010 Handbook

Wednesday, January 18, 2012

The Pascal Spring (by Verity Stob)

Very amusing new piece by Verity Stob about the Sons of Kahn, featuring Delphi XE2 and FreeAndNil

Verity Stob has released on The Register Very a new amusing new piece on "The Sons of Kahn and the Pascal Spring", which has already been twittet and blogged, but it is worth noticing. 

In the first part, there is an interesting assessment of the failure and troubles of competing technologies (" Sharpers of Dotnet were also troubled, especially the cult of Silver Light" and "the Sharpers were laughing compared with the fate of the tribe of Flashinites"), as an explanation of the success of Delphi XE2 and the gang of "discotheque of Embarcadearohdearohdearyme" who "bought in stuff from Europe and Russia".

Interestingly enough, the last part is devoted to the fact the Delphi factions instead of rejoicing are fighting around the use of FreeAndNil... something I tried to avoid blogging about, but might not resist.

Great job, as usual, Verity:  "if this is the Second Coming, then it is not quite as I had imagined it."





Friday, January 13, 2012

Delphi Developer Days 2012 Very Early Bird and Guest Speakers

The very early bird singup for Delphi Developer Days 2012 (with 25% discount) expires in a few days. Plus, book early as we might end up room in some cities. Plus, we ahve the guest speakers list.

Delphi Developer Days is the yearly conference/training class I organize with Cary Jensen in the USA and Europe. We are planning 2 US + 4 European stops (in 4 different countries) this year.

Very Early Bird

The very early bird signup for Delphi Developer Days 2012 (with 25% discount) expires on January 20th, for each and all of the dates (March through May). If you are interested in participating, book ASAP for the extra discount. Previous attendees will still get a good rate, but not the general public. Did I tell you this is one of the best (and most well attended) Delphi training events of the year? Details at  http://www.delphideveloperdays.com/

Book Early, Might Get Full

Another reason for booking early (before or after this first deadline) is that some of the locations are filling up quite nicely, and might as well get full. If a location gets fully booked, you'll have to pick a different city and date. First come, first served, of course. Seems Rome is still quite empty, though.

Guest Speakers List

Finally, we do have a complete guest speakers list:

London, United Kingdom:  Stephen Ball, Embarcadero Technologies
Amsterdam, The Netherlands:  Bob Swart,  Bob Swart Training & Consultancy
DC/Baltimore area, USA:  Jim McKeeth,  RemObjects Software
Chicago, USA:  Ray Konopka,  Raize Software
Frankfurt, Germany:  Bruno Fierens TMS software
Rome, Italy:  Daniele Teti,  BitTime 

Of course, I'll take the advantage of this blog post to thank all of these Delphi experts, who've accepted our invitation. 

As I mentioned on twitter, I've been doubling as a travel agent, to get my various flights. Most are booked now, See you at Delphi Developer Days!

Monday, January 9, 2012

Delphi and Facebook Base64 Url Encoding

Was working on a Delphi server used to build a Facebook application, when I bumped into an odd Base64 decoding issue. Thanks to some very approximate Facebook documentation.

Was working on a Delphi server used to build a Facebook application, when I bumped into an odd Base64 decoding issue. If you look at the Facebook page documenting their Signed Request parameter, you can see it has a first part with an encoded signature (which I won't really mention here) plus some JSON data encoded in Base64. This looked trivial, but as I started using Indy's TIdDecoderMIME class, the result would be correct... but only at times. Other times, the final } of the JSON string was missing. Now, since there were three closing braces at the end of the specific error situation, I didn't spot the error immediately, the JSON string apparently looked good:

{"algorithm":"HMAC-SHA256","issued_at":1111111,"page":{"id":"-omitted-","liked":true,"admin":true},"user":{"country":"it","locale":"en_US","age":{"min":21}}

If you look at it carefully, you'll see that the third final brace is missing. So now I could figure out while the JSON parser was crashing badly on me (by they way, I'm using JSON SuperObject for this specific project, nice class). Back to the Facebook documentation. They did say "a base64url encoded JSON object", with a link to Wikipedia, but the link doesn't really explain much:

"modified Base64 for URL  variants exist, where the ' + ' and ' / ' characters of standard Base64 are respectively replaced by ' - ' and ' _ '," and " Some variants allow or require omitting the padding ' = ' signs "

Saying there are some variants of an algorithm is not really the best way of documenting it. Facebook doesn't really say which "variant" it is implementing, but, well, at least you can guess among a few options. Moreover, the demo simply calls a PHP function, base_url_decode, and doesn't offer much advice.

Initially I though of a problem with the Indy decoding, tried a couple of alternatives, went to nowhere. In fact Delphi has another SOAP-related Base64 decoded, who was doing the opposite, that is adding some garbage at the end of the string. Now that I knew where the issue was, it was easy to google "base64 decoding facebook" and find a nice blog post, http://qugstart.com/blog/ruby-and-rails/facebook-base64-url-decode-for-signed_request/. This is written in Ruby, but having a minimum of description, I could translate it over to Delphi in very little time (see image below for formatted version):

  strFixup := strInput + StringOfChar ('=', Length (strInput) mod 4); // nope, fixed below
  strFixup := StringReplace (strFixup, '-', '+', [rfReplaceAll]);
  strFixup := StringReplace (strFixup, '_', '/', [rfReplaceAll]);

Update: as suggested in a comment below, this is not correct, as when there is one extra byte we need to add 3. However, in case of zero extra bytes, we shouldn't pad with 4, so evern the original Ruby code seems wrong. I've now fixed it with:  (4 - Length (strInput) mod 4) mod 4, as in the image below.

To be honest I have to say there is a Q&A in the Facebook page I didn't initially read. It says "if you are missing a few characters, you are probably using normal base64 decoding instead of base64url decoding. See  wikipedia ." But, again, wikipedia said there are several variants, come on Facebook! Even more surprising it that the provide a sample conversion at the very end of the page ("Do you have any example?)" , but that's actually only half of the what's encoded in the initial string!  

Thanks to some very approximate Facebook documentation I wasted a few hours. I think documentation for online APIs should be much more precise and do't take for granted everyone is using a single programming language in the world!

Wednesday, January 4, 2012

From Delphi to Android

Android is bigger and bigger every day. What does this mean for Delphi programmers, how can you move knowledge and code? How can you program in Object Pascal for Android? An overview of the current options in a rapidly moving area.

Android is bigger and bigger every day. What does this mean for Delphi programmers, how can you move knowledge and code? How can you program in Object Pascal for Android? An overview of the current options in a rapidly moving area. 

It is about a month since I first considered writing a post on this topic, but given this is a rapidly evolving area I'm sure this is a better timing. having just seen two / three articles on specific technologies, I think it is time to get this moving. Let me first add a couple of personal considerations:

  • I think Android is big and will grow a lot. I've been using an Android phone for over an year, and I like it. Won't trade it for an iPhone or Lumia. I own an iPad, find it much more interesting than I anticipated (this is worth another post), but Kindle Fire, the coming GPad (Google iPad Clone), and more options will open this area to Android as well.
  • I think development tools for mobile are still in their initial stage and will grow, landscape will change.
  • I'm not generally terribly fond of code converters (sorry for those building similar tools, but I'm negatively biased).

Having said this which are the real and practical options for Delphi developers who want to build Android applications? These are the options I've noticed, let me know if I miss any, and if I missed any key information (feel free also to add more details, here I'm trying to provide summaries).

Alternative Android Development Options

Before we look to the available Delphi-oriented tools, let me try to summarize the options for building Android applications:

  • Writing Java applications for the Delvik virtual machine, generally using Eclipse and the Android SDK and plug-ins. This is the standard and mainstream appraoch.
  • Writing HTML + JavaScript Web applications optimized for the device, maybe using a library like jQuery Mobile. You can simply point users to URLs, or embed the page in a true Android Web App, and even interact with the device using a library like PhoneGAP. What's interesting in this model is that you can use the same application also on iOS.
  • Write native applications using the NDK, generally in C or C++.

Delphi Language Tools for Android

It is interesting to notice that different tools that bring the Delphi language (or Object Pascal) to Android follow each of the three models above. Here is a summary:

  • Oxygene for Java, by RemObjects, is a tool for writing Delphi-like code (or more Delphi Prism-like code) in Visual Studio converting it to Java for Android. Has a nice way to let you refer to any existing Java library, more or less like Prism does with .NET libraries. Read more at  http://www.remobjects.com/oxygene/java.aspx and Brian Long's article at http://blong.com/Articles/OxygeneForJavaIntro/OxygeneForAndroid.htm. With this tool you create Java applications.
  • SmartMobileStudio (formerly OP4JS) is a tool to convert Delphi code to JavaScript and create web applications. Official site is at  http://www.op4js.com/. Primoz has a nice article at http://www.thedelphigeek.com/2012/01/first-steps-with-smart-mobile-studio.html. I tend to disagree on the main rationale (JavaScript is low level / not good / too complex / etc), but still this tool might get you to code faster. With this tool you create Web apps.
  • Use FPC (Free Pascal Compiler) to build native apps, as detailed by Uwe at  http://www.bitcommander.de/blog/index.php/2011/12/19/fpc-android-boot/. After all, if Embarcadero is using FPC for iOS, it could also be good for Android. Still quite an early version, but interesting. And native.
  • Use Delphi DataSnap REST engine with a proper library to build Web Apps, like I did and documented on this blog at http://blog.marcocantu.com/blog/mobile_jquery_delphi_rest.html and http://blog.marcocantu.com/blog/web_andoird_app_delphi_datasnap.html. Yes, you need to write some JavaScrip, but can also use Delphi to generate some, as I do in my Relax Framework. You can probably use the JavaScript REST proxy also from SmartMobileStudio, but I'm not sure about this.
  • Use Eclipse ... and Delphi's Mobile Connectors for DataSnap. You can still write the core code and the database access code in Delphi, and code the UI in native Android Java. Or possibly use Oxygene for the front end, and Delphi for the backend. Or other server plus client solutions. Bittime has written a "Connect Four" app with this model, see https://market.android.com/details?id=com.bittime.connectfour&hl=en.
  • Wait... for a future Delphi for Android, and learn FireMonkey for now, as it seems likely the future, rumored, unofficially promised Delphi for Android will have the same user interface of the current Delphi / FPC for iOS, ties to OpenGL. At the 24 hours of Delphi, JT and DavidI promised a webinar for presenting the new roadmap in early 2012... so I'm waiting. Will this be a native / NDK solution? 

Again, there might be more options and alternatives, particularly in the Web App arena, but this offers you some alternatives... to get to Android or get ready for it. Awaiting your comments (better on the blog than on Facebook, but anything goes).





Tuesday, January 3, 2012

Why Skype used Delphi?

Skype engineers describe why the picked Delphi for the Windows version (a rather old link in my "to blog" list).

This page on Quora about Skype is quite old (two years, which in the Internet age is a lot!), but wasn't linked much and wasn't linked by myself although I did blog about Delphi and Skype several times. Came to my attention last month, and now that I'm doing my new year email cleaning up, find it is still worth sharing.

Original link on  http://www.quora.com/Skype/What-programming-language-was-Skype-originally-written-in?mid=55546 . I think it is very relevant for Delphi, even if the decision appears somewhat casual. 

 

Amazon S3 Clients for Delphi XE2

I've written articles and published source code for native Amazon S3 clients written in Delphi XE2, both VCL and FireMonkey.

I've written new articles on Amazon S3 (Simple Storage Service) from Delphi for the latest issues of Blaise Pascal Magazine (http://www.blaisepascal.eu/). That's specifically issue 19 and 20.

The source code of the two projects has been added to my Delphi REST Clients repository (http://code.marcocantu.com/p/delphirestclients/), specifically at:

I'm still trying to figure out why the Amazon S3 components seem to crash on the Mac, as this would be a nice project to move over.

 

Going to publish quite a bit of FireMonkey code this month, will create a specific code project... this is just a start.

Saturday, December 31, 2011

My Year in Cities, 2011

As it is now a tradition on this blog, this is my 2011 in terms of cities I've been to, with a few new entries.

Very busy and not blogging much, but I'll catch up. As it is now a tradition on this blog, this is my 2011 in terms of cities I've been to, with a few new entries. I did this in 2006, 2007, 2008, 2009, and 2010. If you haven't seen it in the past, this is a list of cities I've been to in 2011, for either work or vacation. The rule is: Places I've visited in 2011 for at least one night, in chronological order.

  • Piacenza, Italy (where I live)
  • Arezzo, Italy
  • Padua (or Padova), Italy
  • Paris, France  -- for Embarcadero meeting
  • Washington dc, USA
  • Baltimore, USA -- for Delphi Developer Days
  • Houston, USA  -- for Delphi Developer Days
  • Atlanta, USA
  • Frankfurt, Germany  -- for Delphi Developer Days
  • Amsterdam, Netherlands  -- for Delphi Developer Days
  • Gunzburg, Germany -- for Legoland
  • Gropparello, Piacenza, Italy
  • Courmayeur Mont Blanc, Italy
  • Paris, France -- for CodeWay Tour
  • Koln (or Cologne), Germany  --  for Delphi tage
  • Ankara, Turkey -- for Delphi XE2 event
  • Verona, Italy -- for ITDevCon
  • Bolzano (or Bozen), South-Tirol, Italy

Well, it was another busy year, and with a great new version of Delphi. I've already many trips planned for early 2012, including the new 6-cities tour of http://www.delphideveloperdays.com/ between March and May.

I wish you all a great 2012, hoping it will bring us Delphi for Android before ... the end of the world. Cheers.

Tuesday, December 20, 2011

24 Hours of Delphi Today

In an hour or so David I will kick off a new 24-hours of Delphi event, featuring also myself (around 7pm, European time).

In an hour or so David I will kick off a new 24-hours of Delphi event, featuring also myself (around 7pm, European time). To sign up visit http://embt.co/Delphi24. The detailed program (a bit hidden, I have to say) it at:

http://blogs.embarcadero.com/davidi/2011/12/16/41441/

As you can read there, the even will start today at  12:00am PST / 08:00 GMT / 9:00 Central European Time . Speakers include Pawel Glowacki, Stephen Ball,  Jim McKeeth, Bob Swart, myself, Delphi program manager JT, Anders Ohlsson, Alister Christie, Bruno Fierens, Cary Jensen, Andreano Lanusse,  Tomohiro Takahashi (speaking in Japanese!). The live interviews will be intermized by CodeRage 6 replays (well, they need to get some sleep after all). 

This is my specific section (but there will be also some replays of my CodeRage 6 session), focused on the client phone app I recently blogged about:

10:00am PST (Dec20) / 18:00 GMT (Dec20) / 19:00 CET (Dec20) – Marco Cantu ( http://www.marcocantu.com/ )
Building a web phone client with a Delphi REST server based on jQueryMobile, 
Delphi Developer Days 2012 , Delphi Books, and Q&A

Stay tuned for the next 24 hours, if you can!





Monday, December 19, 2011

Delphi Developer Days 2012 Official Announcement

Cary Jensen and myself are officially kicking off the new edition of DDD, with 6 stops in Europe and US in March-May 2012

Cary Jensen and myself are officially kicking off the new edition of DDD, with 6 stops in Europe and US in March-May 2012. You can read the more official press release at  http://edn.embarcadero.com/article/41923.

This is a two-day event (in between a conference and a regular class) that has both joint session in which we compare views and offer insights, and parallel sessions in which you can pick a topic and listen to either myself or Cary. For the spring 2012 we are going to hit 6 cities, 2 in the US and 4 in Europe:

  • London, United Kingdom: March 26-27, 2012
  • Amsterdam, The Netherlands: March 29-30, 2012
  • Washington DC/Baltimore, USA: April 16-17, 2012
  • Chicago, USA: April 19-20, 2012
  • Frankfurt, Germany: May 14-15, 2012
  • Rome, Italy: May 17-18, 2012

Unlike past years, we are alternating 2 European sessions with the one in the US. This means that developers in Europe can pick two different time frames, depending on their expected workload in the period. Also, while we are getting back to some cities we've been in the past, including London and Chicago that we missed last year, there is a new entry, Rome. The hope is not only to attract Italian developers, but also international developers looking for an interesting destination (and a bit unusual one for IT events). That's why in Rome we picked a downtown location, unlike most other cities. 

In terms of content, the goal is to cover all new Delphi XE2 features but also recap recent Delphi extensions and a few classic topics. The joint sessions will be:

  • Delphi XE2 Features You Might Have Missed
  • Delphi Database Strategies
  • Introduction to FireMonkey
  • Delphi Internet Applications and Delphi Mobile Applications
  • Delphi Tips, Tricks and Techniques

Sessions given by us individually will cover ClientDataSet, DatSnap, more FireMonkey, RTTI, dbExpress, LiveBindings, Unicode, and jQuery. The complete program (still subject to change in the sessions sequence and timing) is available at http://www.delphideveloperdays.com/descriptions.html.

We'll give to all attendees a very large courseware with white papers (not slides) and lots of free software licenses donated by our sponsors, which include Embarcadero Technologies, Sybase, /n software, Devart, Gnostice Information Technologies, RemObjects Software, Sisulizer, TechXtend / Programmer's Paradise, and TMS software. I'll blog again about some of the details of the event, but for now notice that there is a 25% discount in you signup before mid-January. So act soon, and save a lot!

Friday, December 16, 2011

Delphi XE2 Update 3

Embarcadero has released Update 3 for Delphi XE2, continuing with an almost monthly update cycle.

Embarcadero has released Update 3 for Delphi XE2, continuing with an almost monthly update cycle. The new update is a whopping 412 MB and you can get it in the Registered Users page (specifically at  http://cc.embarcadero.com/item/28670) and with the Check for Updates featuer of the IDE. There is also a new ISO with the updated product installation image. As in the recent updates, the PAServer and FireMonkey portions of the installation that you need to install on a Mac must be set up manually.

What's in this new update? A new standard iOS style more complaint with platform standards (a significant feature for iOS developers), a new VCL style, and a ton of bug fixes. There is also an extension for the dialog modal results enumeration (for both VCL and FireMonkey). A very detailed description is at http://docwiki.embarcadero.com/RADStudio/XE2/en/Release_Notes_for_XE2_Update_3 while the list of fixes is at http://edn.embarcadero.com/article/41831/. Among the fixes I noticed:

  • Fixes in Version Info in the Project Options
  • Fixes in VCL Styles
  • Fixes in 64- bit debugger and in the memory manager (for 64-bit apps using more than 4GB)
  • Compiler fixes for generics, 64-bit, and more

Of course there are also many expected FireMonkey fixes, including some that were really needed and some relevant ones for iOS. Some of those I was waiting for are:

  • TEdit: SelectAll should not be called when clicking on an edit
  • TCheckbox should check on Mouse Up
  • FMI: bad quality of loading image on iPad
  • Having a ShowMessage with short text containing spaces, the text is wrapped but height is not adjusted.

In other words, this is another must-have update.