Home > Delphi, JavaScript, Linux, Object Pascal, Raspberry PI, Smart Mobile Studio > Object Pascal for Raspberry PI

Object Pascal for Raspberry PI

October 29, 2014 Leave a comment Go to 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!

Advertisements
  1. leledumbo2503
    October 29, 2014 at 8:38 am

    > has all the features of C/C++ (with the exception of templates)

    ehm! both delphi and freepascal already have them for quite some time, with freepascal’s objfpc has it first with different syntax. but the current version (esp. trunk) has support for both syntax depending on active compiler mode.

    • Jon Lennart Aasenden
      October 29, 2014 at 3:59 pm

      Thanks! Well then I learned something new today as well 🙂

  2. aplikmuj
    October 29, 2014 at 11:02 am

    The result achieved within the boundary of the requirements given is not dependent on the complexity of the language, compiler and tool. Complex tools don’t deliver better results because of their complexity. Scripting does have it’s limitation but you get things done quickly. The absence of the demand for reusability in general makes scripting languages attractive. The developer himself will not face many situations in his job at one company/workplace in real world good industry where designing for reuse will pay. There are other advantages that do come with the design for reuse approach – having an eye on completeness of design.

    • Jon Lennart Aasenden
      October 29, 2014 at 3:19 pm

      We are not talking about pure complexity (not everywhere). In the case where I mentioned pascal as an alternative, we were dealing with computation and data processing. I simply said that it would be wise to use a native language for that particular task, and I proposed FPC since that is a 1-liner to install and use. I was meet with an extremely sharp tone, and in one case even outright bullying — and the RPI board is a place where kids travel. I seriously dont want my kids hanging around a board where people talk like that.

      I am open for all languages. I enjoy scripting myself, and I have written a couple of script engines in my day. So I am not against python or any of the other popular script languages out there — but when it comes to computation, byte-by-byte processing, then you cannot avoid the fact that a real – pointer based language will be faster.

      Also, last time i checked, a python class has roughly the same amount of text as a pascal class. And with the latest features in FPC/Lazarus, it would be a snap to use that instead of python. But as you point out and I agree on, sometimes a shotgun makes more sense than a canon. People may use whatever they like – but I feel the menu should be expanded and that people should at least investigate before they throw bad language around the place (i mean, we are talking about programming here).

  3. November 6, 2014 at 3:57 pm

    Fl studio this written in Delphi.
    More Delphi programmers than anyone imagines. 🙂

  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: