Hacker News new | ask | show | jobs
by superdisk 1036 days ago
I know he's talking about Delphi here, but FreePascal+Lazarus is still one of my secret weapons. It has some sort of supernatural force field which causes people to ignore it and unfairly denigrate it; meanwhile I whip up desktop applications in hours that would normally take days.
6 comments

The best part is that Lazarus is write once, compile anywhere. It works on all major desktop OSes and even some less mainstream ones.
Yeah though in practice it is more "write once, compile anywhere, debug everywhere" :-P as there are often minor (and sometimes major) inconsistencies between the underlying widget libraries (not Lazarus' fault though, if anything there is a lot of effort put into providing as much consistency as it can).
Last time I looked at this I couldn't really find an easy standard way to make HTTPS API calls and parse JSON, but only spent an hour or two playing with it. Can you point me at the canonical way to do this? What's the Requests of FreePascal?
Fun, I struggled with json parsing for a long time, and have done it for the first time with freepascal. Maybe this can help you : https://medium.com/@marcusfernstrm/freepascal-and-json-337c0... ?
That is way easier than the stuff I was reading before which said I needed some sort of 3rd party paid component for it, nice.
Third party paid component for parsing strings into basic data types and making http requests? That doesn't sound right even for late 20th century
I love comments like this because it shows me how diverse this field is, and how different everyone's experience and expectations are.

As a counterpoint to your comment, I make a living writing high-quality libraries. Everything I make is "in the box", but its not hard to improve on that.

My most popular tools are around string functions, json and xml readers/writers and network functionality.

So, on one hand I'm selling ice-cream in Alaska, on the other hand, it's good ice-cream.

It's a small market, a pimple on a niche, but its big enough to keep me going and that's big enough for me.

Free Pascal has fcl-web which should provide a HTTP/HTTPS client (among other things, it can be used to make web apps), though it comes with libcurl bindings out of the box so you could also use that too. fcl-json provides a JSON parser. FWIW "fcl" means "Free Component Library" which contains various tools (mainly exposed as classes).

The packages[0] directory of FPC contains a lot of stuff that come out of the box with the compiler and they often have an "examples" and/or "tests" directory with code you can check. There is some documentation[1] but sadly FCL is really not that well documented - you just have to check the sources for most things.

Note that this is for Free Pascal itself. Lazarus builds on it (LCL, the "Lazarus Component Library", is built on top of FCL) and adds a bunch of additional components of its own. Though usually for non-GUI stuff you just use the Free Pascal classes, Lazarus has some of its own "wrappers" that integrate with the IDE and the form/object designer. The "weblaz" package (it comes with Lazarus but you need to install it manually from Package -> Install/Uninstall Packages) provides a bunch of components for working with the web (mainly for making web apps), including the "TFPHttpClient" component which can be used to make HTTP requests. As a simple example, if you throw a TMemo (multiline text editor) control in a form, throw a TFPHttpClient component and then doubleclick on the form to edit the code to execute during the form's creation you can type "Memo1.Text:=FPHTTPClient1.Get('https://news.ycombinator.com/');" and it will put the HTML code for this forum in the memo (note that you may also need to add the opensslsockets unit in the uses section at the top of the code). Of course that is a very simple example but if you browse the properties and events of the component in the object inspector as well as the available methods by typing "FPHTTPClient1." and pressing ctrl+space in the code editor you can find most of the other functionality the component provides.

[0] https://gitlab.com/freepascal.org/fpc/source/-/tree/main/pac...

[1] https://www.freepascal.org/docs-html/current/fcl/index.html

For Delphi it is a combo of the Indy project (IdHttp), and superobject (probably other json parsers too but superobject is quick and fairly solid).

However, given I've yet to find Delphi code that straight up compiles in Lazarus/FreePascal, you probably have your work cut out for you, but if you google for [superobject/indy] for Lazarus, others have started those hikes, and you may find there are working versions of one, or possibly both of them. I've never looked.

Does superobject compile under Lazarus?
A roadmap for Lazarus just released on 19 Aug 2023 (3 minutes video)

https://www.youtube.com/watch?v=ixQ2LZTzVJQ

Is there text form?
Thanks for sharing!
The one negative I've found with Lazarus... And this is purely if you were someone coming from a Delphi background, or were planning on Lazarus being your "get out of jail free" card if [Embarcadero/(whoever owns it now)] decides to stop updating Delphi (and even then you could probably manage it's lack of updates for years, hell I stayed on Delphi 2007 for a good 8 or 9 years after XE, XE1, XE2 et al had been out).. Anyways, back to my point, the one major negative I've found with Lazarus is you simply can not take Delphi code, and compile it straight in Lazarus... There are many many many very subtle differences. Totally fine and understandable, but if you were planning on taking the attitude of "Stuff Delphi, lets take our 400k line project and move to Lazarus", you are going to have a bad time.

Having said that I've done a couple of my own projects at home in Lazarus. It's fine, it feels dated, going back to the original Delphi / VB style of RAD tool with form designer/code editor as floating windows etc. The intellisense leaves something to be desired, but I can't be too critical because it's not like I'm putting my hand up to contribute to the project. If you look at what you get for what you pay for, it's quite literally amazing.

> It's fine, it feels dated, going back to the original Delphi / VB style of RAD tool with form designer/code editor as floating windows etc.

Note that if you install the "anchordockingdsgn" and the "dockedformeditor" packages you will get a UI that uses a single toplevel window with all the previously floating windows being docked inside it (you can still un-dock them) and a form editor that is inside the window (without the "dockedformeditor" you can still get the single window for the IDE but form editing will happen in floating forms).

Personally i prefer the floating windows UI as i overlap windows a lot (and i'm used to it - also i have a dedicated virtual desktop for coding which helps), but there are enough people who prefer a single window UI that this should work without issues these days (it used to be somewhat very unpolished at the past, like installing the package and having a shotgun blast in the IDE panels :-P so you'd spend a few minutes moving and resizing the panels in sane places).

Thanks for the info, anchordockingdsgn/dockedformeditor, sounds like it will solve my aesthetic gripe with Lazarus.
Hi everyone I operate an irc channel to assist pascal/Delphi programmers with developing projects. https://libera.chat/guides/ IRC.LIBERA.CHAT Ports [6667 plaintext ] or [6697 secure] channels #fpc #pascal. It is not necessary to create an account to participate.
Whipping was never the problem with Delphi, long term maintenance was.
I find Pascal based languages to be much more readable than most JavaScript and C++ code bases.
> long term maintenance was.

How so?

Because it's all proprietary, and continuously deprecated to blend better with the latest hype.

I did 13 years with Delphi, full time.

We have a fair bit of code in production that was written over 20 years ago. It just works. It has gone through strings switching from 8-bit to Unicode (16-bit) with hardly any modification.

We upgrade every year or so, and in almost all cases it's smooth sailing.

Delphi has been quite good so far when it comes to long term maintenance.

Not my experience.

First they deprecated the bundled DB bindings, after hyping them to hell and back; then the bundled report generator. We had more than a million lines of code depending heavily on those.

Proprietary, with almost full sources to the standard library, however. There is indeed a bunch of half-assed stuff, but that's easy to ignore. In general, Delphi moves slowly and hardly ever breaks backward compatibility. Only the transition to Unicode in D2009—oddly not mentioned in the article, along with generics—was a little rough. Apart from that, decades old code keeps compiling/running without issue. It's mostly third party components needing updates sometimes, especially if they're shipped as compiled units or integrate with the IDE.
Mate I've got a project whose first lines of code were struck back in the 80s in Turbo pascal. Your "continuously deprecated" argument doesn't hold a lot of water from where I sit... In terms of actual language features/changes that have caused deprecated status, those are very few and far between. Maybe some VCL database controls, for sure it would have sucked to have built stuff relying on interbase, but that is not a language/compiler feature, that was CodeGear EOL that particular project (I had to manage the exit strategy on one of our projects where it relied on that crapware)

Even library developers are pretty good at pumping out versions of their libs that have support for even Delphi 5. I know of at least 2 people who are still doing windows dev on Delphi 5 or maybe 7, I can't recall.. the very definition of "from my cold dead fingers".

Suffice to say if you were one of those real hold-outs, not updating to the latest.. you wouldn't have generics, dynamic arrays, lambdas/anonymous functions, and you would probably struggle to grab much code written in the last decade and compile it straight up.. but that would probably be the case for a number of languages that have had core features added to them over time.

The fact that the system is proprietary certainly is an issue, but every install always ships with all the source code of the RTL, VCL, and clear instructions on how to compile it with a "you're on your own now" sense of adventure.

It is still slower than Web fronted "today's framework to take over the world!".
With the emphasis on "today's".

As in, new one tomorrow, or in a week. Wish project timelines matched ;-)

Fair enough re Delphi, but the previous comment pertained to FreePascal with Lazarus, which are FOSS and well-maintained.