Readit News logoReadit News
tomc1985 · 4 years ago
So glad to see this on the front page!

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.

andrewshadura · 4 years ago
If it copies anything, it’s first of all Delphi, around the version 7 :)
nobleach · 4 years ago
And 7 was just "let's try and add some 'web' to Delphi 6". And 6 was "Hey, Kylix is gonna be huge on Linux, so let's try and align Delphi 5"...

Still one of my favorite programming experiences in my life.

FpUser · 4 years ago
It is way, way more than Delphi 7.

I've managed to easily port good sized modern Delphi project to run on Raspberry Pi using Lazarus.

tomc1985 · 4 years ago
Having never used Delphi, the parallels to VB were uncanny. So I guess Delphi copied VB
FpUser · 4 years ago
>"Pascal is kind of a weird language"

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.

benibela · 4 years ago
All of it is weird

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.

tomc1985 · 4 years ago
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.

twangist · 4 years ago
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.
istoica · 4 years ago
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.

webmobdev · 4 years ago
> 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.

moasda · 4 years ago
Happy to see Lazarus on the front page.

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

pjmlp · 4 years ago
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.
ctoth · 4 years ago
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?
ale42 · 4 years ago
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.

tomc1985 · 4 years ago
https://wiki.freepascal.org/fphttpclient isn't good enough? Why do you need a library?
ziotom78 · 4 years ago
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.)

revanx_ · 4 years ago
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.
thijsvandien · 4 years ago
Indy is very popular, especially among Delphi users (shipped with it): https://github.com/IndySockets/Indy.
edwinyzh · 4 years ago
https://github.com/synopse/mORMot2 Very rich and mature feature-set, with active development and active user forums.
benibela · 4 years ago
I wrote my own library for that: https://github.com/benibela/internettools

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.

digitalsankhara · 4 years ago
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.

timbit42 · 4 years ago
I've been looking for a copy of Topspeed Modula-2 but could only find Logitech Modula-2 online (yes, that Logitech).
digitalsankhara · 4 years ago
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.

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!

pjmlp · 4 years ago
At least his influence lives on C#, Scala and Go.
digitalsankhara · 4 years ago
I think I read that aspects of Modula 2 found their way into Python's modules.
kcartlidge · 4 years ago
Upvoted for TopSpeed Modula-2 under DOS. Amazing for it's day; massively ahead of the competition.
digitalsankhara · 4 years ago
I found it a very comprehensive dev tool. I still have the manual, having safely survived many moves!
edwinyzh · 4 years ago
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.

xet7 · 4 years ago
How to compile mORMot ? Is there example repo of some Login/CRUD website made with mORMot ?
lastdong · 4 years ago
Pascal was great! Would love to see a page with currently in production software written in Pascal.

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.

clouddrover · 4 years ago
> Would love to see a page with currently in production software written in Pascal

Here are some lists:

https://www.embarcadero.com/case-study

https://blogs.embarcadero.com/category/showcase/

https://github.com/Fr0sT-Brutal/awesome-pascal

lastdong · 4 years ago
Great stuff. I’m still so surprised to find Pascal popping up now and then in HN, and actually base for large codebases still in production nowadays.
ale42 · 4 years ago
> 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...

andi999 · 4 years ago
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.

pjmlp · 4 years ago
Something that was already sorted out by USCD and ISO Extended Pascal time, features that were later adopted by Turbo Pascal.

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.

lonk · 4 years ago
FL Studio : A digital audio workstation written in pascal https://learndelphi.org/fl-studio-is-a-massively-popular-dig...
lastdong · 4 years ago
No way! This is amazing, I used to play with Fruity Loops many moons ago, it’s really well done. Thank you for sharing.
Qem · 4 years ago
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?
benibela · 4 years ago
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

blame-troi · 4 years ago
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.
lastdong · 4 years ago
Omni Pascal looks exactly what I was thinking about. Definitely one to keep up with. Thank you
janci · 4 years ago
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 guess I will need to write my own... once.

Deleted Comment

marcodiego · 4 years ago
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.
benibela · 4 years ago
>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

unnouinceput · 4 years ago
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.

rscho · 4 years ago
Be the change you want to see?
revanx_ · 4 years ago
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 ...

unnouinceput · 4 years ago
>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)