Hacker News new | past | comments | ask | show | jobs | submit login
Programming with Lazarus, a Brief Introduction (getlazarus.org)
23 points by sysrpl on March 5, 2019 | hide | past | favorite | 17 comments



I've been playing around with Lazarus recently. It's a pretty nice way to knock up a GUI, and it compiles to a single executable, which is great. Which makes it kind of ironic that Lazarus itself is such a giant pain to use as a portable application. The Windows installer is packaged in such a way as to make it a pain to extract without running it, and even then I had to resort to Cameyo to make it work reasonably. Seriously, if anyone from the project is reading this, can you put some effort toward making this not such a giant pain?

I've also discovered that I'm not really a fan of Free Pascal as a language. Particularly maddening is not being able to assign an intermediate value to a variable in order to make code more clear without first declaring it at the top of the procedure.

Overall though, I really like it.


Regarding the installers, try this page that makes installing much easier:

https://www.getlazarus.org/setup/?download

That is the purpose of the get lazarus website, to make installing and customization easier.

Regarding variable declaration, part of the Free Pascal design is that you must declare things first before you can use them. Declaration must be separated from implementation code. This means you must all declare variables, with their types, before you use them in a statement.

  var
    S: string;
  begin
    WriteLn('Please enter you name:');
    S := ReadLn();
    WriteLn('Hello ' + S);
  end;


>Regarding the installers, try this page that makes installing much easier

Ugh. So my choices are: use the installer, or build from source. How Linux of them.

You apparently don't get this, but I don't actually want an installer to make it "easy". I'd rather it be simple. Give me a damned zip file containing the program and its dependencies, and make the tools support relative paths (or environment variables). Is that too much to ask? Yes, apparently.

> Regarding variable declaration, part of the Free Pascal design is that you must declare things first before you can use them. Declaration must be separated from implementation code.

Yes, I know. That's precisely what I don't like about it. It disincentivizes using variables to hold intermediate values for clarity purposes.


> You apparently don't get this, but I don't actually want an installer to make it "easy". I'd rather it be simple. Give me a damned zip file containing the program and its dependencies, and make the tools support relative paths (or environment variables). Is that too much to ask? Yes, apparently.

Do you find that a lot of software on Windows conforms with the way you think software installation should work?

I see "portable" versions of software in zip files sometimes, but always pretty small apps. This kind of packaging probably peaked in popularity prior to the introduction of Windows Vista. In the UWP era things are only more likely to trend away from this.


Actually yes, most software does. Notable exceptions include a lot of Microsoft software, unfortunately. They used to be better about it but they've become exceptionally lazy about it lately. Unix culture's "hardcode all the paths" influence I expect.

And popular does not mean good. In fact, it is often the opposite.


> Notable exceptions include a lot of Microsoft software, unfortunately. They used to be better about it but they've become exceptionally lazy about it lately.

I don't believe I've ever used a Microsoft product that offered installation via zip files in addition to installer. What are some examples?


Oh, if that's what you meant then no, lots of stuff isn't offered that way (though a lot of stuff is, and when it isn't you can often just take installers from various software and open them with 7zip to extract their contents without issue). However the entire Sysinternals suite is portable, and old MS software would at least give you the option to install to any directory of your choosing (after which you could usually move it around without problems). Newer software from MS pretends that this is possible, but really often just installs a tiny portion of the software in the chosen path and dumps everything else into the hardcoded default one.


I found your comment gratingly entitled, snarky and rude to someone who was only trying to help with something you are getting for free.

I doubt if that attitude earns you a lot of help and respect.


He literally told me nothing I didn't already demonstrate knowledge of in the post he replied to, implying he didn't actually read it. Providing "help" when you don't even take the time to understand the problem is not helping.


After Python and Java, Pascal feels unsettling. All the code examples I've seen so far put hundreds of lines in a single main file, making it incredibly difficult to read and understand. I'm not sure if I'm approaching it incorrectly or what (and I'm open to advice on how to read Pascal code and how to organize my own).


You don't need to put everything in one file. Just add a new unit (a source code file), and separate your code by functional use into those distinct units.

If you have enough units that are all related and you want to separate the code even further, put them into their own packages and import them into other projects.

You can be disorganized in any programming environment. It's your job as the programmer to name things correctly and break apart common code or task into their own reusable compartments.


Delphi 10.3, which is paid I know, and I know you know too, nevertheless has the possibility just like in C/C++ to declare the variables on the fly. Delphi before that didn't, it is a language feature just introduced.


Would it be wrong to say this is essentially a cross-platform implementation of WinForms? It reminds me of the workflow for WinForms.


Yes, you are wrong. The control library that allows this is based on Delphi's VCL or Visual Class Library. The VCL was design in large part by Anders Hejlsberg, the creator of C#. Hejlsberg helped design the VCL before he worked at Microsoft.

When Hejlsberg was hired away from Borland to work at Microsoft his first placement was to work on Visual J++. Microsoft was sued and lost because they were incompatible extensions to Java. These extensions were designed in part to support their own VCL like framework for Java, and resulted in a fragmentation the Java community, or so the Java suit claimed.

After the Visual J++ debacle, Microsoft decided to create their own Java like ecosystem, which is what .net was or is. The first few iterations were made quickly and featured Winforms as you mentioned. Winforms was very much influenced or based on the design of the VCL, with the help of Hejlsberg.

The Lazarus library (LCL) has the mostly the same class structure and same class methods as the VCL. So in summation, Winforms was inspired largely by the VCL, and the LCL is a close copy of the VCL.


Cool, I had no idea! So it'd be more accurate to say that this is a cousin to the predecessor to WinForms haha.


Not quite. Lazarus (which is just an IDE for Free Pascal), or rather the LCL (Lazarus Component Library), wraps native GUIs like Win32, Gtk, Qt and Carbon. It just provides a similar interface for visually designing your own GUI out of common components.


So kind of like wxwidgets?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: