June 17 2011: Software Development Network Event, The Netherlands

On Friday June 17, 2011, the next SDN event will take place in the Achmea Eureko Conference Center in Ziest, The Netherlands will take place, with a full Delphi track consisting of 5 sessions by speakers Brian Long (2), Olivier Olmer, Filip Demuynck, and Bob Swart. Brian Long will talk about Programming for Android with Delphi Prism and Mono for Android, as well as Project Cooper, which brings native Android programming to Delphi developers.
Read More

Developer Issue Report Tool (DIRT) Client screenshots

People who've attended the Delphi XE DataSnap webinar, or read the Delphi XE in Action white paper on "DataSnap XE in the Real World" may have seen the development bits of my Developer Issue Report Tool (DIRT) Server and Client, but here are some screenshots of the most recent build. After you login to the DIRT DataSnap Client (called DirtCleaner by the way), you will get an overview of all issues that belong to you (either because you were the Reporter or the Assigned-To user).
Read More

Delphi XE DataSnap Development courseware and webinar

Within the next 24 hours, I will send out the third edition of the Delphi XE DataSnap Development Courseware manual to all current registered buyers from http://www.eBob42.com/courseware, at 190 pages - now also available as paperback from Lulu.com without updates to the paperback, I'm afraid. The paperback edition of the Delphi XE DataSnap Development courseware manual contains 190 pages, with sections about: DataSnap History and Example Data, DataSnap Server Targets (and Wizards), DataSnap Security, DataSnap Server Components, DataSnap Server Deployment, DataSnap Clients, DataSnap and Databases, DBX: DataSnap Filters, DataSnap REST and Callbacks, DataSnap and .NET Clients, and an appendix about the extended Developer Issue Report Tool (DIRT) Server and Client.
Read More

Working with C++ dll’s from ObjectPascal

It's a well known fact that there are many excelent libraries written in C++, and we, as Object Pascal programmers can take advantage of them. Many times, I have found in forums or mailing lists, questions such as "How can I translate XYZ library to ObjectPascal?", or "How can I use a C++ from Object Pascal?". Well, it's not necessary to translate a library from C++, we can use it just by creating a C wrapper around it.Why I need to wrap the C++ library to C?Because of name mangling, if you look inside the library (using TDump included in Delphi, or by using "nm" on linux), you'll get something like this:000DB314 794 0319 _ZN12DcmAgeStringC1ERKS_000DB274 795 031A _ZN12DcmAgeStringC2ERK6DcmTagm000DB2F0 796 031B _ZN12DcmAgeStringC2ERKS_000DB398 797 031C _ZN12DcmAgeStringD0Ev000DB368 798 031D _ZN12DcmAgeStringD1Ev000DB338 799 031E _ZN12DcmAgeStringD2Ev000DB3C8 800 031F _ZN12DcmAgeStringaSERKS_In the snippet from above, you can see names like _ZN12DcmAgeStringaSERKS. Those names may reffer to functions, methods, constants or variables we can call from Object Pascal by using GetProcAddress. The name in the example, is the "mangled" version of DcmAgeStringa. If the C++ doesn't expose classes, but functions, you can call the functions just by passing the mangled name to GetProcAddress, but what about working with classes?.There's no way to directly use a C++ class from Object Pascal, before using it is mandatory to create a "C" wrapper around it.Let's start by defining a simple C++ class with only one method:#include using namespace std;class Test{ public: Test(); void getHello(char * &AString); };Test::Test(){}void Test::getHello(char * &AString){ const char * str = "Hello World from C++"; strcpy(AString, str);}The class above, can be used with something like this:int main(){ Test * t = new Test(); char * str; t->getHello(str); cout << str;}It just gets change the value of the string "str" and print its contents.As I mentioned earlier, there's no way to create an instance of a C++ class from Object Pascal, but there's a workaround, to create a "C" wrapper around it, and export it from the library.Creating our first "C" wrapper around a C++ classThe idea is to create plain C functions in charge of creating an instance of the Test class, then return a pointer to that instance, then create another function that receive the pointer as param, and use its getHello function.Here's the code:#include #include using namespace std;class Test{ public: Test(); void getHello(char * &AString); };Test::Test(){}void Test::getHello(char * &AString){ const char * str = "Hello World from C++"; strcpy(AString, str);}extern "C"{ void createTestInstance(void * &instance) { instance = new Test(); } void doHello(void * instance, char * &AString) { Test * lInstance = (Test *) instance; lInstance->getHello(AString); } void deleteTestInstance(void * instance) { delete (Test *)instance; instance = NULL; }}If you look at the snippet above, you can see I added code inside an extern "C" block, there will reside the exported functions. I added three functions to create an instance of our class, to use the method getHello, and one to delete the instance.To create a dll from this code, just do this (I'm using Linux here, but you can use MinGW from Windows using the same command):g++ -fPIC -shared test.cpp -o test.soThat command compiles our code and creates a shared object file, in Windows you must replace "-o test.so" with "-o test.dll".Now you can check the contents of the library by using nm or tdump. The result should be something like this:...0000000000000c08 T _fini00000000000008b0 T _init0000000000000990 t call_gmon_start0000000000201068 b completed.74240000000000000ac5 T createTestInstance0000000000000b4e T deleteTestInstance0000000000000b21 T doHello0000000000201070 b dtor_idx.74260000000000000a30 t frame_dummy U strcpy@@GLIBC_2.2.5 U strlen@@GLIBC_2.2.5...You can see, that createTestInstance, deleteTestInstance and doHello now aren't mangled as in the plain C++ library. Now the fun part!The last step of this journey, is to create an Object Pascal program that loads and use the shared library. The program should do this:1) Load the library and store a reference to its handler.2) Execute the method createTestInstance and store a reference to the pointer it returns.3) Execute the method doHello by passing the pointer stored in point 2 as parameter.4) Delete the instance by executing deleteTestInstance and passing the same pointer.Here's the code:program Test;{$mode objfpc}{$H+}uses dynlibs;type TCreateInstance = procedure (var AInstance: Pointer); cdecl; TdoHello = procedure (AInstance: Pointer; var AString: PAnsiChar); cdecl; TDeleteInstance = procedure (AInstance: Pointer); cdecl;var lCreateInstance: TCreateInstance; ldoHello: TdoHello; lDeleteInstance: TDeleteInstance; lHandle: TLibHandle; lInstance: Pointer; lStr: PAnsiChar;begin lHandle := LoadLibrary('./test.so'); if lHandle NILHandle then begin writeln('Library loaded successfully!.'); lInstance := nil; // First, create the instance Pointer(lCreateInstance) := GetProcAddress(lHandle, 'createTestInstance'); if @lCreateInstance nil then lCreateInstance(lInstance); // Second, use the instance Pointer(ldoHello) := GetProcAddress(lHandle, 'doHello'); if @ldoHello nil then begin GetMem(lStr, 255); ldoHello(lInstance, lStr); writeln(lStr); FreeMem(lStr); end; // Third, delete the instance and unload the library Pointer(lDeleteInstance) := GetProcAddress(lHandle, 'deleteTestInstance'); if @lDeleteInstance nil then begin lDeleteInstance(lInstance); UnloadLibrary(lHandle); end; writeln('Done.'); end else writeln('Cannot load library.');end. That's all. Now you can use all your loved C++ libraries from Object Pascal!.
Read More

Why Microsoft and Nokia have a chance

Many iPhone and Android fans don't believe that Nokia and Microsoft have much chance to succeed. While everybody agrees that they wouldn't have a chance without good partners, few seem to agree that they can do much together. The most frequent explanation is that their level of innovation is too low, and their R&D doesn't really work. Most people, however, don't care about the phone producer's
Read More

Learn about Multi-Tier Application Development with DataSnap XE

Embarcadero has just published my new DataSnap white paper where you learn about Multi-Tier Application Development with DataSnap in RAD Studio XE, based on a small but real-world DataSnap application that covers just about everything you can imagine: from secure connections to simple server methods, server methods returning read-only datasets, datasetproviders returning master-detail datasets, with autoincrement primary keys (and how to handle those), using authentication and role based authorisation to secure not only the server methods but also the exposed datasetproviders, deployment and more.
Read More

The future of C#, the bloat explosion, and what happened instead

Looking back on this video with Anders Hejlsberg, about the future of C#, from march 2009, or this blog post about the upcoming bloat explosion, seems quite awkward with the current explosion of iOS and especially Android. There are numerous awkward parts in the video: The focus on objects, the "huge amounts" of memory and the statement that multithreading is the exception. As readers of this
Read More

Android sells better than Windows to consumers

If you combine a few news articles, things get interesting: http://www.guardian.co.uk/technology/2010/nov/29/apple-ipad-cannibalising-pc-sales "Gartner forecasts that worldwide PC shipments for 2011 will reach 409m units" = 1.1 million per day. It is fair to expect less than 40% of these sales to be for consumers. This is an 18% growth, meaning that in 2010, we can expect PC sales to reach 138
Read More

R.I.P Microsoft Windows?

Microsoft is usually very good at presenting new products years ahead of the actual launch - but there continues to be a very remarkable absence of a single strategy for support of Windows applications or Windows as a well integrated desktop. Android provides many improvements that Windows does not offer as part of the standard platform: * Easy app discovery and installation (Android Market) *
Read More

Non-Delphi: Postmodernism, Transformers: ROTF and Baudrillard

The simulacrum is never that which conceals the truth--it is the truth which conceals that there is none. The simulacrum is true. (Baudrillard, Simulacra and Simulation) I've just watched Transformers: Revenge of the Fallen, and it got me thinking. It's perhaps the most post-modern movie I've seen to date. T:ROTF isn't so much a movie as a string of soundbites, stereotypes and cliches arranged into a 2.5 hour trailer for a movie you'll never get to see, because it was never made. You turn up for the product the advertisement is selling, but it turns out the whole product was ad. There's no "there" there. I've never seen a better embodiment of Baudrillard's conception of simulacrum than this. The meaningless symbols are so densely packed in this movie I need a convention. Everything in the movie is a stereotype or cliche: a stand-in, an intellectually lazy shorthand reference. I'll be lazy too, and mark stereotypes in my commentary with [brackets]. The beginning is indistinguishable from a trailer. A brief [dawn of man] scene, you know the kind, [stone age people silhouetted against a dawn sky somewhere in Africa], doing [caveman things with the spears and the facepaint], with a [rumbling voiceover] helpfully telling you that it's ["Earth, birthplace of the human race"]. If it were storytelling, it would be rushed, heavy-handed, and contemptuous of the viewer - both showing and telling. But I don't think it is storytelling. It's arranging some symbols (humans, decepticons) into a particular aspect required for later symbolic purposes. The decepticons portrayed in this ancient time are [evil] (with [King Kong-like grabbing] of a feeble human, albeit male), but there is no motive, no narrative. Why would such powerful machines pay any more attention to stone age humans than they would apes, or insects, which they can swat away with similar ease? Next up: Shanghai, [disaster scene], with [disaster radio news chatter]. Cue [Pentagon command centre], explaining that some black hawks are moving in, while showing some black hawks moving in: Americans aircraft and troops entering Chinese territory, in complete suspension of geopolitical disbelief, no explanation considered necessary. Expository trailer voiceover says "new autobots", while expository camera shot shows new autobots, including [hot girl on bike], [fast car], and [military transport]. "Together, we form an alliance", explains voiceover, while showing human troops in [military transport] (which subsequently transforms). No attempt to explain why squishy soldiers with small arms are going up against fast-moving heavy machinery. What do they hope to achieve with their flying pieces of lead? Would they go up against even a human-engineered tank with such miserable munitions? Nor an explanation for the gunships flying with mere tens of feet clearance from the ground and the surrounding buildings that tower over them, completely negating the tactical advantages of a mobile, hovering cannon and missile platform. But all is soon revealed. The squishy humans aren't going in to fight, they are going in to be squished, to symbolize human weakness against the machines. After a decepticon slams its fists into some concrete pipe sections, somehow creating a fiery explosion, gunships capable of engaging the enemy with missiles and canons from considerable distance approach low and close enough to be clobbered with a mere wave of mechanical arms. As an alleged depiction of a military engagement, it's beyond ludicrous, laughable on its face. Suspension of disbelief isn't possible: this isn't a battle; it isn't even a simulation of a battle. It's a simulation of battle simulation, an arrangement of symbols of battles. Here are our valiant heroes going into battle; here's our shockingly powerful foe, see how he easily puts our heroes on the back foot; but wait (!) here come our heroes again with reinforcements, to win the day with a bunch of soundbites: ["damn, I'm good!"], ["punk-ass decepticon"], ["any last words?"], "the fallen shall rise again", ["that doesn't sound good"], ["not today!", reload-click, bullet to the head]. That's just the first 8 minutes or so; it goes on for hours (!), with no variation in pacing that you wouldn't also expect in a 30-second movie trailer. Some other commentary roughly concurs with mine, though I didn't enjoy the spectacle or visual feast aspects, primarily because those spectacles are filmed too close to the action, and the subjects, transformed machines, have so many bits and bobs hanging out of them it's hard to tell where one begins and another ends, much like how camouflage breaks up outlines. Trying to figure out what's actually going on within the pace of the editing cuts would give me a headache. Besides, marvelling at the sheer density of signifiers and its generally jaw-dropping empty awfulness is more fun, in a perverse way.
Read More