You are viewing the original copy of this page

You are viewing your personal edited copy of this page

Introducing Lazarus

If you are haven't used Lazarus recently then this tutorial is for you. In it we give users a broad overview of Lazarus and some of its key features. We look at the type of applications you can create with Lazarus, and show you the core concepts to desktop application development it makes so very easy.

Highlights include the two way design process, events handlers, testing and debugging, and deployment. A brief gallery of applications I've personally created with Lazarus is included at the end, and I honestly believe it's the best tool in the world for developing platform agnostic desktop applications. Like the video says, give Lazarus a try

Tutorial Video: Introducing Lazarus

Questions and answers

Question: If someone wants to make a scalable, stable and high performant desktop application, why would someone choose Lazarus (Pascal) over let's say JavaFX (Java) or otherwise?

Answer: Lazarus supports constructs such as generic programming with type constraints, iterators and enumerators, user definable conversions, value types with properties methods and events, extension methods, and more.

In the video you'll see many examples of applications all written with Lazarus. They look fantastic, perform great, and they don't depend on a runtime environment.

Additionally, Free Pascal, the language Lazarus uses, includes events and properties, two core concepts important in creating desktop applications.

Properties are the nouns and adjectives which you place on objects or value types (structs). They allow you to have descriptive words associated with your types such as Color, Caption, and Width.

When you write:

Button.Color := Red;

The property setter is invoked causing code to execute Button and refreshing the area of the screen occupied by Button. This is different than having a bunch of Button.SetColor(Red), Button.GetColor(), Button.SetCaption(Text), Button.GetCaption(), and other such declaration. Without properties what's to say what nouns and verbs are important to the state and presentation of an object or value type? You just have a bunch of methods with nothing to distinguish them from properties as I've described.

Then there are methods, again something which Java is sorely missing. In Free Pascal they are their own intrinsic type.

Using an example again:

Button.OnClick := LoadFile;

We've associated some notification on Button with a handler method. Now how hard is that? Better yet, inLazarus you can browse all the events an object supports and double click it assign a handler. The Java method of inner classes and interfaces results in a lot of unnecessary typing and code. It's also antithetical to the concept of lambdas and closures, whereas in Lazarus they fit perfectly.

See also