Archive for September 23, 2014

Converting QTX Pascal to FreePascal/Lazarus

September 23, 2014 1 comment

As you may remember, I run a second website for Quartex Pascal, a research IDE for custom compiler technology. Aiming first and foremost to be the object-pascal equivalent of Eclipse. In many ways QTX continues where Smart Mobile Studio ends. Smart Mobile Studio targets HTML5 exclusively – aiming to be the best Object Pascal to JavaScript compiler on the marked — but Quartex Pascal is a very different beast all together.

The QTX IDE has so far been written in vanilla Delphi XE2 and XE3. It uses plain generics and is otherwise without external dependencies. The editor functionality is provided by a forked version of SynEdit, and as of writing the DWScript engine is the primary code generator framework. But depending on how portable DWScript is (a port of DWScript is reported to be in circulation, but if it supports the code-generator framework added by Eric Grange is unknown at this point) that will probably change.

There is also a secondary code generator framework being written for it, which uses Castalia for parsing and building the AST (abstract symbol tree). It is also capable of parsing visual basic .net (OOP, rule based parsers are very easy to write using my framework). The parser/tokenizer constructs an AST using an intermediate language format, which in turn can be stored as plain XML. This is quite revolutionary because it means – that turning the intermediate code into “real” code is now a matter of XML transformation, which is an off-the-shelf technology tried and tested by time. Ultimately, QTX may use the freepascal universal compiler itself to build “real” applications, or custom code generators – targeting mono C#, GCC or any other native compiler available on a target system.

Porting to freepascal

In order to support more platforms I have decided to port my work wholeheartedly to freepascal. This does not mean that Windows wont be supported anymore, or that I’m abandoning ship – far from it; it means that QTX will eventually be available for Windows, OS X, Linux, Amiga OS and MorphOS to name a few.

I will no doubt continue to work with Delphi for a long time, but I must admit that I am beginning to phase out Embarcadero from my toolkit, in favour of FreePascal, JavaScript and C#. Delphi’s pricing has become ridicules, the generated code is not what it used to be – and since FreePascal and Lazarus have reached a point of quality that is hard to rival — I see no reason continuing to pay top dollar to a company so clearly hostile to Smart Mobile Studio. In fact, they threatened to poll their funding for a “famous Delphi event” if Smart Mobile Studio was allowed to be presented — which is just plain unacceptable behavior for a company like Embarcadero.

If you have never tried Freepascal + Lazarus under Ubuntu, I sincerely urge you to install it. It truly is a fantastic experience!

My desktop right now

My desktop right now


Pascal community project: Thundercloud

September 23, 2014 Leave a comment
The G4 PPC Mac, you must admit that it's a sexy piece of machinery

The G4 PPC Mac, you must admit that it’s a sexy piece of machinery

If you follow my weekly ramblings you know that I’ve spent some time recently with hardware; Recycling older hardware for new and modern purposes to be precise, with focus on PPC Apple Mac’s and older Intel PC’s.

I am still in shock over how people treat these fantastic machines. In one case, a man wanted 300NKR ($25) for a G4 Mac – which is basically the same as saying “if you pick it up, it’s yours”. That very same machine cost roughly 16.000 NKR some 14 years ago. It was my first introduction to Apple products and I used it for music production. So I know a thing or two about using these machines for high performance tasks. I realize of-course that 10-14 years is a long time in the world of computers, but once again it depends on what you actually want to achieve.

I mean, the Raspberry PI is a fun kit to play with, but it’s a three-wheeler for toddler’s compared to a fully specked out G4 or G5 Power Mac.

What’s the point with all that hardware

There is a limit to how many computers you want in your house. My goal of 5 G4 Mac’s and 5 G5 Mac’s inter-linked by optical connections is already raising eyebrows with my girlfriend – so I may have to move my DIY project into the basement (I sort of predicted that *smile*), but the facts of the project is simple:

  • Collect enough CPU power to host a cloud
  • Attempt to interface or write the cloud architecture in FreePascal
  • Use either native OS X or Ubuntu for PPC

Each computer will be designated a specific layer in the personal cloud. For instance, a friend of mine donated his previous gaming PC to the project. But it turned out to be anything but old (well, it’s a few years old but the hardware is en-par with great systems even today). It contains two quad-core 2.4 GHz Intel processors (read: eight cores), two NVida G-Force graphics cards which are inter-connected – and much, much more. In other words, this machine is capable of running Crysis-II on two monitors in full HD without breaking a sweat!

The logical place in a cloud for that piece of hardware is to host the video conversion API. Due to the number of cores and powerful GPU’s this is a natural place in a cloud architecture for this particular system. While the Mac’s are fun and cool – their graphics cards cannot compete against that kind of power on their own. The graphics processing power of that one PC probably equals two or three G5 machines (plain hardware, no extended graphics card).


I feel I have to write a bit regaring Ubuntu. My favorite Linux distro has always been Fedora Linux (a Redhat community project). I don’t know why, but the Fedora visual styles and the way the system is organized appeals to me. Sadly, Fedora has a smaller driver-database than Ubuntu – so getting Fedora to properly recognize my old laptop has been disappointing to say the least. The built-in wifi is not picked up and things like camera and card-reader is rendered useless by Fedora.

The ubuntu desktop

The ubuntu desktop

I decided to try Ubuntu and, as expected, it immediately recognized the hardware and every feature, which was a much more pleasant user-experience. It took roughly one hour to install and update the system, but once Ubuntu was properly setup (which was just a matter of selecting language, creating a user account and setting a few options) I found myself in a polished. modern and capable desktop environment.

As I began to investigate the concept of personal cloud computing I realized that Ubuntu pretty much contains what I was looking for to begin with: namely a fully working personal cloud solution which is free, international and open-source. Ubuntu uses a system called OpenStack, which is a cloud system with support for a variety of programming languages. The typical candidates are of course Java, .Net, Python, nodeJS and more (you know, the typical stuff). But there was no support for Object Pascal – which came as no surprise.

But, if C/C++ can do it — Object Pascal can do it, so I’m hoping to convert the C/C++ headers to FreePascal. As such the native, portable, platform-independent “ThunderCloud” project can become a reality.

What exactly do I mean with “Cloud”?

I must stress that the word “cloud” is being hyped by spin-doctors to mean either very little or very much. But it does not simply mean storage! A lot of people look at the cloud phenomenon as a kind of anonymous giant filing cabinet in the sky, where large and small files are loosely connected to an account, only to magically disappear when you delete something.



The concept of cloud ranges from being able to instantly clone and run full virtual-machine images (think vmware environment), scale them to any number of instances, create virtual networks between these and real computers, manage terrabytes size databases, backup solutions, email, and last but not least – to manage all the software on the images, no matter how complex they might be.

Cloud is also an open, account based, API for the web. Providing a great number of API’s for web developers and native developers over a wide variety of protocols and standards (REST, JSon, XML, noSQL, SQL-Server, mySQL and high-speed file storage). It is this latter part of a personal cloud that I am interested in:

  • User account management
  • Backup services (Mac, Linux and Windows)
  • Media streaming and conversion
  • File management
  • Message handling (email, messenger, sms, IP telephony)

Lazarus on Ubuntu

Say what you will about FPC/Lazarus but it really comes into its own on Linux. Under OS-X Lazarus feels.. well, “out-of-place” is one way to describe it. I havent tested Lazarus under OS-X lately, but when I did use it a couple of years back it was haunted by terrible bugs, strange crashes and inability to adopt the native OS-X theme. Problems made even worse by the fact that Mac’s treat you as a child, hiding and translating filenames en-mass to obscure the fact that you are actually running a Unix system. I pray this has changed by now, and that Lazarus/FPC is just as elegant to use as the Linux version is.

Lazarus on Ubuntu

Lazarus on Ubuntu

I think this was the very first time I have ever installed and started Lazarus without something being wrong. The IDE asked me to locate the source path at one point, but after installing a couple of dependencies from the Ubuntu software app-store Lazarus was content.

With the exception of the “Delphi 1 .. 7” look, which I absolutely hate, Lazarus was a joy to use. And this is the first time I have used such a description on Lazarus, because all my previous experiences with Lazarus (OS-X for the most part) have been tragic and negative.

With the FreePascal compiler supporting multiple targets; you can compile for Linux under Windows, and for Windows under Linux — I am now questioning my use of Windows for personal computing. We do use Windows at work – in fact, it’s a 100% Microsoft business from beginning to end, so I wont be able to dodge Windows licensing there. But what I do with my spare time and what system I use at home, that’s my business and nobody else’s.

I must admit that the only reason I havent switched to Linux before is because I relied on Windows for Delphi programming. But with the quality of Linux now starting to rival Mac’s, and at the same time the quality of Lazarus and FreePascal rivaling that of Delphi — I see little reason in paying Microsoft or Embarcadero for their services anymore.

C# under Ubuntu works like a charm

C# under Ubuntu works like a charm

Linux also runs MonoDevelop, which I use for C# development so once again I question the place for Windows on my personal computer(s). And should I for some reason need to run anything exclusively Microsoft – Wine and VMWare pretty much have it covered. But I cannot for the life of me recall what program should be so important that Linux can’t provide identical or better alternatives. Photoshop has become ridicules over the past 8 years, so I actually prefer “the gimp” for giving the same amount of features at only a fraction of the size and complexity.

Blender runs perfectly under Linux as it does on Windows, same can be said for webkit browsers.

The only program which I presently cannot run or work on, is Smart Mobile Studio (which is a must), so I installed VMWare in order to run my development environments separately (just like I do under OS-X and Windows). I always use VMWare for my Delphi work. Each version of Delphi is installed into its own separate environment, using several different operative systems (Windows XP, Windows Vista, Windows 7 and Windows 8). This makes it easier to work, debug and test. On all platforms.