Archive

Archive for October, 2014

Object Pascal for Raspberry PI

October 29, 2014 5 comments

Recently I visited the Raspberry PI community on Facebook. A great group with many exciting DIY projects of all shapes and sizes. Personally I have bought two Raspberry PI (short: RPI) for various purposes; first of all retro gaming through MAME, and secondly more serious stuff like ownCloud and a private build server for freepascal.

And this is what I want to present to the Raspberry PI community, because the moment I began to talk about pascal – I was met with a near hostile attitude. Both on the official Raspberry PI forum as well as the community driven Facebook group. I found it baffling that someone could get upset, or use hostile language towards someone, over a programming language. I use many languages, including scripting engines, they are all part of my toolbox. But the language I use the most is object pascal, because it’s quite frankly so much better than the alternatives. It is so productive, easy to use and powerful that I almost dont know where to begin.

To Quote Linux Journal:

Lazarus may be the most native cross-platform development environment
running on Linux, Windows and Mac OS X. -Source: Linux Journal

It is such a shame that so many young programmers have been completely hoodwinked by hype and marketing, that they actually believe that a scripting engine such as python, or a bytecode virtual machine like Java, can even be compared to Object Pascal or C/C++. Python and Perl have their uses in the IT landscape and are brilliant dispatch and processing languages, but they are just scripting engines, written in a language which paradoxically is not python or pearl. Which is just one of the ironies we face when discussing what the nature of a “real” programming language is (one of the base criteria is being able to compile itself once the bootstrap is written for a particular platform). Many of these teenage programmers quite frankly don’t understand the distinction and really believe that python is en-par with C++ or object pascal. I’m sorry to burst your bubble, but compared to C++ or Object Pascal — python is nothing but a toy.

Freepascal / Lazarus IDE on Linux

Freepascal / Lazarus IDE on Linux

I have coded my own scripting engines (quite a few actually), so I know perfectly well how much work is involved. Writing a script engine or a compiler is probably one of the most technically challenging topics you can visit; but at the end of the day none of these systems can compare to a real language; neither in depth, technical excellence, dependencies, ease of distribution, speed or possibilities.

And in the case of Object Pascal, the language is no harder to use than python, so the argument of complexity and time-to-market is null and void.

Object Pascal? But isn’t that old and outdated?

Absolutely not. It’s younger than C/C++ and is in constant development, just like C++. In fact, on the Windows platform C++ builder and Delphi are companion products which are binary compatible, meaning that you can share compiled code between them. This is also scheduled for OS X and (in a couple of years) Linux. But freepascal which is the open-source, free alternative to Delphi, have been on these platforms for a long time already.

What you will find if you take the time to investigate Object Pascal, is a well thought-out language which has withstood the test of time, based on a rock-solid software patterns and built around an architecture which is scalable, agile and extremely productive. It is used by millions of individuals around the world on a daily basis, both large and small companies (including several fortune 500 companies) and has a history of delivering stable and robust software.

Skype, Nero Burning Rom, Help and Manual, Dark Basic, Jotta Backup — these are just some of the well known applications out there that are all written in object pascal. So the argument that one guy cam up with, which was “I have never used a single Delphi program ever” is as null and void as the time-to-market rubbish. If you havent tried Skype, or for some reason believe it’s of lesser quality – then you should get your head checked.

Let’s have a look at what object pascal can do for Raspberry PI by establishing a couple of facts.

Get away from platform bound code with Smart Mobile Studio

Compile for HTML5/JavaScript with Smart Mobile Studio!

Raspberry PI is not a power-house of processing power. It has a low-end ARM CPU which, if over-clocked (forced to run faster than it was designed for), delivers roughly the same power as the now 15 year old Pentium III. This means that if you hope to use the Raspberry for anything useful, especially if your target audience are young teenagers or kids eager to learn how to program — you want to chose a language which has the following qualities:

  • Runs fast, a Pentium III needs all the help it can get
  • The less dependencies (libraries) the better
  • Is platform independent
  • Scalable learning curve
  • Support for modern constructs, like generics
  • Has plenty of examples, books, websites and videos going for it
  • Costs little or nothing
  • Provides good income when mastered

In other words, if you want to build applications which executes extremely fast, even faster than C/C++ in some cases, then you could not find a better language for the Raspberry PI than object pascal. The reason for this choice is again backed by facts, not preference:

  • Object Pascal was taught in european schools as late as 2005
    Object Pascal was made with teaching in mind
  • Object Pascal was designed to replace C/C++ and is more mature
  • Object Pascal is much easier to master than C/C++
  • Object Pascal code runs en-par with C/C++ but often surpasses it in terms of speed
  • The generated executable code is highly optimized
  • The generated executable has no dependencies. Everything is compiled to a single binary
  • Full support for external libraries (and also packages)
  • The compiler supports every chipset and operating system on the market (and then some)
  • Both compiler and source RTL is well maintained and up-to-date (VCL, LCL, VJL, FMX)
  • Object Pascal has a thriving community with millions of users
  • There is a proverbial ocean of examples, components and frameworks available
  • Object Pascal supports inline assembler
  • Pascal has delivered commercial applications for 20+ years
  • Pascal has produced brilliant software engineers for 20+ years
  • Delphi programmers are in high demand!

So the reality of it all is, that if someone wanted to create a processing language like python, they would pick a real language to implement it, like C/C++ or object pascal. This is a fundamental difference which is extremely important to understand: Namely that a real language, one which is compiled into executable machine code, cannot be compared to an interpreted script language. It’s like comparing a bicycle to a racing car. It’s two completely different worlds. For instance, how many python compilers have you found that was written in python? Or how many python or pearl runtime environments have you used which surpasses the speed and technical advantages of C++ or Object Pascal? It is a fact, that native executable code will always be faster than interpreted AST (abstract symbol tree) execution, even when JIT technology is involved.

Delphi XE7 supports iOS, Android, Win32, OS X with a variety of project types

Delphi XE7 supports iOS, Android, Win32, OS X with a variety of project types

Resources

There are far to many resources for learning object pascal than can be listed on this website (let alone this article), but if you are interested in having a look, i have provided you with a handful of links below:

If you visit Google Code or SourceForge, search for “Delphi” or “FPC” (freepascal) you will find thousands of big and small projects ready for Download. Everything from operative systems coded from scratch in freepascal or large scale web services to handle thousands of connections, database servers written in Delphi, database engines, games, multimedia — the works.

Oh, and the Raspberry PI disk-image writer for OS X was written in freepascal, you can download that here (much easier than the guide on the official website).

If you are serious about programming, especially on embedded systems, then object pascal is probably the best choice you can make. It’s easier to learn than C/C++, has all the features of C/C++ (with the exception of multiple ancestors. Object Pascal enforces linear inheritance to avoid ambiguity in the VMT [virtual method table] should identical members collide, which is the problem of multiple ancestors for a class), has no dependencies (so your programs dont need a second library file to run), is highly optimized, scales from low-level procedural or assembly-language programming – to high level object orientation; the list goes on.

To install on the PI, simply open terminal and type:

  • sudo apt-get install fpc
  • sudo apt-get install lazarus

As for platform support, you have a lot to choose from. FreePascal provides the following:

  • DOS
  • Windows
  • Linux
  • OS X (Intel, PPC)
  • Classic Mac OS PPC
  • Spark Solaris
  • Amiga (68k, PPC)
  • Aros (intel)
  • MorphOS (PPC)
  • iOS (ARM)
  • Android (ARM)
  • Raspberry PI
  • BeagleBone
  • Nintendo DS
  • Nintendo Wii
  • Playstation
  • .. and more

Happy Raspberry PI coding!

Populate ImageList at runtime

October 28, 2014 2 comments

For some weird and wonderful reason, populating an image-list at runtime is not as straight-forward as I first imagined. If you want to create applications that loads resources on demand from disk (giving the user an option to change your graphics as well) then you really need to push stuff like images out of the main executable.

In my case I’m writing an IDE which is intended to compile with freepascal and Lazarus later on, so I try my best to avoid “Delphi centric” elements (read: components that only exist under Delphi), resource files and hard-coded data. Of which images are the number one enemy.

The problem

You would imagine that just loading a piece of graphics using TPicture, and then drawing it to the canvas of a bitmap – before inserting it into the imagelist, should be enough right? Well almost. The problem with good old TCanvas.draw() is that it could not care less about transparency information. Which is completely lost whenever you turn a TPicture.Graphic into a bitmap.

The solution, having messed around with this for at least 30 minutes, was simple: Use assign when moving the image from TPicture to TBitmap. That preserves the transparency information. Especially for PNG images which can also have an alpha map chunk.

And here is the result after having wasted 30 minutes trying different variations. The AddFromFile() function really should be included in TImageList. I cant imagine why this has not been included by Embarcadero. Either way, I have a clean and solid solution below:

No more "white block background"

No more “white block background”

 The code

Here is the snippet source-code. Simply add it to your toolbox of snippets, or convert to a normal function if you like the old syntax style better.

Note: Remember to set your imagelist to

  • ColorDepth: cd32Bit
  • DrawingStyle: dsTransparent
  • Masked: False
class function TQTXIDETools.LoadImageIntoList(aFileName:String;
          aList:TImageList;
          out aImageIndex:Integer):Boolean;
var
  mImage:   TPicture;
  mBitmap:  TBitmap;
Begin
  result:=False;
  aImageIndex:=-1;
  if aList<>NIl then
  begin
    if FileExists(aFilename,true) then
    begin
      mImage:=TPicture.Create;
      try

        (* Attempt to load image file *)
        try
          mImage.LoadFromFile(aFilename);
        except
          on exception do;
        end;

        (* image successfully loaded? *)
        if (mImage.Width>0)
        and (mImage.Height>0) then
        begin
          (* Draw image to a bitmap *)
          mBitmap:=TBitmap.Create;
          try
            (* copy pixels + transparency info to bitmap *)
            mBitmap.Assign(mImage.Graphic);

            (* Add bitmap to image-list, return index *)
            aImageIndex:=aList.add(mBitmap,NIL);
            result:=true;
          finally
            mBitmap.Free;
          end;
        end;
      finally
        mImage.Free;
      end;
    end;
  end;
end;

Using the code

Using it is simplicity itself. Simply enter the form where you need images loaded, double-click on the “onCreate” event and call this procedure. You will ofcourse need to adapt the code to your own toolkit. I tend to isolate everything in classes, including paths, to make applications as modular and extendable as possible:

Procedure TfrmPreferences.setupImageList;
var
  mAccess:  TIDEAccessManager;
  mIndex: Integer;
Begin
  if ideAccess.getIDEAccess(mAccess) then
  Begin

    (* Load "add" glyph *)
    with mAccess.PathManager do
    if TQTXIDETools.LoadImageIntoList
    (getImagePath('add.png'),imageList1, mIndex) then
    self.acAddPath.ImageIndex:=mIndex;

    (* Load "delete" glyph *)
    with mAccess.PathManager do
    if TQTXIDETools.LoadImageIntoList
    (getImagePath('delete.png'),imageList1, mIndex) then
    self.acDelPath.ImageIndex:=mIndex;
  end;
end;

New Delphi / FPC market, get in early!

October 24, 2014 1 comment

Being able to target and get involved with an operative-system early is imperative for success in the field of software development. The Delphi community knows all about this, being thrown into iOS and Android at the eleventh hour – when the market was fully saturated, leaving Delphi programmers with nearly zero potential for economic advantage.

To make a long story short – those languages which can target a platform early, tend to be the languages that secures a long-standing, solid foothold over the platform. While the iOS and Android train has left the building – and we can now only compete on quality and complexity: there are more operative systems rising which can be potential gold-mines for Delphi and FPC developers.

AROS

You have probably never heard about AROS. It’s not Linux, it’s not Windows, It’s not Unix nor is it based on Spar, be-OS, RISC OS some other esoteric operative system. Aros is a free-standing alternative, open-source and free for use, who’s quality has now reached the point where viable, commercial applications is a reality. It has gain momentum and that’s the perfect time to invest in something..

Aros rocks!

Aros rocks!

Aros was created to be a clone of Amiga OS, which is probably one of the most advanced operative systems the world have ever seen. Many of the features that OS X have added only recently are actually over 20 years old (like inter-process scripting, AREXX in Aros terms) and ran on Amiga workstations and servers years ago.

For those that havent heard about Amiga OS or who just remember it as a multimedia-computer from the late 90’s, Amiga OS in many ways the perfection and blend between Unix and OS/2. It sported a full multitasking desktop 10 years before the PC got Windows, a desktop which is more or less identical to what OS X and Windows have today (20+ years ahead of its time). Amiga OS was wildly popular in Europe during the 80’s and 90’s, but somehow it never got a foothold in the united states (with exception of high-end movie production companies), mainly due to the onslaught of Atari, Apple and Microsoft marketing.

Amiga OS 4, not exactly graphically impaired

Amiga OS 4, not exactly graphically impaired

The Amiga went out of commercial use around 1996, but in Europe the platform is still in use by enthusiasts. Which is ultimately where AROS for x86 and ARM comes in. There is still a very evolved, very modern version of the “official” Amiga OS, which you find here: http://www.amigaos.net/, but this article focuses on the X86 and ARM ready open-source clone: Aros.

Present state

As of writing, freepascal and Lazarus is being ported to Aros. This is fantastic news because it means that object pascal is finally getting into a near-future-economic platform early. The operative system has been using the linux kernel for a few of years (in order to boot up properly and take care of memory models and various other “tidbits” we take for granted), but now it finally has it’s own sub-systems and stands on it’s own feet.

It’s pretty awesome considering the amount of work involved!

Uses for Aros

If you feel Linux is to complicated to deploy in a work situation, and Windows and OS X to expensive — then Aros might be for you. It was originally written for x86 but has recently been ported to ARM (with a PPC port also being worked on). This means that the OS can run on anything from mobile devices to high-end servers. It is a perfect candidate for embedded systems.

Aros is more than a capable desktop environment

Aros is more than a capable desktop environment

Aros follows in the proud Amiga tradition of “performing miracles with extremely few resources”, meaning that the operative system itself requires very little RAM and disk space compared to Windows or OS X. It will happily run full-speed with 1 gigabyte of memory and 400 megabytes of disk space (and smaller for that matter).

It’s also modular, which makes it an exceptionally good embedded operative system, along the lines of QNX Real-Time OS, which costs a truckload of money. Aros on the other hand is open-source and free (!)

Getting creative

So if you feel like getting into the operative-system early, porting over software from Delphi to Aros Exec, now is the time to find out what it’s all about!

Other markets

As you have probably heard, the Mozilla foundation (the guys behind firefox) has ventured into the mobile operative system market, and FireFox OS is becoming a reality.

One of the great things about FireFox OS  (FFOS) is that all the applications are JavaScript based.

This may not sound like good news but it is, because it means you can use your Delphi and FPC skills with Smart Mobile Studio and create complex and solid applications immediately. You will also have a distinct edge in how SMS gives you true OOP, while native JS developers are stuck with ordinary prototypes.

Mozilla FireFox OS

Mozilla FireFox OS

Links

Raspberry PI broken freepascal packages

October 24, 2014 Leave a comment

For some odd reason, installing freepascal + lazarus on Raspberry PI is no longer possible. There is something wrong with the dependency chain inside the repository.

Raspberry PI dependency error

Raspberry PI dependency error

Hopefully someone will fix this ASAP

Blitzbasic goes open-source

October 20, 2014 2 comments

It’s probably old news to some, but I just noticed that BlitzPlus and Monkey X, two commercial grade compiler systems from Mark Sibly and Blitz Research, was committed into open-source over at github.

Blitzbasic comes in many versions, both 2D and 3D

Blitzbasic comes in many variations

Blitzbasic produces extremely fast code, tiny executables – and have been knocking out commercial games since the early 90’s. It was completely re-written for the PC some years back, is well maintained and up to date, and was in my view worth it’s initial $99 pricetag. So getting access to the underlying compiler and RTL source for free is a fantastic opportunity to learn from a master.

About BlitzBasic

BlitzBasic was initially released for the 16 bit Amiga home computer, following the great success of an older Basic interpreter “Amos Basic”, written by Francois Lionet. Unlike Amos Basic, Blitzbasic featured (and still do for x86) inline-assembler and was a real compiler system. Blitzbasic was responsible for successful games such as Worms and Hardball. Worms is still selling on mobile and console platforms to this day – and is one of the best selling games in computer history.

Worms was created in BlitzBasic, its one of the best selling games of all time

Worms was created in BlitzBasic, its one of the best selling games of all time

But Mark Sibly did not stop there. With the death of the Amiga platform he completely re-wrote the entire codebase in C++ for Windows, and have over the years maintained and made a living from his language. Blitzbasic is no “light weight” basic lingo, but by far the most advanced basic dialect out there. It features inline machine-code, templates, classes and much, much more.

Monkey X

Mark’s latest language, called “Monkey X” takes the whole Blitzbasic philosophy one step further. Monkey X is platform independent and generates code for XBOX, Playstation, Windows, iOS and OS X. You can also compile for HTML5 which is a great bonus for game and multimedia developers.

Monkey X is a transcoding compiler, much like Smart Mobile Studio

Monkey X is a transcoding compiler, much like Smart Mobile Studio

Mark has also decided to open-source Monkey X as well. From what the blog rumors say, Mark has worked to much for to long and wanted a clean break from computing – resulting in open sourcing his whole portfolio. I sincerely wish Mark the very best and that his health improves, he has been an inspiration to a whole generation of programmers and was one of the people that inspired me to become a programmer in my teens.

Blitzbasic and Monkey X are great products, both represents the most advanced basic dialects (although Monkey is C/JavaScript like in syntax) on the market. You are not limited to games only but can use Blitz and Monkey to generate serious platform independent software that runs native. Monkey uses transcoding, much like smart mobile studio, but targets C++, C#, Flash and other languages.

Verdict

If you have even the slightest interest in compilers or how to make your own programming language, or indeed need a good platform to realize your game – then this should be considered winning the jackpot.

Head over to github and fork this puppy: https://github.com/blitz-research/blitzplus

 

Resurrecting the Amiga home computer

October 20, 2014 7 comments

I know. This is a Delphi blog and lately I have been so far off topic that you are excused for thinking I’ve gone bad. But rest assured that all my marbles are accounted for – I have simply done what all good programmers do from time to time and explored new things.

Firefox os, Javascript is coming..

Firefox OS, Javascript is coming..

For the past 3 months I have invested time in learning Linux, which is becoming more and more important these days, no matter if you are a programmer or not. And I can safely say that the time spent hacking away at Ubuntu has opened my eyes to new potential markets for both Delphi, Smart Mobile Studio and FreePascal.

Load balancers are on my list now, although with C# and the mono framework in mind. I will be working on load balancing code quite soon in C# so absorbing the market and the various models out there is important.

And last but not least, alternative operative systems. You may not be interested, but HTML5 and JavaScript is growing increasingly popular. So much so that hardware vendors are adding JS interfaces for their products. This means that you now have micro-controllers that eat, execute and run JavaScript directly (V8 Built in probably).

I have also spent some time in the past, looking at technology that basically got me where I am today. I was lucky enough to grow up with almost exclusively Commodore gear (Vic 20, Commodore 64 and Amiga), in a country which besides Sweden and the UK was the Amiga nation supreme, with all the big hacker groups neatly strung like pearls across our Norwegian coastline.

What caught my eye

Unless you have been living in a cave the past 5 years you have probably heard of the Raspberry PI mini computer. It’s a tiny little gadget, about the size of a credit card, and it costs round-about $35 (!) And if you have been following that, then you also know that it’s a fun piece of hardware which can be picked up anywhere, is powerful enough to run Linux (although barely) and is being used for everything under the sun. People make arcade machines with it (Mame is a fantastic emulator), they build their own Nintendo systems with it (Nes, SNES); the more technical savvy users even control their houses with it, stuff like heat regulation, lights and things like that.

Recently Acorn Computers, which was a competitor to the Amiga back in the 90’s (their Falcon model came close to the HW specs of the A1200 towards the end, but never sold since the Amiga dominated Europe) released RISC OS into the public domain. Or open-source, I havent looked at the details yet — but you can download and use it on the RPI for free.

RISC OS in all its.. eh, glory

RISC OS in all its.. eh, glory

What are the odds of anyone using RISC OS in 2014? It’s very different from anything we got on the market, but oddly enough not that different. The reason people use it with the RPI is naturally because it’s small, compact and runs on the hardware. It’s a strange little OS, sort of a mix between Linux and Windows (if you strip them down to the bare-bones). It’s focus on Basic and Machine-code sort of reminds me of the Commodore 64. Remember how we used to buy magazines with cheat codes, then spent an hour typing in all those poke and peek commands? Well that’s the feeling I get when playing around with RISC OS.

Thinking about the Amiga

For roughly 20 years now people have been (well, some people) eagerly anticipating the return of the Amiga. I have pretty much made my reasoning clear on the subject in earlier posts – that I hardly think the Amiga will ever come back, quite simply because it doesnt serve any purpose in mainstream computing.

The only possible way the Amiga could once again become popular, is if the platform did some task exceptionally good – much better than Linux and Windows do. And let’s face it, that’s not gonna happen. Going face to face with Microsoft and millions of Linux companies at this point in time would be suicide. And no investor in his right mind would come near such a project.

Sexy, compact and extremely fast! Amiga OS

Sexy, compact and extremely fast! Amiga

But! There are a few facts of life we should remember. First of all, competing with free is hard to do. This is why Linux (almost forgot: GNU/Linux) has even evolved. People use Linux because it’s free and they can shape it into whatever they want. Linux has been lurking in the shadows for ages it seems, doomed to be a “server OS”, but that is starting to change – or has changed in recent times. It’s now a very capable, safe and enjoyable platform with thousands of easy to use titles. It’s actually easier to install and un-install programs for Linux than it is for Windows. Which has taken Linux a long, long time to achieve.

Competing with “almost free” is even better, because then at least it has value. It’s a paradox I know, but if something costs $3 it’s statistically more likely to be successful than if it’s 100% free. What I have in mind here is that if you could get an Amiga system for, oh, say $80 or $100 (the price of a Raspberry PI + Amiga OS) that is a pretty good deal!

Going back on topic — what about the Amiga? Well, the trick of surviving is to avoid bigger fish. It’s basically what Steve Jobs did when he returned to Apple. Instead of going into the ring with Microsoft, which would have ended in Apple getting beaten to death — he took the fight to new markets. The IPod became the money-cow for Apple in combination with music sales, followed by a series of accessories which all provided Apple with very welcome funds.

These funds were used to launch the new Macintosh computers, but here Steve made a genius move. Everyone was expecting Apple to once again taking on Microsoft, but instead he competed exclusively in the areas where the PC was weak: namely machine design and an aesthetically pleasing desktop experience! Apple simply ignored Microsoft and made sure their “platform”, which is iPod, iPad and iMac connected together and worked out of the box. It should also be mentioned that Microsoft owns large portions of Apple, so the whole “mac vs. pc” argument is not even worth going into (although some people do, even to this day).

Amiga on ARM

So, what could the Amiga compete with today? Well, if the owners of Amiga OS were to even entertain pushing it, it would have to be for the Raspberry PI. It would compete primarily on the level of size, speed and resource requirements. In many ways it would be the perfect embedded platform, since 90% of all embedded boards are dedicated to one task only (offshore and military applications are extremely lucrative). It would also be a nice excuse for lack of protected memory which would buy them some time to get implement that. So that’s one market Amiga OS could indeed enter. It’s competitors would be much larger, more expensive systems like QNX real-time OS, which also needs 4-5 times as much CPU power just to start. But Amiga OS would have to be partly re-written and the old custom-chips would now be replaced by code. The blitter and sound chips we all loved so much could still be used, but they would be implemented as software mapped to the GPU chip of the RPI.

Raspberry PI, Model B

Raspberry PI, Model B

The Amiga OS, even with a layer of 68K legacy emulation, would – if compiled to run on ARM, literally run rings around Linux, RISC OS and whatever else is presently there. The RPI is capable of emulating an A500+ more or less perfectly using UAE (running on top of Linux) – so you can only imagine what speed a native ARM version would achieve.

Another factor is resources. Amiga OS runs happily with less than 4 megabyte of RAM – the low-end Raspberry PI ships with 512 megabytes, and the current model B with 1 gigabyte. The low-end CPU is a 700Mhz ARM processor, with the high-end version running at 1Ghz. Both can be over-clocked to respectively 1Ghz and 1.3Ghz without problems, although a cheap $3 heat-sink may be in order.

But the best factor is undoubtably production costs. Raspberry PI is an off-the-shelves product. Its extremely cheap, readily available and has a dedicated GPU. With the blitter software making use of said GPU (as well as the desktop and OS in general), you would no doubt have the fastest Amiga ever made. So the cost of producing the machine would be limited to software development, not hardware production. Adding a case and bluetooth keyboard/mouse is something even mom can do.

People would pick it up not because it’s a PC or a Mac alternative, but exactly because it’s not an alternative. Parents dont mind spending $35 on a system which, with a bit of online torrenting, has thousands of classic games to run. Add a joystick and your kids have more games to play than they will ever have time to complete.

Despite it’s size, small form-factor and processor, the Raspberry PI is still a very good entry-level computer for kids, but Linux and RISC OS is quite frankly to bloated for the hardware. What it needs is a slim and fast OS that achieves miracles with very little. The RPI’s biggest problems is software, because “modern” software tends to be compiled with a completely different philosophy. From what little I remember of the 90’s, Hyperion (or some other company) did upgrade Amiga OS to more streamlined C/C++ (read: more portable). So it’s not an impossible endeavor.

I sincerely hope “someone” out there is reading this (whomever owns the rights to Amiga OS) because it’s probably the best and only situation this decade for a return on your investment.

  • Nearly non-existent hardware production cost
  • Time to refurbish the OS for pure ARM (can run on any arm platform)
  • Legend and legacy support market
  • Free marketing access via the RPI community (schools, teenagers and adult users)
  • Huge potential as an embedded platform

Well, that’s what I think

Build your own Delphi based operative system

October 19, 2014 8 comments

Those of us that grew up in the hacker community of the 80’s and 90’s have a different mindset from kids today. It’s sort of built into us that if we put our minds to it — we can do anything. Any system can be hacked, modified, built. Why? Because we can that’s why 🙂

I still remember getting so angry at loosing in Soccer Manager that I got my drill, black & decker’ed my way through the F1 key, then soldered it shut in order to win the tournament! Yeah we Norwegians have stubbornness issues. But on the positive side — we get stuff done!

Operative systems

While games was my dream job as a teenager, another side of my aspirations were building my own programming language (sort of did that) and my own operative system. Not a system like Linux or Windows, but rather just my own desktop environment. Back then the Amiga had it’s kernel on ROM’s, so the only thing that loaded when you booted the machine were drivers and the desktop environment. So naturally everyone wanted to pimp or replace that with their own.

Xamarin rewrote Android to C#

Xamarin rewrote Android to C#

Well, the Amiga is long gone and buried (sadly) and exists now only in the virtual world of emulation. But would it be possible to create your own, pascal driven desktop environment for x86 computers?

Now if you are thinking about a fully-fledged operative system, with it’s own hardware drivers (this is really the biggest challenge, because there are so many configurations out there), kernel and software — then I would say no. Not because it’s impossible — but rather improbable that anyone would throw away the amount of time and money to do so. Having said that several operative systems have been written in freepascal, the latest endeavor being FPOS. But as you probably imagine, it takes a long time to truly build an OS from scratch.

But, creating your own environment which is 100% controlled by your code — that is more than possible. It’s already been done by several companies in the field of backup-software and embedded NAS systems.

Xamarin, the guys behind mono even took the time to re-write Android in .net a while back, called XOBOTOS. You can check that out on GitHub here: https://github.com/xamarin/XobotOS

Delphi and DOS

You probably think that Delphi is only for the desktop. Well, that’s how it was designed. But the code generator inside Delphi produces ordinary, bog standard machine code; meaning that it only does what it’s designed to do. Namely to produce machine code that the x86 processor can execute.

What we need is something which emulates the absolute bare-bone functionality of Windows. I am talking about the true low-level stuff like allocMem(), the ability to read mouse co-ordinates, keyboard input and so on.

Delphi for DOS, works like a charm

Delphi for DOS, works like a charm

Well it just so happens that such a system exists. It’s called WDOSX and was primarily adapted for Delphi 5 and 7. What it does is take your ordinary Delphi .exe file and patch it to use the WDOSX extender. This basically turns your Windows program into a DOS program. The extender emulates the windows functions (memory allocation and so on) to work with DOS rather than WinAPI — effectively fooling your application into thinking it’s running under Windows.

Limitations

The limitations are obvious: no windowing toolkit, no threading and pretty much what you would expect from a DOS program. On the positive side though – you do get a flat memory-model, so if you have 16 gigabytes of ram, you will be able to use it as normal. No “high” memory and “low” memory, or 64k segments to worry about.

You will also enjoy a very VCL like RTL, namely CLX (Kylix). DWPL patches the CLX source-code so it works under DOS. It especially patches client/server units, so when it comes to networking you will be surprised just how powerful it is.

Add full-screen access, mouse, sound and complete access to the disk and you have probably the most powerful “DOS” development platform ever created. CLX is the open-source port of VCL to Linux (read: platform independent). A variation of CLX is used by Lazarus, so it’s pretty solid stuff.

Kylix, a project years ahead of its time

Kylix, a project years ahead of its time

Applications

It wont take long before you ask “but what about applications?”. Well you are in luck, because Delphi has the best scripting engines in the world. You could use RemObjects’s script to build applications, or what about DWScript (which is much better)? I seem to remember that the latest (read: last) WDOSX extender included support for blue-threads (so there is a TThread class in there somewhere). With a bit of work you could run several DWScript based applications at once.

And the speed would be phenomenal. Because your application would in fact be the only “real” application running on the entire machine. With exception of freedos and 2-3 drivers naturally.

A NAS server written in Delphi for embedded platforms? Yes you can!

Graphics

The Delphi package to use WDOSX (DWPL) is actually very good! It maps the VESA screen buffer into a TScreen class, making it a snap to take full control of the computer’s graphics. The downside is, naturally, that you wont get access to any GPU functionality since VESA means you use the processor to draw everything. Which is much slower.

It also uses FreeType, the same font renderer used by OS X and Linux to draw text on screen. This turns your home-brew OS into a more polished looking system.

Networking

Believe it or not but that is also possible. It requires a network card with a packet driver for DOS. Those are rare today, but not as rare as you might think – because DOS is still the #1 system for offshore embedded systems and military boards. Strange as it may sound DOS is alive and kicking to this day.

Libraries

Believe it or not but WDOSX supports the loadlibrary() api. Meaning that you can load and use DLL files (as long as these libraries dont collide with the limitations). That is pretty cool. You could in effect isolate common functionality in libraries for easier maintenance — or define your .exe format as DLL’s (so any applications for your desktop would ship in the form of DLL files, since that is the way to get executable code loaded).

FreeDOS

You still need a system that does all the dirty-work, talking to hardware interrupts and taking care of device IO. Well this is where freeDOS, the open-source and free DOS clone comes in.

So your system would in effect look like this:

  • FreeDOS
  • Mouse driver
  • Graphics driver
  • Network packet driver
  • WDOSX
  • Your application

Desktop environment

Creating your own desktop is, well, not hard but time-consuming. A window is basically just a graphical region with various options for how it’s displayed, positioned and drawn. It’s more complex but once you have the basics implemented, it’s quite fun to program 🙂

Possible markets

The only viable, economic market i can think of is that of backup and disk-utilities. In fact, most of the recovery software that boots off a USB or cd-rom is based on DOS. People use freeDOS for a lot of things, but very few have used Delphi for this. It’s primarily the domain of the now discontinued C++ Builder.

But yes, you could with some effort create a fully independent desktop environment written completely in Delphi. I have also seen full kick-start (boot code) written in freepascal (believe it or not).

But for sake of sanity I would stick to creating a desktop-system designed for a specific task, like back/restore of a disk (you have raw access to sectors so it’s a perfect situation).

A possibly second market is embedded systems dealing with server’s. Dedicated NAS servers are cheap these days, but you can actually build your own. It completely depends on your motivation (fun, money or hobby).

Either way — if someone took the time to work on this for a few months, Delphi would have a pretty good setup for creating embedded applications. The embedded market is very lucrative, especially the companies that target the oil industry.

FreePascal

I actually havent tested WDOSX with freepascal, but I suspect it will work. I did a quick google and found that WDOSX is indeed mentioned under supported systems (Ubuntu man pages).

If the idea of writing your own desktop-environment for embedded systems tickle’s your fancy, then why not investigate 🙂

Building a modern Amiga, notes and ideas

October 18, 2014 11 comments

Ordinarily this is not a post you would find on my extremely dedicated Delphi and Smart Pascal blog, but readers will no doubt have noticed my love for the old Amiga home computer. A lot of my effect code have comments hinting to their ancient Amiga roots, and I have made no secret that I think it was a great tragedy that the Amiga went under (especially since those that buried it were board-members with no real passion for the product).

Sexy, compact and extremely fast! Amiga OS

Sexy, compact and extremely fast! AROS

But all is not lost, in fact – while a lot of Amiga boards are filled with a rather thick atmosphere of defeat and memories of glories long gone, the truth of the matter is that there has never been a better time to be an Amiga user! Never since you could buy a real Amiga has there been more options for people to chose from, and after nearly 30 years that speaks volumes about the platform.

UAE (universal Amiga emulator) is a fantastic piece of software engineering. It exists today in many forks and flavors (a “fork” is when a programmer clones the code, which is called a branch, and starts working on it. The process of cloning is called “fork-ing”) on just about every possible platform out there. This means that you can now turn almost any PC, especially older PC’s, into a fully fledged Amiga. In fact UAE not only runs on x86 based machines, but ARM and PPC chipset’s as well. So if you have an old G4 or G5 Mac in the attic – why not give it a new purpose as an Amiga?

Now I know what you are thinking: That’s not really an Amiga is it!

Well, that is of-course true in the literal sense, but while I could spend a few hours digging into the philosophy of what an operative system represents, or if you truly are you since the cells in your body change every 8 years or so –It would be rather pointless. Instead, I would rather spend my time looking closer at what I can do, and what my options are! In other words: what can we do to build a modern Amiga through emulation?

Options for building an Amiga

I wrote an article about how I used a humble Raspberry PI to fully emulate an Amiga, booting into UAE from linux automatically (so no Linux login-prompt. It boots straight into Workbench). Using off-the-shelf battery packs I even made it portable with 6 hours game-time without a power supply!

So the Raspberry PI is one way of going about getting a cheap Amiga. But as many people have commented – you can’t emulate an A1200 since the RPI (Raspberry PI) is not powerful enough to deal with AGA copper code. Im not even sure AGA is included in the UAE4All code (I havent looked at it) to be honest.

Also, I havent touched an Amiga since 1995 so the fact that I managed to get the system booting on a Raspberry PI after fiddling with it for less than an hour – is nothing short of a miracle in my book. It was almost an emotional experience, sitting in my living-room testing rocket ranger at age 41 (had the house to myself that weekend). That was the first Amiga game I bought as a kid and it released an avalanche of happy childhood memories.

I sincerely doubt PC owners feel the same about that 386 DX 1 they used to own 🙂

The power of freeDOS

Right. While using a Raspberry PI for your Amiga emulation is a good option, it can be a hassle to setup correctly (as many have reported). I am no Linux guru so I suspect I got lucky. Thankfully I have gotten some help after that, to make a boot sequence which is safer and valid (hope to upload a disk image when version 2 is done).

The second Amiga option is to buy a dedicated PC and install freeDOS + UAE, that is probably the fastest UAE you will ever get your hands on, since the CPU will be 90% dedicated to UAE itself. You can read more about dosUAE here. But keep in mind that this is DOS, so dont expect a codebase updated recently. But it works, no doubt about that.

DOS UAE is old but cool

DOS UAE is old but cool

The downside with regards to DOS, is that unless you have drivers for your graphics card (and a decent packet-driver for your network adapter, if UAE for DOS even supports that?) – then it wont be usable for much more than playing games. Packet drivers and “modern” dos software for new hardware is primarily the domain of embedded boards and custom designs (read: offshore, oil industry and military systems). But if you have an older PC with networking and graphics card setup correctly — why not give it a try?

The power of Linux

The same formula likewise works for a dedicated Linux box – which is a much better option than DOS since it eliminates the driver problem off the bat. This is the option I would use, because if you boot from Linux you have the benefit of hardware support. Like mention in my previous article, Ubuntu has roughly 3 times as many drivers than other distros due to the fact that it’s funded. The owner of Ubuntu has thrown massive amounts of money on driver development over the years because he knew that drivers were the key to a successful desktop operative system. So if you want a fast Amiga (as fast as Linux can push UAE) with the best possible support for fresh modern hardware (thinking especially about graphics and GPU support here) then Ubuntu Linux is as good as it gets.

The power of Windows XP

If you are going to dedicate a computer to your Amiga resurrection project, then a very fast option (probably faster than Linux and less hassle than DOS) is to install Windows XP. If you have an old XP machine you no longer use (especially if already has drivers working and is ready for use) this will have a leg up on DOS and is easier than Linux. Depending on your Linux skills naturally.

For casual gaming and retro coding

For casual gaming and retro coding

Windows XP is easy to modify to your own diabolical ends, like altering the boot-image, no login prompt – and putting UAE in the startup folder. That is basically all you need to do for your Amiga-XP-Box.

Oh and you get the benefit of using hard-disk images (or why not dedicate a whole partition for your desktop?).

The power of thin clients

This is a great option that is both non-expensive and clever. Thin clients are mini pc’s that were built to only display programs that execute on the server. Even today many TC’s ship with Windows XP embedded. A thin client is “bare-bone” with little or no disk and RAM in the 1 – 16 GB range. More than enough for your Amiga (the Amiga can do wonders with 2 megabyte, so 1024 times that is practically nerdvana). And what you do is the exact same as you would do for the dedicated XP box: You alter the boot process and fire up UAE immediately.

More than enough for Amiga emulation

TC’s — More than enough for Amiga emulation

Depending on the model it will be roughly the speed of an A4000 060 (or so I’ve heard, I have not tried this myself). I highly doubt older models can reach anything close to a 68060 processor, but state of the art TC’s might. It’s impressive how much CPU power they cram into small gadgets these days. My phone probably have more raw power than a pimped up Amiga 1200 had. But it’s how power is used that matters, and no modern device comes with software as ingeniously designed as Amiga OS. It runs on air and tears of ducklings.. It’s a work of art.

Just to make my point I did a quick visit to the most used Norwegian second-hand online marketplace FINN.NO and I found a guy selling 6 (six) HP thin clients at 100 NKR a piece ($9). That’s a bargain if I ever saw one. Here is the article link (will probably vanish quickly).

The power of torrents

I know it’s not good form to encourage piracy but we are talking games bordering on 30 years old (in some cases) so I have no problem looking at the massive collections of Amiga software out there in “torrent space” – as a pure resource of brilliance which belongs to the world. Having said that, I think people should avoid at all cost piracy of OS4 or Amiga forever. It is highly unlikely that any new environments will be created for the Amiga if people copy those systems; and besides – we are old enough now to recognize that programming is hard work. I work as a professional developer and know full well how much it hurts when people crack what you worked for 2-3 years to achieve. If you use it, support it with a purchase!

And this is coming from an ex Quartex and Alpha Flight member (for those of you that remember us). So it’s not without a sense of irony that I write about piracy.

But fact is, you will find gigabytes of games and applications online, much more than you ever had when you owned a real Amiga in your teens. The same goes for MAME (arcade emulators).

Downloading 3.500 Nintendo, Sega, Neo-Geo and Amiga games in <15 minutes is almost to good to be true. Remember Turbo-Tape on C64? You set the tape loading before you went to school and perhaps Last Ninja was done loading by the time you got home 🙂

The following search at PirateBay yields some interesting results:

http://thepiratebay.se/search/Amiga%20games

Sugar and salt

If emulation is not your thing then we should also recognize that there has never been more Amiga based operative systems than right now. Some prefer the old workbench, some prefer the new OS 4.X desktop and others still enjoy the clones. Which as of writing is Aros (and derived clones) and the “inspired” MorphOS.

Pimp up old hardware with a small, compact and lightning fast OS

MorphOS – Pimp up old PPC hardware like an G4 Mac!

Both projects have their positive and negative traits. The positive have to do with the fact that they retain and protect the legacy of Amiga – the negative is typically personified by lack of compatibility with 68K software and lack of drivers. If there is an elephant in the room, it’s undoubtably the lack of hardware for “modern” Amiga operative systems.

Having said that, people always find a way. While I havent been a part of the Amiga scene for many, many years – one thing you can always count on is the high level of skill and technical know-how in the community. If there is a technical problem, someone always figures out a solution. Just look at all those A1200 machines retro-fitted with USB disk-drives and ADF readers? So nothing is impossible.

Example: I picked up a second-hand G5 Mac with 2 monitors for 300 NKR ($30 or thereabout). Useless by modern standards and can only run “vintage” OS X, yet it runs MorphOS faster than any other machine I have! Including my brand new iMac and my Linux gaming PC (!). Imagine what a true port of Amiga OS for PPC would look like.

Truth be told, modern operative systems dont properly use the CPU. Optimization like simple “loop expansion” like we used all the time in the old days is rarely found in modern code. So when a truly human written piece of code is found, it’s typically lightning fast, small and very efficient.

New machines

From what I understand there are two systems being developed by third parties. The first is x86 based and meant for Aros, the second PPC based and suitable for MorphOS. But from what I read online prices for these systems are astronomical and borders on insanity. No-one in their right mind would pay three times as much for an “average system” just because it has a sticker with “Amiga” on the side. Refuse to buy these machines. Get a decent machine and run Aros or MorphOS in protest (!)

I must admit that I find the Amiga situation completely absurd. I have no idea who owns what, but whomever owns the OS should wake up from their psychosis – because there is absolutely no reason to sit on the Amiga codebase if you are not going to do anything with it. It’s been 19 years since I owned a real Amiga, nineteen years (!) and I it can only be described as retarded that the Amiga situation is exactly the same now as when I left.

Aros is pretty damn cool!

Aros is pretty cool!

As a developer myself I realize that the amount of work required to port Amiga OS from 68K architecture to x86 is enormous, but 19 years? I could have written the damn thing myself by now! What exactly are these people waiting for? And whomever owns the hardware rights – why can every other company out there just as small as you, create and release platforms based on off-the-shelf technology, and get it right; yet for the Amiga (which incredibly enough still has thousands of fans), building a machine is impossible?

I think we can safely assume that the owners have no intention of lifting a finger. No company is that slow neither in production or the head to fail so utterly over so many years. Sorry to burst a dream or two, but it’s utter rubbish to still believe that these companies/people have any tangible plans for the Amiga other than flamboyant nostalgia.

Interestingly, the one project that could actually give the Amiga a shot (at least as a “cult” like OS) was something called Amithlon, which was a custom Linux system which booted UAE directly (hm. interesting idea). In other words, a customized version of Linux – giving the Amiga side of things all the benefits of hardware abstraction and even new libraries for programmers to use (!)

But that was clearly to successful to the morons that own Amiga today.. heaven forbid that Amiga should run on x86 without problems — so the project was canceled (jaw drop’s here). Sometimes you just have to question the collected wisdom of the Amiga license holders. It’s almost to stupid to comment on.

Amithlon, worked like a charm on x86 -- so they killed it

Amithlon, worked like a charm on x86 — so they killed it

Still plenty of options

If we look away from the obvious stupidity of whomever owns the Amiga brand, hardware and software rights — the situation is actually optimistic: UAE takes the Amiga everywhere, and with modern processors spending most of their time in idle state – emulation is not the penalty it used to be. Heck, if UAE was modified to make use of multi-core threading, the emulation would be damn close to un-measurable in some cases. The guys behind UAE deserves a medal, it’s an excellent piece of software engineering (or reverse engineering).

I can’t remember the last time I booted an actual, real Windows machine. I do all my development in VMWare these days, including Linux and OS X development. So why I can’t enjoy my Amiga desktop with all those titles and programs is beyond me. Heck, putting together a decent emulation-station from either a cheap embedded board, thin client or older PC is a piece of cake.

Cloud, the future or everything

Cloud

Cloud

Despite the ridicules management of Amiga rights, the Amiga actually have a shot of reaching mainstream once again. Cloud services does not simply mean hosting – it also means that you upload a whole disk for executing it in the cloud. A bit like what thin clients did for terminal services, but 100 times more powerful!

With cloud taking over — it will no longer be a question of hardware, but rather a question of platform. If the Amiga have any future then that’s it. The alternative is that it remains the most widely emulated and loved home computer in the world.

A second market would be embedded systems. Have a sneak peek at QNX real-time OS. That could have been the Amiga, but someone figured it was better to do nothing for 19 years (except OS 4)… Just.. way to go!

And to those who own the rights for Amiga: give the source-code to the community. Make Amiga OS open-source. It’s the only way you will get the manpower to catch up with all the missing features. And if you ever wanted a native x86 version, then open-source is the only way to go.

What is the point of owning an OS if you are not using it for anything?

But to be honest it doesn’t matter what the Amiga copyright holders do. Emulation is so damn good these days that people have little or no use for an official Amiga. 20 years without a proper update is a long time. Just imagine the amount of code invested in Windows or Linux during those years — you can’t catch up with that without a miracle.

But once the C/BCPL code was made open-source, that reality would change drastically for the better.

So what do we need? A product that runs better on the Amiga platform (again, not hardware) than any other OS. Just look at what Apache and mySQL has done for Linux over the years. The Amiga would need something like that to adopt a serious role in the server community. Even if it was just cloud based game emulation for that matter.

Final words

Some people might think was a negative article, but it’s actually not. In Norway we have a saying which, roughly translated, goes like this: “sometimes you have to call a chair for a chair”; meaning that lying to yourself or others ultimately leads no-where. If there was no UAE then indeed – that would be grounds for sadness regarding our beloved childhood computer.

What have the romans ever done for us eeh?

10 for that you must be mad!

But we have UAE and hardware is now cheaper than ever before! Anyone with a slight bit of Amiga skill can easily put an old PC or Mac to good use. Machines which would otherwise be thrown away. Add torrents to that equation and .. thousands of games, applications and demos (!) If that is not optimistic news then I dont know what is 🙂

I have been harsh with the license holders of Amiga technology today, but after so many years I feel I have the right to speak my mind. And they have made it so utterly clear that anyone who cherish that old computer is utterly on their own. Which suits me just fine – because the community itself has everything it needs (and then some).

So to all friends of the Amiga personal computer out there —enjoy UAE and your homebrew devices!

Downloads

Building an Amiga for $40 with Raspberry PI and UAE4All

October 9, 2014 22 comments

Right. As most readers probably know by now, I absolutely love the idea of re-furnishing old computers to their former glory. I tend to buy second-hand computers and technology and turn them into something useful and modern, or at least something the original designers didn’t consider when they made it. Like my $43 Apple G4 with dual monitors, a kit I turned into a MorphOS powerhouse – that is presently running a custom synapse (FreePascal coded) file-server.

Well, I’ve had a Raspberry PI floating around the place for a whole year now; It was originally something I bought for my 11 year old son in a desperate hope that he would fancy a DIY project with his old man. But sadly I have capitulated to the power of minecraft and the fact that he is more a “soccer kid” than a programmer. I love him either way, but I hope to initiate him into the mysteries of code – which have given my life so much joy. Especially in my childhood, playing games and trying to make them using Blitz basic 🙂

The RPI mini computer, size of a pack of sigarettes

The RPI mini computer, size of a pack of cigarettes

Either way, yesterday I was shopping when came across a special offer on 5V re-chargable batteries, the models meant to re-charge your iPhone. So each battery holds enough juice to fill an empty phone when you’re on the road. I suddenly remembered that the voltage and amp was identical to the Raspberry PI, and since you could chain-connect several batteries together via USB->USB MINI connectors  I figured if I got a couple of them the PI could run on them.

And work it did! I was actually able to get 6 full hours of “mobile” activity from the Raspberry PI with just two batteries (!). Which is en-par with any modern laptop of portable touch device (IPad, Android Pad). I also stopped by an electronic’s store and picked up a USB splitter – turning the meager 2 USB slots on the classical Raspberry PI into a 6 slot connectivity monster.

Tip: A rule of thumb if you want a “portable Amiga” is to add one battery to the chain per USB device you have connected that requires power. Keyboard and mouse doesn’t require much, but count one battery (a total of 2 so far). Add two more batteries if you use a USB disk drive, and a single battery if you use a Wi-FI dongle or a USB stick. So for an RPI with keyboard, mouse, external 512 gig disk and a wi-fi dongle: count 5 chained batteries.

Tip 2: Save your sanity and buy a pack of those cheap wireless keyboard and mouse. It requires very little power on the RPI and you dont have cables all over the place. Especially in your living room where your wife will no doubt comment after a while 🙂

Top 3: If your TV has an USB plug, buy a USB to mini-usb cable, then use the USB on your TV to power your RPI (!) It works brilliantly and once again saves you a power cable. With this in place you only need the HDMI cable and your’re ready to rock.

Linux to the rescue

One of the cool things about Linux these days is that it’s driver database has grown huge over the past 7-8 years. It used to be that getting anything at all to work on linux, let alone “off the shelves” windows hardware, was nearly impossible. I vividly remember having a (then) high-end gaming PC with the latest Mattrox graphics card (the type you could buy 2 or 3 and chain them with fire-wire optical cables for extreme performance) + Soundblaster 16, but when I tried to install RedHat Linux I ended up with a bog-standard VESA driver! That was such a disappointment that I did not touch linux for 8 years.

Well those days are long gone and most modern Linux distro’s are able to recognize whatever you throw at it. Since I picked up Ubuntu and started using it full-time I have yet to find a single piece of hardware that it cant work with. Which is brilliant! Especially the source-based drivers that (in theory) should work on all distros as long as it uses the driver API to talk with the hardware.

Either way — this meant that getting the Raspberry PI to recognize keyboard, mouse, external drive and even my printer (!) was actually easier than on my spankingly new Mac! You plug it in and seconds later it’s ready to go.

Memories of Amiga

I must admit that I miss my Amiga a lot. Im now 41 years old but when I think about my Amiga, which I clung to until the last moment, only selling it in 1995 due to Microsoft Office requirement in college, I get all warm and fuzzy inside. It’s the same emotion you experience when you meet “that special someone from the past, she that got away”. I guess it’s common knowledge that people who grew up with Amiga’s are extremely passionate about it – bordering on fundamentalism. And this is decades after it’s gone out of production (!).

There are crimes in the history of technology; VHS vs. Betamax was one of them – but the absolute worst crime in computing history – en par with the extinction of a the west-indies by a hoard of drunken sailors in the 1600’s, will always be the unjust death of the Amiga. We would inhabit a very different technological world had Commodore survived to this day, that is for sure. It would be faster, easier and far more friendly than anything we have today. Nor would it be driven by megalomaniac psychopaths like Steve Jobs or Bill Gates. Although Petro Tyschtschenko can give you a nasty scare if you meet him holding “the walker” prototype in a dark alley somewhere.

Right – here are few things people may not know about the Amiga:

  • You could buy VR (virtual reality) equipment based on Amiga Tech 20 years ago. VR is not new nor is it innovative, it all started with the Amiga
  • TV series Babylon 5 used Amiga for all it’s graphics
  • LucasArts used Amiga 4000 render-farms
  • Nasa loved the Amiga and had a ton of them, they were also used in a couple of satellites!
  • While Microsoft Windows could barely run calculator and notepad simultaneously, the Amiga had full preemptive multitasking
  • AmigaOS was architected after UNIX and is extremely resource sufficient; running a full multi-window desktop, multitasking with far better performance than Mac’s and PC’s at a meager 1 megabyte of ram and 14Mhz Motorola 68000 CPU. That’s like a 14 year old beating Mike Tyson
  • It was only when PC’s adopted graphics accelerators and 3D hardware that Amiga’s struggled to keep up
  • PPC accelerator cards were made to make up for it, but commodore screwed up the marketing
  • Ultimately the Amiga died due to neglect by Commodore, which filed for bankruptcy
  • After the demise of the Amiga, the MC68000 CPU’s were mainly used in washing-machines (auch!)

Turning a PI into an Amiga

Looking at the specs of the $35 Rasperry PI mini-computer we find that in a raw head-to-head comparison of CPU power (which is really unfair to the Raspberry, because the Amiga’s strength was it’s integrated custom chipset) it is head over heals beyond anything the Amiga had. The Amiga 500 had 512Kb ram, the low-end RPI has 512 megabyte ram (1024 times more!). The CPU is a single-core ARM processor running at 700Mhz, but most people overclock it to 1Ghz. I can only imagine how the PI would run if Amiga OS was ported whole-heartedly over. Amiga OS natively compiled for that hardware would run rings around an average, modern PC.

Ta-Da! <$50 for a portable Amiga? Eat that Amiga inc!

Ta-Da! Less than $50 for a portable Amiga? Take that Amiga INC!

So, how could I turn my now battery powered Raspberry PI into an Amiga? Well, I have to turn to emulation. And in order to get that working I need Linux. So I went over to the Raspberry PI website and downloaded the noobs disk image, plugged in a network cable and installed Debian (I also tried the fedora port, but Debian gave the best speed). I used the apt-get package manager to update the system, plugged in a wireless USB dongle so i could finally ditch the cable — and voila! I had a “mobile” Raspberry with wireless capabilities. Oh and I had a ordinary USB keyboard and mouse in all the time. Just in case you think I did this via telepathy.

Setting up the emulation

Next was the Amiga emulator, which comes in many flavors and forks. Once again i googled the best option and found a custom variation of Amiga4All on the RPI website. I downloaded the package and installed it.

Next, I needed a few things:

  • Original ROM files from the Amiga
  • Disk images of games, Workbench (the Amiga desktop) and harddisk’s

Well, considering the amount of money I have invested in Amiga’s during my teens I felt no shame visiting my local torrent and grabbing a massive 8 gigabyte ISO with everything. And I mean everything, including all the ROM files ever made for the Amiga (and then some! Even the failed Commodore inventions like the CDTV was there).

I took the Flash-Card out of the RPI and plugged it into my Mac, then copied the ROM files to the “roms” folder, and the disk images to the games folder. I also separated the floppy images from the harddisk images so it would be easier to work with.

Adapting Linux

Next, having booted back into Linux on the RPI, I edited the config file and removed the statement “startx” (towards the end of the config file) which is the command that starts the desktop under Linux (I presume this is universal, but I’m really new to Linux so there may be variations). I replaced it with the command-line call to start UAE instead – pointing it to the first game I ever bought as a kid: Rocket Ranger (I later discovered that you could disable the desktop completely when you install, but picking “text mode” instead of desktop-display).

To be perfectly frank I never thought it would work “just like that”, because I have only 3 weeks on hands-on experience with Linux (Ubuntu) so I was prepared to drone over esoteric man-files and asking people online. But to my big surprise, I 6-10 seconds later I was looking at the Cinemaware logo on my spanking new 55″ LED TV. Boy did I jump! I even got sound, although it was slightly jerky.

I went back in and had a look at the UAE config, turned on JIT, set “drop frames” to 1 (it was set to 3). I also set sound to mono, because I’m not that into music anyhow. And that was it — it worked just like my old Amiga (!)

Setting up WB

Next step was to see if any of the Workbench HD images worked, and indeed they did! It’s actually faster to use Workbench under emulation – than to use Arch Linux compiled for Raspberry (oh yes, I tested that distro as well, and it was barely usable at all).

Overclocking

A major speed boost is the over-clocking feature. You simply edit the RPI boot config and set over-clocking to max (see article on doing this here) and the CPU runs at 1Ghz, which is a great improvement from the default 700MHz. I have yet to find a game which runs worse than the original Amiga — and I’m guessing it’s not even hardware accelerated.

As you probably know the RPI comes with a proper GPU, which is how it can play HD video. If UAE was to use this there is no doubt — the RPI would replicate the old Amiga down to the letter, but with more power, more ram and full driver support for modern hardware.

Well, I hope my little adventure interested you!

QTX vs. Smart Mobile Studio?

October 7, 2014 4 comments

It appears to be some confusion regarding what “Quartex IDE” is and how it’s connected to Smart Mobile Studio. In fact, the Smart team was asked if they had stopped production — which is a very unfortunate interpretation of the facts. Let me assure you that Smart Mobile Studio is not only in production, it’s growing by the hour – with several key developers working on it (!). I must underline and stress that QTX has no relation to Smart Mobile Studio at all.

The only thing these two projects have in common, is me. I am the author of both
systems and as such there will be similarities between the two.

So what is QTX and what is Smart?

Smart Mobile Studio

Smart Mobile Studio

Smart Mobile Studio is the programming platform I created together with Eric Grange a couple of years back, and later in co-operation with other great programmers. We all to this day make up “the Smart Mobile Studio team”. Smart is sold and marketed by Optimale Systemer AS in Norway. I own 50% of the product and as such is intimately involved with every aspect of Smart Mobile Studio.

Smart Mobile Studio is a completely separate, isolated project which is, to be perfectly frank, the best HTML5 development platform on the marked. And it continues to grow on a daily basis – with (as mentioned) several programmers working on it. Myself included.

Smart Mobile Studio has NOTHING – I repeat – NOTHING to do with QTX.

So what is QTX or “Quartex” thing?

QTX is a personal side project. It was created by me after Smart Mobile Studio and functions more or less as a kitchen-sink for ideas. The goal of the QTX project is to create a generic IDE, preferably open-source, which would be the Delphi version of Java’s Eclipse. Meaning that it can be used as an IDE for many different compilers, not just Smart Pascal but also Free Pascal, Delphi, mono C# or even GNU C++.

Smart Mobile Studio is architected to interface with and absorb the document
object model and JavaScript completely. Smart gives you access to the browser with
the same fine grain of detail as the VCL does for WinAPI. The Quartex IDE and RTL does not.

The reason I created QTX as a side project, is precisely because Smart Mobile Studio is a living, vibrant project. Smart is purposefully intertwined with the document object model and JavaScript by design; Hence, in order to target other platforms, languages and compilers it made more sense to create a new and separate project.

The Smart codebase is small enough to be managed and maintained by a single individual (although barely) and we want to keep it that way. It’s tempting to push the envelope and stuff the IDE full of everything under the sun, including third party compilers, secondary code analysis packages and god knows what — but my experience is that such a codebase ultimately falls pray to bloat, confusion, unexpected errors and bad performance (read: Delphi 2006). We want a HTML5 development environment that is lean, mean and responsive.

So instead of doing that – I sat down and started to experiment with a new IDE. Testing new ideas of how to make routines faster, looking at managing tabs and frames through a different API. This is how the Quartex IDE was born. As a research and development IDE into the object pascal language and parsing technology.

Is QTX better than Smart?

Quartex IDE, early prototype

Quartex IDE, early prototype

Absolutely not. And the two products can’t be compared like that either. It’s like saying that a water-scooter is better than a dirt-bike without taking into account their completely different environments and design goals. I received some statements along the lines of “QTX is better than Smart and is the next Smart IDE”. This is an exquisitely absurd and anal interpretation of what I have written. I tend to write from a personal point of view and I can sympathise with people who may mix up personal views with “hard production facts”; but let me assure you that QTX is not the replacement for the Smart IDE. Smart Mobile Studio is architected to interface with and absorb the document object model and JavaScript completely. Smart gives you access to the browser with the same fine grain of detail as the VCL does for WinAPI. The Quartex IDE and RTL does not.

What I have stated is that parts of the QTX Core, routines inside the IDE which takes care of files, packages and general organization of open editors — that, and that only may merge with the SMS codebase at some remote point in the future. But there is presently no need to do so, because SMS if polished, tried and tested.

One feature which sets the products apart is the RTL (run-time library). Smart ships with a RTL written from scratch to interface with the browser(s) exclusively. While it is theoretically possible to abstract the RTL so it could run on native platforms, it would require herculean efforts and almost a complete re-write. The Quartex IDE, in contrast, comes with a generic RTL architected to suit any platform. Meaning that it’s a lot more complex and borrows shamelessly from the .net framework (since I am heavy into C# I tend to bring something back to Delphi whenever I can).

The only thing these two projects have in common is me. I am the author of both systems and as such there will be similarities between the two.

I have also aired that I have made advances in the way I have built the QTX IDE, internal optimizations and more efficient approches — but under no circumstances does that mean that Smart Mobile Studio is “bad” or “not as good”. Smart Mobile Studio is an extremely complex piece of engineering. Writing an IDE may seem like a simple task – but I can guarantee you that it’s not.

Code sharing

Since I am active in both projects, naturally there is a convergence of code between the two. For instance, I recently wrote the QTX HTML5 library, which can be freely downloaded and used in Smart Mobile Studio. It provides effects and several helper classes which makes it easier to deal with callback’s and non-linear calls.

I can understand the confusion some people have around this — but it’s really very simple. When I have code that benefits Smart Mobile Studio then naturally I will put the code there as well, and visa versa.

So what is the status of these projects

To sum up the situation:

  • Smart Mobile Studio is a fully separate, living and vibrant product
  • Quartex IDE is a generic IDE, separate from Smart Mobile Studio
  • Smart Mobile Studio is written and fully adapted for HTML5, QTX is not (!)
  • Both projects were written by me, this is the only thing they have in common
  • Since I am active in both projects, I tend to share my codebase with myself (sigh)
  • QTX functions as a kitchen-sink for new ideas, prototypes and parsing technology
  • Good ideas are ultimately pushed into Smart Mobile Studio
  • Smart Mobile Studio is 100% about JavaScript and HTML5
  • Quartex IDE is generic and tries to work with everything

So there we have it. I have two separate projects i’m involved in. They both include an IDE. They both use compiler technology. But they are very different and completely separate.

I have written that “QTX begins where Smart Mobile Studio ends”. This have for some strange reason been interpreted as Smart Mobile Studio somehow going out of production (??). Let me de-mystify that line of thought straight away:

What is meant by that statement is simply that Smart Mobile Studio is not multi-lingual. It targets HTML5 and JavaScript exclusively. It contains thousands of lines of code written to cater for – and make JS programming as easy and flexible as possible. And it is getting better and faster and more clever for each day that passes! As such, Smart Mobile Studio is only about high quality JavaScript. Hence Smart Mobile Studio ends there; it only does HTML5 and JavaScript. And it does so brilliantly.

Quartex on the other hand is generic. Meaning that it completely relies on an external compiler to do the job. It implements the typical functions you expect from an IDE, but does not dig into the peculiarities of any language. It is purely language agnostic, meaning that it has no idea if you are writing pascal, php, java or c++. All of that has to be crafted and designed. As of writing it uses the freepascal compiler as its primary code generator. Allowing it to reach out to Windows, OS X, Linux, Amiga, Nintendo and other platforms. But it deals exclusively with native code at this point.

Will you make another HTML5 studio?

Well, I can if I want to, but there are several reasons why I would not do that. First of all we are 5 people who have worked countless hours on Smart Mobile Studio and Smart Pascal. Christian, Primoz, Andre and Jørn have invested both time and money into this – not to mention Eric Grange (writing a code generator for another language is no walk in the park) and I feel it would be a catastrophic demonstration of disloyalty, egoism and selfishness to create a competitor to a product I myself started, own, maintain and sell.

Secondly, the smart pascal team are my friends, and friends don’t do shit like that.

Third (from the Bhagavad Gita) : “A man at war with himself, is sure to lose”.

Final words

I sincerely hope this little post cleared up the confusion regarding this topic. Smart Mobile Studio is growing by the hour and it is well under way to reaching its goal: to become for HTML5 what Delphi is to WinAPI — The ultimate HTML5 Mobile application studio.

My personal project, Quartex IDE, has nothing to do with SMS. Since I am the author of both systems, naturally I will share my codebase with myself in order to make sure Smart Mobile Studio is as fast, robust and intuitive as possible. But keep in mind that Smart Mobile Studio has 4+ years of constant development behind it. We are 5 programmers working every day to make it more clever.

Kind regards

Jon Lennart Aasenden

Hacker culture – understanding scandinavia

October 4, 2014 Leave a comment

In our day and age, the word hacker is a term associated with criminal behavior. It can mean anything from extracting information unlawfully, break or bypass security measures, avoid payment of service, terrorism (to terrorize, to cause fear) and much more.

20 years ago a hacker, in the Scandinavian sense of the word, was simply a clever programmer. The impression is that of a programmer hacking away at a problem, finding or hacking new roads in the mountain (or going under it if that’s what it takes). Such a programmer dedicated the majority of his time to creating demonstrations (demos) and pushing technological boundaries. His or her’s focus was (and is) on how to squeeze every last drop of CPU power from a system – in the service of graphical or audible effects regarded as cutting edge or “impossible”.

bilde-tatt-04-10-14-kl-20-12

There can only be one — QUARTEX

A hacker was, at least in the Scandinavian sense, not the same as a cracker. The latter being a person who spent his time removing copy-protection from games and software in general, with little or no moral standing as to the fate of his victims (crackers tend to believe that everyone else is rich and that years of work exists only for their leisure).

An interesting point, when comparing hacker culture between Scandinavia and USA – is that Scandinavia really never had a clear-cut equivalent of America’s white and black hat paradigms. The closest match is that between hacker and cracker, but even there the lines cross and blur.

What the US missed out on

Americans have really missed out on what must be one of the most positive aspects of hacker culture, namely the demo scene. I have heard many different explanations regarding the lack of “demo” interest in the US, ranging from economic (america is insurance based and as thus, money and career is implanted in the mind of kids quite early) to the more tasteless (“we don’t do demos, we make bombs”).

Silent before the storm, the press lodge

Silent before the storm, the press lodge

Personally I think it has more to do with the college school system, fraternity mentality and various cultural tendencies. But it is extremely strange that a solid demo scene never occurred in the US during the 80’s and 90’s – because demo coding is probably the best education in programming you can get. And considering the money prices involved with high-end demo coding, especially from multimedia and game companies who are on the constant lookout for the next superstar programmer – i find it nearly inconceivable.

Considering how Americans trek across the entire continent to celebrate comic books and star trek characters (comicon), it is sad to see what I believe would be a more rewarding expo not even being proposed. But, perhaps times have changed. I know there are countless developer expo’s in the US every year – sadly very few of them involves more than presentations of technology as opposed to radical, cutting edge demo’s.

The parties

Back in the day we used to simply call these gatherings “copy parties”. This was way back when a 20 megabyte hard disk was seen as the proverbial shangri-la of storage space. Games and applications came on 720Kb floppy disks, and tape streamers were regarded as “safe”. So parties were copy parties, because that’s basically what you did there. You copied games and shared your code — and hoped to win the demo competition your group signed up for.

Today these same parties (and I suspect much of the same activity) is simply called “demo parties”, and if you are between 14 and 30 – it’s THE place to be whenever you can. I’m 41 years old and still regard these gatherings as one of my most enjoyable experiences, especially today with all that juicy hardware to play with. The most famous demo party, probably in all of europe, being “the gathering” which is held at the olympic stadium in Hamar, outside of Oslo, Norway (called “the viking ship”).

The Gathering

The Gathering

The gathering (TG) has turned into big business over the years, with technological companies practically throwing sponsorship at the event – and in return they get the ultimate hunting ground for future employees with a high degree of technical insight.

If you have ever been at an expo (or Delphi meetup) you enjoyed, multiply that by 10.000, add a huge stage with 24/7 shows, beer, the fastest internet connections money can buy (and I mean that quite literally) and more programmers than god ever intended — and you have “the gathering” in a nutshell. Created by “The Crusaders”, a fairly infamous hacker group from Drammen outside of Oslo, Norway.

Quartex

As readers of my blog probably know, I started out in a group called Triumph (actually it was called “the band” before that), then I moved on to Alpha Flight, before I finally joined Quartex. Quartex being the most notorious hacker cartel in Europe at the time. In Scandinavian sense this is regarded as a high achievement, since only people with a solid skill set could join these groups. Quartex being the absolute elite.

Sadly Quartex meet with a rather grim fate. It existed since the early days of the Amiga home computer, but when the piracy wars of Europe raged – german police hunted Quartex to extinction, with only scattered members around the globe (interestingly enough, one of the HQ addresses being American).

Importance of hacker culture in modern life

The importance of hacker culture cannot be underlined enough. If you associate hackers with dark room, anonymous thieves who do nothing but cause problems, then you are in fact suffering from a particular bad case of generalization and stereo-typing. The entire concept of “hacking” is an expression of curiosity and creativity combined with expert technical knowledge. In many ways it represents the individual’s pursuit of technical excellence, far beyond anything you find at your local university.

Young hackers learn to think outside the box

Young “hackers” learn to think outside the box

What you will typically find, at least in Scandinavia and northern Europe is that nearly all of the programmers doing ground-breaking work today have a background as demo coders and “hackers”. In fact, it was their exposure to advanced programming at an early age, driven by interest and environment, that led to these good programmers becoming exceptional experts as adults.

Such hackers are in the US labeled “white hat hackers”, since they are using their skills for good; while those that use their knowledge for breaking the law and clearly placed in the “black hat” department. This should also give some hint to the phrase “red hat”, which is one of the world’s leading Linux distributions.

I’m not sure the American tendency to see things in purely black or white can be applied to hacker culture. Hacker culture is generally a lifestyle with many facets. Being able to crack a game or get into someone’s Facebook account is not the final word spoken about an individual. While I would never condone such actions – or breaking the law no matter where you live, I do feel that the stereo-type of “the hacker” should be adjusted according to reality.

I consider myself a “hacker” even though I don’t break copy-protection or try to sneak my way into a server illegally. But should I do something like that, then the government should be glad I did it and not some foreign nationalist party who would use the information for evil. And that is the role of a white-hat hacker, to know “how to”, but to use that knowledge for good.

But in Scandinavia at least, the term hacker still retains some of its former glory from the 80’s and 90’s. And that can only be a good thing.

Moving to Linux, part 4

October 2, 2014 Leave a comment

In this final installment of my Linux series we will be focusing more or the Linux side of things (with the exception of Wine Bottler for OS X), with pointers on how to write your own native Linux applications; and also (Unix wise) how to convert and publish your Win32 apps on the mac without a single line of code (!)  And yes, with no dependencies or virtualization involved.

You are probably expecting a long introduction to Lazarus, which I wont bother with since 90% of all Delphi developers knows perfectly well that Lazarus and FPC exist. So before we start talking about Lazarus and FPC, which I wont do in “presenting” fashion since we already covered that, I want to list a few alternatives which might suit you better.

New wine for aging bottles

In the old days Wine was “THE” magic app for Linux. In fact it was so successful –that more esoteric platforms such as the Amiga operative system – tried to adopt it. How that particular endeavour went I havent got the foggiest, I just remember reading that it was started on years ago.

Wine, a serious option for legacy win32 apps

Wine, a serious option for legacy win32 apps

If you don’t know what Wine is, here is a short low-down of the product:

In short, Wine is a re-implementation of key Windows modules. So it’s not an emulator, but rather a kind of portable variation of Windows’s sub-systems and core, created by open-source enthusiasts. It is also a system of mapping, in real-time, Windows OS calls into their linux POSIX equivalents. While this probably sound like a dodgy option for getting your Software to run on Linux without a massive re-write, I may remind you that Borland shipped Kylix running solely on Wine. Wine also runs Microsoft Office, Internet Explorer and a wast array of other titles flawlessly. So it should be considered a stable and viable option for getting Win32 apps onto the Linux/Gnu desktop

To sum up, unless your application hits the hardware directly (or indirectly, since Windows sandbox you with drivers. As it should), or uses one of the rare modules of Windows which is not handled by the mapping process — odds are you can “wrap” your executable(s) and start selling for Linux without any significant alteration.

Crossover

This is a commercial product, but essentially it’s a fork of the Wine codebase. Produced and maintained by CodeWeavers, it features an easier path and less fiddling than the original Wine distro. But ultimately — it’s another incarnation of Wine.

Wine Bottler (the best option)

This is a god-sent package for Mac users. And you will probably feel bad for not knowing about this before now. Imagine the following: You have a fully working, well written Delphi Win32 application written using VCL. But, the idea of porting it from VCL to FMX, or from VCL to Freepascal/Lazarus will be to time-consuming and not economically viable.

Wine Bottler, the absolute dogs bollocks

Wine Bottler, the absolute dogs bollocks

How do you solve this? Well, chances are that you wont. You will stick to selling your software on the Windows platform. But this is where Wine Bottler comes to the rescue, because unlike Wine — the bottler is an application for completely wrapping your application with Wine, turning it into a self-sustained, no dependency OS X bundle (!)

So, if you have a piece of software you want to launch for OS X, but you don’t have time or money to re-write using FireMonkey, then you can use Wine Bottler to do the job for you. It takes you application(s) and turns it into a fully valid and working executable for OS X.

I sure wish I knew about that earlier.. would have saved me a lot of work.

As the docs says:

Double-click your .exe or .msi and convert it into an app with WineBottler. You can run the generated app like every other program on your Mac. For advanced users, WineBottler gives you a selection of options: install special dependencies and even turn your .exe into a self-contained app – that is an app, that contains everything to run it… even on other Macs. Porting to OS X never was easier ;). Find out more – have a look at the Documentation.

The big choice, FPC or Delphi

Opensource inside

Opensource inside

Lazarus is not for everyone. You either love it or hate it, but you have to agree that it’s one hell of a project. And you may not be aware that freepascal was actually used by Embarcadero in order to deliver iOS support for Delphi. This was prior to the completion of their own compiler. I feel a bit sad for freepascal in this regard, that Embarcadero just waltzed in and grabbed what they needed (and I wonder if they ever donated a penny to the freepascal project). It borders on what should be allowed to do with an open-source project. But one thing is clear: freepascal is of high quality and it produces high quality code. The question really is how dependent you are on third-party components and if they have FPC/Lazarus support.

Another factor that you should consider, although not without attaining your own subjective experience (read: try it!), is the quality of Lazarus and freepascal on the Linux/Gnu platform – compared to the quality of the same under OS X. Lazarus on OS X has begun to mature over the past 2 years, but I found it to be a mess at first. Always some strange exception, missing file or mysterious crash. Thankfully that was years ago — and today it’s a different story all together.

On Linux especially, Lazarus is a completely different product. I have so far only experienced a single bug (and lord knows Delphi goes down like the titanic from time to time). The overall experience is quite polished and — well, it’s just a completely different ballgame compared to OS X. The Windows version of Lazarus has always been very good, but the Linux version quite literally outshines them all.

What direction to take?

When faced with a complete re-write of a major project, you have to weigh the pros and cons carefully. If you chose to stick with Delphi that would mean re-authoring from VCL to FMX. This can either be simple, depending on how cleverly you wrote the original code, or a total mess. In my experience, “living” products tend to grow in complexity and spaghetti-factor when faced with a deadline, so how hard it will be to get your legacy win32 VCL app spinning on OS X and iOS is difficult to estimate. For Linux however, you dont have an option except either a Wine wrapper or a FPC/Lazarus re-write.

In this regard an FPC/Lazarus port is probably much faster. First of all the FPC RTL is identical to Delphi and VCL (it is actually a fork of Kylix, which was the open-source portable VCL); Secondly the UI toolkit is likewise more or less identical to the VCL (with some minor differences).

Large Delphi programs can quickly turn into a mess if you dont architect them properly

Large Delphi programs can quickly turn into a mess if you dont architect them properly

But, we must also remember that Delphi is slowly moving towards coverage of all three major platforms, with only Linux missing from its impressive repertoire of technology. So you may wonder why you should choose between the Delphi path and the FPC/Lazarus path. It’s not a question of the past. Rather it has to do with where object pascal will be in 10 years.

Note: Remember how we trusted Borland, only to find ourselves in a 8 year long struggle, which nearly drove Delphi as a platform into extinction.

Well, I can’t tell you to migrate all your business to FPC/Lazarus. I would suggest you regard FPC/Delphi as two distinctly separate tools in your toolbox, with one substantial benefit: they both cover object pascal with miniscule differences in dialect.

The only real difference and potential deal-breaker, is of course that of generics. Which sadly differs vastly between compilers. But rumours have it FPC will add support for Delphi style generics syntax quite soon, once again restoring balance to the force.

Here are the pros for adopting Lazarus (IMHO):

  • Wast range of platforms supported
  • Your binaries require little in terms of installation (unlike C/C++)
  • Write servers, libraries and leverage Linux as a cost-effective solution for your customers
  • Free ! — A direct economic saving of $3000 straight our of the box compared to Delphi
  • FPC can be used as part of your product, Delphi cannot
  • Truly platform independent!

And here are the pros for sticking with Delphi:

  • Delphi offers a larger codebase compared to FPC/Lazarus
  • Delphi has the support of commercial component companies
  • Delphi is backed financially by Embarcadero
  • Delphi has the latest advancements, like GPU rendering under FMX
  • Delphi has a more modern IDE which we are acustomed to
  • With iOS, Android and “wearbles” Delphi has a leg up on FPC/Lazarus

I should perhaps mention the obvious. Namely that you can use FPC/Lazarus to get your VCL legacy code onto OS X and Linux, but for that purpose only. New projects and solutions might be better served by being written in FMX.

A word of warning: Delphi was near extinction only a handful of years back. Borland was forced by Microsoft to drop their competition, resulting in the spoils of war going to Microsoft (in this case Anders Hejlsberg playing the part of Bill Gates’s trophy wife). Embarcadero took over but did very little for Delphi during those years. Which is why Smart Mobile Studio came into existence. My point being: While Delphi has gone through the proverbial sinus-curve of popularity and decline, freepascal and Lazarus has remained largely unaffected by this. Which is truly worth considering if you have projects expected to be active for at least 10 years.

Moving to the cloud

Cloud

Cloud

Another interesting option, although perhaps beyond the majority of single person companies, is that of full cloud virtualization. This solves the problem of legacy (older code) and uproots the choice of platform once and for all. If you read my previous post on virtualization, then you know that cloud based computing includes the ability to upload entire VMWare images to be executed in the cloud. This means that native server software once again becomes important since it, in most cases, provides a significant speed boost over scripts and PCode runtimes. And it is of no consequence what language or compiler you use to deliver the goods – as long as they deliver.

Here is an example of a “typical” setup which covers both web, mobile and native:

VMWare Image #1

  • Port: 8040
  • Firebird database
  • Authorized access from IP of VMWare #2 only
  • Ubuntu

VMWare image #2

  • Port: 8090
  • morMot RPC (remote procedure call) service
  • Soap and JSON endpoints
  • Ubuntu

VMWare image #3

  • Port: 80
  • Apache HTTP server
  • Smart Mobile Studio driven website
  • Ubuntu

Image #1, your data store

The first image would house the database and storage facilities of your business. In our case we could use the freeFirebird database (pick the database of your choice here. MySQL is another great open-source alternative). Since we don’t want hackers to have a field-day with our investment, access to the database should strictly go through the RPC layer. This reserves for us an opening for a load-balancer should our business suddenly sky-rocket.

Image #2,RPC server

Where server #1 deals with data and storage exclusively, this VMWare image deals with access to that data and basically provides a fail-safe abstraction layer. the fail-safe being: login sequence, session management, data injection hack protection, data extraction protection (only valid sessions and users) and other “standard” methods of security.

By carefully crafting an API with SOAP and JSON endpoints, we cater for both native clients designed for the desktop – and HTML5 apps written in Smart Pascal — all from a single, unified API. I have proposed mORMot since that has excellent Smart Mobile Support. But Smart Mobile Studio ships with built-in support for Remobjects SDK. You pick the package that suits you.

Image #3, your HTTP access point

The last image represents the public “face” for your virtual enterprise. It has several key benefits, first and foremost that it will host the HTML5 version of your software (written in Smart Mobile Studio). Secondly, you have enough leverage for a RPC dispatcher — meaning that you can keep the RPC service private, using Apache as a gateway to the service in instance #2.

And last but not least, the above setup will not just cover HTML5, it will also cover native development. You can sit down and write the Windows and OS X native clients in Delphi with Firemonkey — and under Linux you make use of FPC/Lazarus. All clients would access the service the same way, and have identical features. So just like Dropbox your users can use either a native client app, or simply log-on through HTML5 and a standard browser.

Writing platform independent services with FPC

Note: Under Unix and Linux, a background service is called a “daemon”. The name stems from ancient greek religion, where all men were believed to have a personal daemon (helper, what in modern religion would be a guardian angel). Plato was said to have a daemon from the gates of hades. The ancients did not divide reality into good or evil, that came later with Christianity and Islam.

A fine paper on writing cross-platform services with FPC can be found here:
http://www.freepascal.org/~michael/articles/daemons/daemons.pdf

And as always, google is your friend. Should you need help I suggest you register on the FPC/Lazarus forums and ask. You will probably find that your questions have been answered before.

The mORMot framework can be found at Synopse, the company behind it (open source):
http://synopse.info/fossil/wiki/Synopse+OpenSource

And lastly, the free and open-source database access framework Zeos can be found here:
http://zeoslib.sourceforge.net/index.php