Archive for May 22, 2015

Why do some people hate Delphi so much?

May 22, 2015 30 comments

I have to admit that all the rubbish snag comments about Delphi is really annoying. Why does seemingly intelligent, clever and open-minded individuals hold some grudge or negative judgement regarding Delphi?

Where in God’s name does this come from? And who in their right mind, being grown men in their 30’s, 40’s and 50’s, would start acting like little children like this?

I see it almost everywhere. Even in my last job where we had two teams working with C# and Delphi, joining forces to produce a top quality product. Yet behind closed doors there existed a kind of silly superiority complex amongst the C# users which I found disrespectful, superficial and outright stupid.

What is really a shame here is that almost everyone I have met holding such a dumbfounded attitude, which keeps on thrashing Delphi and object pascal in general, is that they demonstrate absolutely no idea what they are talking about! Some have tried Delphi in past and found it to complex, some never liked it — and all of that is ok of-course. We can’t all be expected to like the same music, food, art or colors – so different programming languages are no exception. But when individual after individual turns out to be just mindless parrots repeating what other parrots are repeating – I just have to set the record straight.

First things first

The first argument to fall flat on its face against Delphi is the one regarding age. “Oh it’s just old crap” I hear people say, “it’s not modern enough”, or even more humiliating (for them), it’s not cutting edge like C++, C# or Java!

The latter argument makes me want to throw up. Literally. Because what these sad individuals fail to recognize, is that C is about three years older than Pascal. Pascal was designed to largely replace C, because C was never intended to be in its present state to begin with. Like JavaScript the syntax was never finished but a result of old habits, deadlines and a moving market. C is a language made as they went along, it’s not planned or thought out like Pascal, C# or Java.

Back in the sixties and seventies programming languages were very crude; each command was just replaced by a fixed block of machine code, with various macro mechanisms to set parameters. So in the first pass the compiler made checked the syntax, the second replaced your “c” code with a blocks of assembly code, the third generated an entry-table for each sub-routine and it’s initializer (hidden routines for allocating static memory) and the fourth pass emitted the now pure assembly code text-file to disk. At the end of this horrible process which could take hours, an assembler was invoked to turn each .asm text-file into machine code .a files. And the last step was the linker gluing each piece together into a working program.

As such “C as a language” was never really finished. C was just a toolkit engineers used when creating operative systems, rom images and software for mainframes. Whenever they needed a new command they just extended the language as they saw fit.

So it was never cleaned up properly; the syntax was never renamed to be more understandable, the curly brackets { }, which were only used to save precious bytes of memory were not replaced with begin or end keywords, and the externalized header files were left as they were. An echo from the past when computers had so little memory that it made sense to parse line-by-line on disk rather than wasting ram. And when I write disk, I mean tape.

To make the chaos complete take into account that there were around 8 different “C” dialects on the market. Just like there are myriads of Basic compilers which all have their own take on what Basic really means.

Education, universities and engineering

So, with the state of the C language in mayhem, competing dialects, compilers, calling conventions and so on — a group of people got together to create “a better C” language. I can imagine that trying to tell X number of companies to do as they say was met with little success. Once people have mastered a language they tend to stick with it, it’s always hard to introduce change, especially if you have nothing but an idea on the menu.

So what the pascal group did was to grab the features C had to offer, humanizing the syntax, polling the header back into the unit file (so no external .h file are needed), decide on registry calling convention as standard (hence we have “pascal” calling convention today, even in C# and Java) — and the result was Pascal.

The purpose of humanizing the language (e.g replacing { } with “begin” and “end” keywords) was for good reasons:

  • To improve readability of complex low-level code
  • To make it easier to teach at universities for students with no computing background
  • Take height for the fact that the human brain recognizes words made up of letters, faster than non alphabetical characters  (*1)
  • To better be able to assemble a curriculum fit for tutoring, which was problematic with C due to the large differences in dialect, competing standards and complexity of operators.

[*1]: Actually the brain sees entire words as symbols and are able to recognize and look-up it’s relevance and meaning almost instantaneously. Whereas non characters like “{” or “}” require the brain to include the characters before and after in order to deduce it’s context before looking it up. In short: The brain reads human words faster than glyphs.

The result of many years of hard work was Pascal, designed to be a better C without the limitations which haunts C to this very day. The results should speak for itself: for 30 years Pascal code has outperformed C in almost every aspect of programming. During the 80’s and 90’s Pascal was the language of choice for game and system developers, especially since Pascal has always supported inline-assembler.

Just like C, Pascal has been uses to create operative systems from scratch. Recognized by all for its simplicity, its rigid structure, it’s efficiency and most importantly: it’s productivity!

Let’s go back to the beginning

Before we look at object pascal today, let’s go back to the early days. Back when there were at least 8 different C compilers (not to mention a few open-source, free compilers available as well) and there really was no control or standard at all.

So, in 1978 Dennis Richie and Brian Kernighan published a book called “The C programming language”. A lot of kids these days seem to believe that this book marks the beginning of C, and that it sort of defines the language from beginning to end. Sadly that is not true, I wish it had been true, but it’s not.

When Dennis and Brian wrote that book the C language was in mayhem. There was no standard at all, nothing to say what was C and what was Basic or BCPL. There was no organization which owned C and with all those different compilers on the market, each of them different, each of them unable or unwilling to support the other — something had to be done.

Hence the book “The C programming language” was released as an attempt to clean up the mess. That meant creating a standard or subset which all C compilers should support – regardless of their peculiarities. As long as every compiler supported the proposed sub-set, they could call themselves “ISO C compatible” and years later “Ansi C compatible”. Sadly this process took many, many years and the ISO standard was not effective until 1982 or thereabouts.

Object Pascal = C++

Like mentioned above Pascal was a project to create a better C. What people don’t seem to get is that pascal is, underneath the syntax, almost identical to C. Most of the improvements were not binary but rather superficial, a more thought out and easy to read syntax, no need for external header files, support for inline assembler, the use of $ rather than 0x for hexadecimal — essentially superficial changes.

So when people thrash talk Pascal or Object Pascal, they can’t possibly know what they are doing. It is a fact that C++ builder and Delphi shares a common core. This is why you can take .obj files compiled with C++ builder and link them straight into a Delphi project. And you can likewise take a Delphi compiled unit and use that in a C++ builder project.

This should give you some sense of what object pascal is capable of. If you have respect for languages like C/C++ then you should also recognize that Delphi and freepascal is equally worthy of the same respect. The only thing separating the two languages are superficial, syntactical differences. Naturally each language has evolved since the 80’s and 90’s and Delphi have many features which C/C++ lacks (and visa versa). But inside the heart of Delphi beats the same engine which powers C++.

Back it up with facts or be silent

“You cant use delphi, thats just .. you cant”

Why? I hear people utter these statements, but I have yet to hear a good reason as to why? Why can I use Visual C++, C++ builder and even Visual Basic (!!!) to write applications but not Delphi? Since I have outlined that Delphi and C++ builder share the same core, under what pretext should Delphi be banned while C++ is allowed? And who in their right mind would allow Visual Basic, which is a language for children, yet ban the most widely used language in the western hemisphere for the past 30 years? Is there an insanity virus going around?

Let’s be honest: all of these statements are of-course rubbish. Java and C# fan-boys will always tell you that their language is the best, and they fight like cats and dogs between themselves too. So when Borland lost the economic fight against Microsoft, they all had a chance to kick Delphi and C++ builder while they were down for the count. But what company  would really stand a chance against Microsoft?

Microsoft is a company so spiteful and egocentric that it created C# when Sun Microsystems refused to give up control over Java. And just look at the damage C# has done to Java in just a couple of years!

Does that mean that Java is “crap”? Does it mean that C# should be allowed while Java should be banned? Or should we allow Visual Basic but refuse to accept Java? Because that’s the kind of insane thinking we are dealing with here.

Of-course A doesnt exclude the use of B. And had Microsoft really gone after Sun with the intent of destroying them, you know just as well as I do that Sun would be dead and buried — and Java along with it.

So before you start thrash-talking Delphi and Borland and Embarcadero, please do yourself the favor of actually knowing what you talk about. Because to people who know several languages, people who were developers 20 and 30 years ago, you sound like a complete moron. Especially when you say that Delphi is old, or Delphi is just “this” or “that” like a child lobbying for his favorite soccer team. At least have the wits to add why you believe Delphi is crap, and then investigate if that notion is fact or fiction.

Did Borland get their asses kicked by Microsoft? Yes they did. Just like Netscape did and thousands of other companies over the years.

Is Delphi dead? Absolutely not! It’s used by thousands of high-end companies on a daily basis all around the world. In fact since Borland sold it’s R&D department to Embarcadero the language has once again caught up with C++, and the user base is growing! It goes without saying that when Microsoft stole the lead developer and inventor of the product, and essentially left Borland to the volves that development stopped for a while. But that was years ago and its ancient history.

And just like C++ compiled Delphi has no dependencies. You don’t need to install a truckload of DLL files to execute your programs. They are native assembly code so they run much faster than Java and C# (roughly 30% faster than C# JIT code). So what makes more sense? Ignoring Delphi and keep using C# for high-priority servers? Or be smart and use Delphi to get that extra speed boost. 30% means a lot when dealing with millions of records per day, yet I see companies falling for the hype and picking C#, only to be haunted by more problems than I care to list.

And you also get to use freepascal absolutely free. You can compile your programs for Linux, Macintosh, Windows — you can target Nintendo, XBox and Playstation. You can target iPhone and Android devices — and even a few novel operating systems like QNX, Embedded DOS, AROS, MorphOS and Amiga OS (although dont hold your breath if you plan to make money on Amiga these days).

And then there is experience and coverage. It goes without saying that a language which spans back to the early days of C++ has gone through some vigorous tests and stood the test of time! Delphi as a product comes with a broad background and public library of code for almost everything under the sun. And the Delphi codebase is still growing!  Why should your company pay millions to hire people to re-invent the wheel in Java or C# when you can get an experienced Delphi developer to deliver faster solutions using code which has been running successfully for a decade?

Think about that for a while before you give in to weak-minded mantra of “mine is better than yours”, because odds are your language of preference can quickly find itself in a similar state a few years from now. Besides — a programming language represents a school of thought, and just look at the hundreds of thousands of software titles created using Delphi. Look at the millions of software problems Delphi has helped solve! To deny that is to quite frankly be thoughtless. Wisdom and knowledge is valid, no matter what language is used to express it.

Smart Mobile Studio Workshop

May 22, 2015 3 comments

I was recently presented with the notion of holding a Smart Mobile Studio workshop. Essentially offer my services to companies who want to get up to date with cloud and mobile development using Smart Mobile Studio.

Want to learn the secrets of Smart Mobile Studio? This is your ticket

Want to learn the secrets of Smart Mobile Studio? This is your ticket

Initially this idea seemed alien to me; I don’t have a problem speaking to a crowd or anything, but I must admit that I have little experience holding workshops. Luckily this notion coincides with my book writing, meaning that I have already started to structure a curriculum for learning Smart Pascal; moving from basic dialectic advantages to writing full speed database driven async cloud services.

I have concluded that my book will actually be a series of smaller books, each dealing in-depth with the topic. There is simply to many facets in Smart Pascal to cover it all in a single chapter. Things like cloud-service programming contains so much potential and so many intricate topics that it deserves to be a small book on its own.

But when it comes to the workshop, the idea has grown on me. Because another aspect of this great idea is to demonstrate just how much object pascal can offer a business (!). Smart Pascal is not just about mobile phones, it’s evolved to be much more – just as JavaScript has evolved to be much more as well.

Below I have written down some of the segments I intend to use in my workshop. It will be a tight schedule, starting at 09:00 and finishing off at around 16:30 (with 30 minutes lunch break at 11:30-12:00). At the end of the workshop tasks for each segment is handed out, you can pick the one you find most interesting. I have dedicated 2 hours for individual work. Each member is expected to bring a laptop with at least Windows XP installed. A copy of Smart Mobile Studio Enterprise is given to each attendant.

Creating your business around object pascal

In modern computing the choices are often bound to the limitations of your language. For instance PHP users tend to stick with Apache (but php runs fine on IIS, just saying), Java programmers use Tomcat or similar, JavaScript programmers use nodeJS or a derived version of this– and users tend to go with IIS even thought it runs fine on Apache with mono.

But what about object pascal programmers? What are our options to match the performance, the elegance and the integration that other languages enjoy?

In this part of the workshop I will introduce you to DWScript HTTP server, which is a phenomenal piece of software designed specifically for object pascal based businesses. When it comes to speed and efficiency it’s right up there with the best of them, but it contains probably more exciting features than all of the aforementioned languages combined.

  • Full support for Object Pascal server-side
  • Full support for Object Pascal client side (using Smart Mobile Studio compiler)
  • Built-in support for all major databases
  • Easy authentication mechanism
  • Support for HTTPS through SSL library files (.dll’s)
  • CORS management
  • Plenty of internal functionality accessible through scripting

The result is a web infrastructure unlike any other, a modern http solution way beyond nodeJS in pure performance– giving you the power of “Ruby on Rails” with the simplicity of PHP in one kick-ass little package. So for businesses which have their own, physical server in-house, running DWScript HTTP server will be like a breath of fresh air.

In this section I will go through how you can write your back-end software for Smart Mobile Studio projects using the DWScript HTTP Server; We will also look at how object pascal makes HTML templates fun to make, how you can make use of the server even from native Delphi applications, it’s REST capabilities and more.

Cloud computing

Getting the big picture can be hard, especially with so much hype being sold on the concept of cloud. This is where I can help your team cut through the ocean of useless information and focus on solutions. Smart Mobile Studio introduces support for nodeJS programming, which is a cornerstone cloud technology. It is platform independent, hardware independent and extremely resource efficient.

Where DWScript HTTP server above represents a native object pascal server which requires a virtual-server host to run, nodeJS means that you can make use of inexpensive hosting solutions. NodeJS is the same on both Windows and Linux, which is also what the cloud is all about: hardware abstraction.

Smart Mobile Studio ships with a nodeJS project type. This project is fairly low-level, exposing the core node server API directly. To leverage this and make it more user-friendly (and feature rich), I have built a very powerful service layer on top of this low-level stack. This means you can now write high-speed, fully scalable services, much like a win32 service or a Linux daemon, that lives and runs completely in the cloud.

I will teach you how to design your services to be scalable, movable and CPU efficient. Scaling is extremely important, especially for businesses that conform to seasons. Businesses like sports-ticket services is a good example. During the high-season their processing requirements can shoot from 40000 to 1000000 over night.

Well with Smart Services that’s not a problem. Just clone X number of instances horizontally of the service and setup a round-robin dispatcher as the entry-point. Scaling your service to go from 100 tickets to handling payloads of 1000000 tickets is no longer a matter throwing more iron on the problem; these days you just select the number of clones you want and click apply.

Writing mobile applications

This is an area which Smart Mobile Studio excels, and in fact it was written to be an alternative to native solutions (mono, delphi, xcode and more). I can teach your team how to write code that behaves identical on all platforms (Android, iOS, Blackberry and Microsoft), and last but not least I will teach you how to tap into the hidden sides of Phonegap, like how to control bluetooth, pre-allocating your database, protecting your files and much, much more.

Focus of this segment is on application architecture, the Smart display organization, how best to initialize your database for data storage on the device – and last but not least, caching, memory and streams.

Note: Smart Mobile Studio recently introduced support for streams, raw memory allocation and intrinsic datatype conversion. This is unheard of in other solutions. Not even typescript have ventured that far into the secrets of JavaScript. I will guide you through the differences (for those coming from a Delphi or FPC background) in how memory is handled.

If you want to write JavaScript which runs lightning fast, which behaves like native code and which does stuff most JavaScript programmers only dream of — then this segment is for you.

Writing custom controls

Writing your own controls should be a fun and pleasant experience. Focus should be on what you want to achieve, not how you can force the RTL to behave in a predictable manner. If you have ever written advanced user-controls for then you know exactly how little fun this can be.

I can guide you through the RTL step by step, explain the methods you need to override and why. I will go through the inheritance layers from TW3TagObject which creates an HTML element — all the way up to TW3CustomControl which represents a complete, blank user-control with supports for everything.

Working with JavaScript and TypeScript

With the basic understanding of what Smart Mobile Studio does and how the RTL interacts with the document object model, getting to grips with third-party libraries is suddenly fun.

In this final part of the work-shop we go through the basics, from writing raw JavaScript in ASM sections, to writing shadow classes to match externally defined JavaScript.

We will also have a look at typescript and I will teach you how to import typescript controls and convert them to Smart Pascal units. This way you get access to thousands of Typescript user-controls and libraries — all of them usable in your Smart Projects.

Hosting the workshop

If you want to bring your team up to speed with the above topics you can register to host my workshop. I require a 50% deposit prior to leaving Norway, to cover flight and housing accommodations. The rest is expected to be payed on the same day as the event takes place.

Once there I will travel to your company or selected location and hold the workshop. The workshop should be set to start at around 09:00 and end at 17:00. It is a full day workshop with two hours dedicated for programming where I am 100% available for questions, help and guidance. The rest of the day is a thorough and in-depth look at Smart Mobile Studio, the RTL, how applications work – followed by practical segments on each technology: using DWScript HTTP to host Smart applications, writing mobile applications, application architecture, Phonegap, working with databases and last but not least — nodeJS service programming).