I'm no expert, and Pascal is kind of a weird language by modern standards, but Lazarus does cross-platform desktop development using GTK or QT bindings.
Personally I like that it gets and stays out of my way. The UI design copies Visual Basic almost to a T and is a little dated by today's standards, but all the important bits are there.
Pascal in Delphi / Lazarus in its current form is a full featured language that implements large amount of common concepts expected from a modern language. I do not see anything weird in it.
They always implement some language feature, but then put some weird, arbitrary restriction on it. It is twice as weird in FreePascal, because the developers cannot decide if they want to make their own language or be Delphi compatible.
Some weirdness examples:
There is automated reference counting to get memory safety, but only for strings and arrays (and also interfaces but we get to that later)
There is mutability xor aliasing, but only for strings
There is a type to store sets of integers, but you cannot have more than 256 elements
There is a type to store a slice of an array, but it can only be used during function calls, so no one ever uses it. Also it looks like it cannot be used with a slice of length 0, unless it is a slice of an array of length 0.
Interfaces are a very common concept in OOP languages. They specify some methods, but not their implementation. Everyone here knows how they work and in Pascal they work in the same way. Except, in Pascal they are also COM interfaces and add automated reference counting to a class. It is weird in the reverse, too. You can have classes with ARC which are almost memory safe, but only if you use an interface.
Array indices start with 0, string indices start with 1. It is already weird, but you can get used to it. But now they added OOP like string functions and it became weirder. Copy(Str, ...) becomes Str.Copy(..). And all the new methods use 0-based indices for strings.
My career took me to C-like languages and scripting environments like Ruby or Python. And (love it or hate it) most of the world thinks in JS nowadays. Some aspects of Pascal are really strange or awkward to me, like the rules for whether or not a statement in an `if` block needs to be surrounded by `begin`/`end`, or where the semicolons go in a particularly complicated, nested instance of said `if`.
But I am not a master Pascal programmer by any means. You sound like an expert.
Pascal might not be weird but it is unpleasant. It has many inconveniences to offer the modern programmer. In its day, in comparison to C -- by programmers for programmers -- Pascal was derided by one computer scientist as "a police-state language" for its many strictures and missing affordances.
Highly invested in Electron, but I love Lazarus. I find it unmatched in what means developing cross-platform native apps, I only wish more people would know about it and use it, popularize, make noise, contribute.
The maintainers are absolutely awesome guys, the helpful and kind type.
> Lazarus does cross-platform desktop development using GTK or QT bindings
Not just GTK (mostly for Linux) or QT (for any) but Win32 (for Windows) and Carbon / Cocoa (for macOS) - so it can produce native GUI. This means smaller codebase and much better user experience.
I have used it for many years. For me it's still the only IDE with a fast compiler that creates native applications for Linux and Windows (and many other OS). And it doesn't require additional runtime libraries to be installed, so just download and run the application.
BTW: I created a Personal Kanban Task Organizer that is automatically built for Linux and Windows. It uses lazbuild in a GitLab CI Docker Container:
I am still salty that it took 20 years for .NET to achieve a similar native experience, and lets see if they don't bork it, like the previous features.
A couple weeks ago I sat down with this and tried to build a simple client for an HTTP API. Three hours later, having read about all sorts of prebuilt proprietary components without being able to try writing any code at all I gave up. Can anyone point me towards a library that will help me make somewhat-complex HTTP Requests on this platform? Something more than GET, that allows me to set headers?
Those days I'm using libcurl with the bindings that are supplied with Lazarus/FPC... works perfectly fine (tested on Windows and Linux, I suppose MacOS will work too... on Windows you need to install the DLL, e.g. libcurl-x64.dll). No need to install anything on Lazarus/FPC. Below a basic (incomplete) example of a GET request with a custom header, but as this is just a binding to libcurl, it basically allows you to do anything, including other protocols (libcurl can even have SMTP support, depending how it is compiled).
uses libcurl;
function curl_callback(data: pointer; size: size_t; nmemb: size_t; str: PStream): size_t; cdecl;
begin
// do something with incoming data
end;
var http: pCurl;
hdr: Pcurl_slist;
begin
http := curl_easy_init();
// [...]
hdr := curl_slist_append(NIL, pchar('Authorization: Bearer ' + EncodeStringBase64(AUTH_TOKEN)));
curl_easy_setopt(http, CURLOPT_HTTPHEADER, [hdr]);
curl_easy_setopt(http, CURLOPT_WRITEFUNCTION, [@curl_callback]);
curl_easy_setopt(http, CURLOPT_URL, [pchar(API_URL)]);
// [...]
if (curl_easy_perform(http) <> CURLE_OK) then begin
// [...]
end;
end.
I had the very same experience, and ended up using the wikipage posted above. But I had to fix it because there were some outdated information.
It's not that Lazarus lacks features, the problem is that the documentation is lacking and scattered. I found that the best way to learn Lazarus is to refer to some good Delphi books, provided that they are not too recent. (The Internet Archive has a few.)
I use the synopse mORMot library for server side rendering http server and database access. It has well written documentation with lots of examples on how to get started. IF you have any questions I am free to answer them.
I'm a fan of Wirth languages in general and had the pleasure of writing DOS applications in Topspeed Module-2 in the late 90s. I generally find the Pascal/Modula/Oberon languages fit my cognitive abilities well. Perhaps it's because of the need to plan out definition and implementation separately as well as use of units/modules - I don't really know tbh, but it just feels ok to me.
I've dipped in and out of FPC/Lazarus over the years, and will give this a re-look, especially now I'm inspired by some of the comments in this post.
Apologies if this is not allowed on HN, but there is Topspeed Modula-2 at this link. I think it's fully abandoned, but I'm still a bit uncomfortable with the ethics of sites like this.
Please - usual security caveats apply of course. I have not installed this myself to check out for malware. It is my intention to try and install it under FreeDOS on an old, air gapped, laptop at some point. Bring back some memories!
Lazarus is great! While FPC and Lazarus make it very easy and productive to make cross-platform GUI software, people should know that mORMot (https://github.com/synopse/mORMot2) makes it very easy to develop cross-platform web apps.
mORMot has been around for over a decade, the feature-set is very rich and mature, and the development and user forums are also very active - you can easily confirm that by checking the github repo's commit logs and visiting their forum.
mORMot's ORM is quite interesting - it's based on SQLite and supports all other mainstream databases through SQLite's virtual table mechanism.
> Would love to see a page with currently in production software written in Pascal.
Not sure about a page with a list, but I know that Altium Designer (one of the big commercial electronic design automation platforms) is at least partially written in Delphi. The executable of one of the last versions contains this string: "Embarcadero Delphi for Win64 compiler version 30.0 (23.0.21418.4207)". The platform even uses a Pascal-based scripting language named DelphiScript...
Original standard pascal was shitty. Strings had a strongly typed length, so you couldnt write a function which accepts strings of different length. Also (what I personally really dislike) the syntax doesnt allow you to write your own 'write' function (since lets call it variadic parameters were not allowed).
Turbo Pascal was better and Delphi pascal was great.
Pascal was the first programming language I had contact with, in high school. I have fond memories of it. Recently I looked into the status of current software written in Pascal. One thing I noted is few of them are packaged in Linux repositories. Wonder what causes that. Is it harder to package Pascal software for Linux, when compared to the average C package?
Pascal programs are much easier to package, since the usual Pascal libraries are linked statically. You get a standalone binary, you can distribute.
I have tried to submit some of my Pascal programs to the repositories, but nothing happens. You cannot pack it yourself, but need to get support from a distribution maintainer. They try to compile it, discover that they do not have a Pascal compiler installed, and give up on it
As of my last look a couple of months back, the extensions for Pascal in Code weren’t particularly usable. Omni Pascal may get there. There’s a language server in development but I don’t know anything about it.
My pet peeve with Lazarus, Deplhi and other visual RAD tools is lack of reusability and composability.
The built-in visual blocks are great, but building your own is nontrivial, you can not build them visually, you must code. To add insult to injury, in Delphi custom components were system-wide, not project scoped and required elaborate installation/registration to show up in the IDE.
Also pascal is insanely verbose, i.e. simple list operations (like building list of options for selecbox) span multiple lines of code.
I'd like to see a RAD tool with so good component design as Lazarus (the Delphi component model design is great and provides for fast, memory efficie t implementation) with a modern language such as TypeScript.
I'd suggest you take a look at gtk composite widgets. Also, take the care to use it with a modern language. Be warned that there are no good, well maintained, mature RAD IDE right now.
>To add insult to injury, in Delphi custom components were system-wide, not project scoped and required elaborate installation/registration to show up in the IDE.
It is even worse in Lazarus
To install a component, you have to recompile all of Lazarus
>Also pascal is insanely verbose, i.e. simple list operations (like building list of options for selecbox) span multiple lines of code.
Is one line per element verbose? It is just a function call.
You could write an array ['a', 'b', 'c'] like that and iterate over it
I really hope Lazarus will do away with full IDE recompilation and already adopt Delphi's style of pre-compiled objects (aka .DCU's) when adding a new component to palette in it. Until then it still feels like amateur, not "professional".
That style is for me personally a source of frustration every time I have to add a new component that shares the same name with an existing one, while in Delphi is just a simple error message and you can quickly switch between whichever you want. Heck, in Delphi I can fully name qualify both of them at the same time for runtime. Try do this in Lazarus with one that uses a design time 3rd party component and you're dead in the water.
This is because some major refactoring has to happen in RTTI and system units to support dynamic linking so that true delphi-style runtime dynamic packages can be supported. This is easier said then done because of how many platforms are supported by FPC & Lazarus.
>In contrast, Delphi IDE only runs on windows ... <
And? I don't see that as a minus in a world where virtualization and virtual machines exists. Also in Delphi IDE, in order to target Linux or Android, all you have to do is "select from this drop-down" and rebuild and/or deploy and voila!, you have executables ready to go. You try have a easy switchable Lazarus to compile for a new OS because I gave up. Right now, for each OS I want to target, I have a separate virtual machine with Lazarus installed there. Long live cheap RAM because I can run all 5 Lazarus VM's I need for creating cross-platform executables (Lin/Droid/iOS/MacOS/Win)
I'm no expert, and Pascal is kind of a weird language by modern standards, but Lazarus does cross-platform desktop development using GTK or QT bindings.
Electron Devs Hate This App!
(ok, maybe not really, but I wish they did!)
PeaZip is written in Lazarus (check out https://forum.lazarus.freepascal.org/index.php?topic=52417.0), and I've seen a few other odds and ends around the net mention the IDE in passing.
Personally I like that it gets and stays out of my way. The UI design copies Visual Basic almost to a T and is a little dated by today's standards, but all the important bits are there.
Still one of my favorite programming experiences in my life.
I've managed to easily port good sized modern Delphi project to run on Raspberry Pi using Lazarus.
Pascal in Delphi / Lazarus in its current form is a full featured language that implements large amount of common concepts expected from a modern language. I do not see anything weird in it.
They always implement some language feature, but then put some weird, arbitrary restriction on it. It is twice as weird in FreePascal, because the developers cannot decide if they want to make their own language or be Delphi compatible.
Some weirdness examples:
There is automated reference counting to get memory safety, but only for strings and arrays (and also interfaces but we get to that later)
There is mutability xor aliasing, but only for strings
There is a type to store sets of integers, but you cannot have more than 256 elements
There is a type to store a slice of an array, but it can only be used during function calls, so no one ever uses it. Also it looks like it cannot be used with a slice of length 0, unless it is a slice of an array of length 0.
Interfaces are a very common concept in OOP languages. They specify some methods, but not their implementation. Everyone here knows how they work and in Pascal they work in the same way. Except, in Pascal they are also COM interfaces and add automated reference counting to a class. It is weird in the reverse, too. You can have classes with ARC which are almost memory safe, but only if you use an interface.
Array indices start with 0, string indices start with 1. It is already weird, but you can get used to it. But now they added OOP like string functions and it became weirder. Copy(Str, ...) becomes Str.Copy(..). And all the new methods use 0-based indices for strings.
But I am not a master Pascal programmer by any means. You sound like an expert.
The maintainers are absolutely awesome guys, the helpful and kind type.
Not just GTK (mostly for Linux) or QT (for any) but Win32 (for Windows) and Carbon / Cocoa (for macOS) - so it can produce native GUI. This means smaller codebase and much better user experience.
I have used it for many years. For me it's still the only IDE with a fast compiler that creates native applications for Linux and Windows (and many other OS). And it doesn't require additional runtime libraries to be installed, so just download and run the application.
BTW: I created a Personal Kanban Task Organizer that is automatically built for Linux and Windows. It uses lazbuild in a GitLab CI Docker Container:
https://gitlab.com/moasda/task-organizer
It's not that Lazarus lacks features, the problem is that the documentation is lacking and scattered. I found that the best way to learn Lazarus is to refer to some good Delphi books, provided that they are not too recent. (The Internet Archive has a few.)
On Windows it is a wrapper around wininet and on Linux around another library Synapse.
The HTTP client is in the directory internet, the HTML/XPath parser in the directory data.
I've dipped in and out of FPC/Lazarus over the years, and will give this a re-look, especially now I'm inspired by some of the comments in this post.
https://vetusware.com/download/Topspeed%20Modula%202%203.10/...
Please - usual security caveats apply of course. I have not installed this myself to check out for malware. It is my intention to try and install it under FreeDOS on an old, air gapped, laptop at some point. Bring back some memories!
mORMot has been around for over a decade, the feature-set is very rich and mature, and the development and user forums are also very active - you can easily confirm that by checking the github repo's commit logs and visiting their forum.
mORMot's ORM is quite interesting - it's based on SQLite and supports all other mainstream databases through SQLite's virtual table mechanism.
Lazarus looks neat, but could a more modern IDE like vs code be used?
One thing it always come to mind is how Borland really did their documentation right, with lots of examples. Made it super easy to learn Pascal.
Here are some lists:
https://www.embarcadero.com/case-study
https://blogs.embarcadero.com/category/showcase/
https://github.com/Fr0sT-Brutal/awesome-pascal
Not sure about a page with a list, but I know that Altium Designer (one of the big commercial electronic design automation platforms) is at least partially written in Delphi. The executable of one of the last versions contains this string: "Embarcadero Delphi for Win64 compiler version 30.0 (23.0.21418.4207)". The platform even uses a Pascal-based scripting language named DelphiScript...
Turbo Pascal was better and Delphi pascal was great.
VMS Pascal was also quite alright.
Also Modula-2, which sorted out all the issues related with original Pascal, was introduced in 1978.
So everyone that focused on the original Pascal as reason for not using Pascal, was having a fossilized mindset.
I think that biggest culprit for it was the widespread of p2c in UNIX.
I have tried to submit some of my Pascal programs to the repositories, but nothing happens. You cannot pack it yourself, but need to get support from a distribution maintainer. They try to compile it, discover that they do not have a Pascal compiler installed, and give up on it
The built-in visual blocks are great, but building your own is nontrivial, you can not build them visually, you must code. To add insult to injury, in Delphi custom components were system-wide, not project scoped and required elaborate installation/registration to show up in the IDE.
Also pascal is insanely verbose, i.e. simple list operations (like building list of options for selecbox) span multiple lines of code.
I'd like to see a RAD tool with so good component design as Lazarus (the Delphi component model design is great and provides for fast, memory efficie t implementation) with a modern language such as TypeScript.
I guess I will need to write my own... once.
Deleted Comment
It is even worse in Lazarus
To install a component, you have to recompile all of Lazarus
>Also pascal is insanely verbose, i.e. simple list operations (like building list of options for selecbox) span multiple lines of code.
Is one line per element verbose? It is just a function call.
You could write an array ['a', 'b', 'c'] like that and iterate over it
That style is for me personally a source of frustration every time I have to add a new component that shares the same name with an existing one, while in Delphi is just a simple error message and you can quickly switch between whichever you want. Heck, in Delphi I can fully name qualify both of them at the same time for runtime. Try do this in Lazarus with one that uses a design time 3rd party component and you're dead in the water.
In contrast, Delphi IDE only runs on windows ...
And? I don't see that as a minus in a world where virtualization and virtual machines exists. Also in Delphi IDE, in order to target Linux or Android, all you have to do is "select from this drop-down" and rebuild and/or deploy and voila!, you have executables ready to go. You try have a easy switchable Lazarus to compile for a new OS because I gave up. Right now, for each OS I want to target, I have a separate virtual machine with Lazarus installed there. Long live cheap RAM because I can run all 5 Lazarus VM's I need for creating cross-platform executables (Lin/Droid/iOS/MacOS/Win)