Hacker News new | ask | show | jobs
by satvikpendem 910 days ago
I keep hearing about Pascal and Delphi, especially on HN, what is it and why is it special or talked about so much? I understand it's an older programming language but not why it's so loved. Any recommendations on how to learn it and is Lazarus a good option for the IDE or does VSCode suffice?
10 comments

I've written a lot of Object Pascal (meaning the Delphi dialect of Pascal, not the older Apple dialect) over the years and... i don't think there is anything special about it :-P. It has a bunch of neat features (and a bunch of not so neat pitfalls) but really IMO the three main reasons to use it is that:

1. It has decent backwards compatibility (code i wrote even 20 years ago compiles either out of the box or with very minimal change - e.g. if you used strings as byte buffers or if you relied on some esoteric RTTI implementation details you may need to change some things but the changes are quick and trivial).

2. Lazarus is a fast and responsive IDE with RAD functionality for making GUIs (and other stuff, e.g. i haven't used it myself much but you can do things like configure visually via the IDE how a webapp will respond to various URLs) and FCL and LCL provide a rich frameworks for desktop applications.

3. The compiler is relatively fast. Delphi's compiler (at least the classic one) is much faster but compared to -e.g.- current C++ compilers, FPC is much faster (it takes less than a minute to compile Lazarus itself and AFAIK the codebase is more than a million lines of code - there is 2 million lines of code in the repo but you don't compile everything).

But linking is slow, plus also only possible using ld.bfd. This causes problems here as I default to gold... For now; each time you start using or close lazarus you have to remind to change ld target.

Otherwise compilation is indeed fast because it uses a system of cache (just like delphi *.dcu system) plus it has modules. On top of that we can add... context-free grammar that's fast to parse, no _insane_ preprocessing (but still some, $ifdef and co).

There are preprocessor macros though you need to explicitly enable them and they don't support parameters (there are workarounds but in practice they're not really needed). FWIW i never had to use them so far, the most i needed from the preprocessor was DEFINE/IFDEF/ENDIF/etc.
Delphi and Lazarus are a continuation of the beloved gui-first idiom where you are greeted by an IDE capable of running code at design-time. That means you can add an sql connection component, create a query, connect it to a data source, connect the data source to a grid and fill it right there while designing your form to see how the result will look like when you run it.

The second reason to use it is: it builds for many targets and runs without garbage collection.

Lazarus needs to recompile and restart itself in order to use packages, but other than that, it's pretty stable and fast. VSCode can be used to edit Pascal code, but it is pretty irrelevant.

It's funny how that sort of immediacy is what people like about lisps, but to my knowledge there is nothing like the RAD interface Lazarus and Delphi have in the open source lisp world.
> there is nothing like the RAD interface Lazarus and Delphi have in the open source lisp world.

The key phrase there is 'open source' I believe, because tools like Lazarus come out of a pretty distinct Borland / Windows culture of making bespoke usually paid graphical development tools. Lisps have a lot of their roots in the academic and Unix culture with a lot of folks seemingly allergic to GUIs to this day. There's an interesting interview with Carmack from a year or two ago talking about this.

It seems like there used to be more of a paid, proprietary, GUI using culture for Lisp, too, in the form of Lisp machines and products like that. They used to not only advertise their programming environment, but also advertise Lisp machines for things like 3D animation and editing office documents.
> nothing like the RAD interface Lazarus and Delphi have in the open source lisp world

Maybe in Racket if you squint a bit?

https://github.com/Metaxal/MrEd-Designer/wiki

Would be cool to have a Lisp backend with a Pascal GUI
After learning BASIC in high school, as a CS student in the early 80's, my intro to computer science classes were taught in Pascal.

In college, we used DECWriter paper-based terminals and IBM 3270 terminals to write code. Our programs were batch processed on the school's IBM mainframe.

What's interesting to me is how well Pascal conceptually has held up with the current trend towards strongly typed languages.

When I look at Pascal source code today, it's remarkable to me how clean the syntax is. If our industry wasn't so driven by the hottest language/stack/framework that seemingly changes every 6-12 months, modern Pascal would still be a viable choice today.

Battlestar Galactica fans know the story line of how computers weren't allowed to be networked because that's what allowed the Cylons to gain access and nearly wipeout the human race.

In my fan fiction world, Free Pascal is the language the Colonies would use due to the Cylons exploiting the buffer overflows and the other issues of C/C++.

Kinda like: would we go the same route knowing what we know now about how using C for (nearly) everything turned out with vulnerabilities, etc.

For many people it was the first language they learned, which I think explains most of it. But the tooling was also very fast from a latency perspective, even on the slow hardware of the time, which tends to make for magical memorable experiences.
And also incredibly small.

Turbo Pascal 2.0 had an IDE with compiler and debugger in a binary less than 60kb (if the info I found googling is true). Of course nowhere near the capabilities of modern environments but state of the art at the time.

The debugging experience I had in Delphi 6-7 was still streets ahead of what I use today in Ruby.
>Turbo Pascal 2.0 had an IDE with compiler and debugger in a binary less than 60kb (if the info I found googling is true).

Turbo Pascal 3.0 had an IDE with compiler and debugger in a binary less than 40kb (if the info I found googling is true).

Things That Turbo Pascal is Smaller Than

https://prog21.dadgum.com/116.html

And it (initially at least) cost $50 vs. a few hundred dollars for other compilers of that period, like MS Pascal.
Programming in Delphi was fun and easy. It's probably because things were overall simpler then, but we seem to hold on to the idea that it was the tool. And maybe it was, I haven't tried Delphi in a while.
It's nostalgia, for the most part, and I say this as someone who loved, and still love, everything about it. But I don't use it anymore and wouldn't recommend it to anyone.

Everything started with Borland's Turbo Pascal back in the 1980s. It was an IDE with a lightning fast compiler and built in debugger. Extremely slick, and it was so fast that there was hardly any time to wait for a build. It was extremely small and produced fast programs. And it was very affordable. Everyone loved TP.

As a language, TP implemented its own dialect of Pascal that turned what was originally a somewhat clunky, limited teaching language into a "real" language; for example, TP had assembly language built in, so you could write hand-optimized code for things like low level graphics. Eventually TP added object oriented programming that rivaled other languages like C++. This was before modern languages like Java and C#.

Borland released a Windows version, but it was basically the same thing but with a GUI. To write GUI apps you had to use a library called OWL and basically define the UI in code, by creating objects like buttons and fields. It was quite good, and played to TP's strengths, but real game changer was Delphi, which ended up becoming TP's successor. It was an IDE which supported everything TP did, but reoriented it around designing Windows GUI apps visually.

In Delphi, you built your UI drawing components and dragging them around, laying out each window and attaching behavior such as click handlers. Some components represented non-visual components such as database connections. The beauty was what they called "two-way editing". Changing the GUI updated the code, and vice versa. A key concept was that the components you were editing were "live"; they weren't mocked-up versions of anything, but actually ran your code right inside the IDE. Programming in Delphi felt more "live" than with other stacks (like Visual Studio) because the whole design-build-test lifecycle was so fast.

Many people considered Delphi to be a more advanced, "grown up" alternative to Visual Basic, which emerged around the same time and was in many ways quite similar, though Delphi was arguably much better. And indeed, since that time, nothing has really managed to match Delphi's ease of development; not VB, not Interface Builder, not whatever Sun was doing with Java and Swing at the time. Tons of people were extremely productive making GUI apps in Delphi, and as with TP, there was a strong developer culture around it, especially in Europe.

In both the case of TP and Delphi, the language was probably the least interesting thing about it. Pascal has always been a little verbose and clunky, and people succeeded despite of it. People who didn't grow up with TP/Delphi who look at it today will almost certainly wrinkle their noses at the sight of this language, and they'd be sort of right. It was never a great language. But it was an incredibly productive one. The speed, elegance, and "vertical integration" of these IDEs were significant force multipliers.

Delphi started to lose for many reasons: Borland's mismanagement, Microsoft playing hardball with them, the emergence of Java, the emergence of the web, the steadily increasing dominance of C++ (and rejection of niche languages), and so on. The fact that ObjectPascal was a niche language meant that Borland was always the underdog and suffered from poor interoperability with standard C/C++ tools; Delphi didn't consume C header files, so a new C library (DirectX or MAPI or TAPI or whatever) always required manually writing glue code to talk to it. Delphi fans were loyal, but they were always second-class citizens on Windows. (Even though Borland eventually launched a C++ version of Delphi, it never really caught on.) The world's focus away from desktop apps to web apps was just one more thing Delphi couldn't keep up with. And I say that as someone who wrote Microsoft IIS web servers in Delphi for a long time and built products that required interfacing with C libraries.

If Borland had been able to keep their eye on the core product and stay true to their development tool company roots, they might have survived to this day. But they didn't. TP and Delphi are now relics of a bygone era, much like the Amiga, the Acorn, the Nokia Communicator, and other examples of "superior tech that never took over the world." But like those other examples, the superiority is local to that era. You wouldn't bother using an Amiga for your main work today, and I wouldn't use Delphi. ObjectPascal was neat, but today it's antiquated compared to languages like C#, Rust, and Go. Delphi was always Windows-only, and these days cross-platform support is more important.

I should add that I've never used Lazarus. It looks like a Delphi clone, and it's probably quite nice.

Great insights, thanks. I used Delphi for a little bit and thought it was nice (much better and more "professional" than Visual Basic), and wonder what happened to it.
The UI integration you described would be awesome for mobile dev.
Back in the day, there were a lot of great widgets for Delphi and a lot of small companies selling commercial widgets. That ecosystem made Delphi (and to some extent, C++ Builder), extremely popular.

Most of those vendors moves to .NET (usually C#) over the years, and eventually, to the web.

For comparison, Qt, which is awesome, has never had such an ecosystem.

The nicest thing is the IDE, so using VSCode you're missing the point.

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

(watch at 2x speed for an idea how fast I worked at the time :=))

I won't describe features that are no longer unique. Most other IDEs have catched up, but twenty years ago, Delphi was much better than anything else. VB had a similar style, but the Object Pascal language was more powerful. Also you were able to program IDE plugins.

The work that FPC and Lazarus teams have done is incredible. Borland was a big SV company. These are voluntary programmers and have outdone Delphi.

Edit, with one more thing: you could program Delphi components (and you can program Lazarus components) using the same Object Pascal language used for the applications. Components can be graphical UI controls (special buttons, edit boxes, calendar pickers, etc.) or non-visible database, communication, processes, really any kind of objects, that can also interact with the IDE.

Pascal was used in the USA for a time on the high school AP tests (advanced placement) which are often used for college applications. So some know it from that.

As well, Wirth was an influential computer scientist and he had many students who went on to do many other things in both the Pascal family of languages and others as well. So his former students have influenced computer science also.

It's not hard to learn. It was often taught as a "first language" the place that I guess Python occupies today. Essentially a more sophisticated BASIC
Essentially a more sophisticated BASIC

Absolutely wrong.

PASCAL was invented by Professor Niklaus Wirth at ETH Zurich specifically for teaching structured programming, circa 1970 (year of first release). It's a descendant of ALGOL (1960), which was pretty much the first structured programming language and introduced functions that could be recursively invoked -- ALGOL is the ancestor of C and PL/I as well as Pascal and relatives (Modula-2, Oberon, etc) and is hugely important.

BASIC came out of Dartmouth College in the US in the mid-sixties and the emphasis was on interactive invocation: early BASIC was almost completely non-structured (GOTO for flow of control, minimal subroutines, IF statements with no ELSE).

While both Pascal and BASIC were intended as teaching languages, they took radically different views of what to teach. And Python is different again: Python has the virtue of a simple and consistent core syntax, but wasn't designed for teaching -- it was designed for scripting, and was developed in the early 1990s for computers with 2-3 orders of magnitude more resources than early BASIC and Pascal.

Object Pascal/Delphi (Delphi was Borland's proprietary implementation with RAD for Windows) is an outgrowth of Borland's Turbo Pascal from the early 1980s, which in turn took Wirth's Pascal and added some essentials that had been missing -- notably dynamically allocated strings, modules, and finally object encapsulation -- that made it much more suitable for writing serious code: for a while Turbo Pascal was a viable competitor for C on MS-DOS.

But Pascal is in no way related to BASIC.

(Algol 60 was also an important influence on Scheme! So is Scheme a lisp or an algol? Yes.)
It's not wrong.

I stand by exactly what I said.

In practice, it was taught as an introduction to programming.

For a decade or two, children learned Basic and highschool/JC aged kids learned Pascal.

Of course they aren't the same thing. It'd be like saying kids ride tricycles and then bicycles and clapping back about penny farthings, velocipedes and dandy horses while tricycles started as a wheelchair device.

Give me a break. The point was Pascal is accessible and easy to learn.

I've met both Kurtz and Wirth and I'm sure they wouldn't have a problem with this.

>"It's not wrong."

I think the post you are replying to got it exactly right. IMO your post got it all wrong.

>"I've met both Kurtz and Wirth and I'm sure they wouldn't have a problem with this."

Modern Delphi/FreePascal and the one created by Wirth are very different. I would not call it the same language. And what you "sure they wouldn't" is totally irrelevant.

From the perspective of the learner, the actual cognitive work to get to mastery is of a similar order of magnitude and similar nature. The feature crossover is probably 80-90% depending on how you choose to enumerate them.

The question was about that, specifically, not about the history, not about the nuanced details of who created it, but about how hard it was to pick up.

Specifically "Any recommendations on how to learn it"

It's not in the class of R, FORTH, assembly or Haskell. It's not like Erlang. It's as conceptually approachable as Basic and historically was taught after Basic to tens of millions of people over the course of two decades, in that order.

>"The feature crossover is probably 80-90%"

It is not.

>"assembly "

It has assembly built in.

Java is also a more sophisticated basic and is commonly taught as an introductory language.

I’d much rather be taught Pascal than Java. Probably 20 year old me would feel differently, but the 20 year old me was a much worse software engineer (actually, he was just a self taught programmer kid.)

> Java is also a more sophisticated basic

Is there some hidden context to these comments, like "we've all just inhaled industrial solvent fumes and then posted on Hacker News?"

right. "First Language" is a moving target and it is not something a language wants to have because you get a bunch of really crappy code in that language and it ruins the language's reputation.

After the rise of the web in the early 2000s it moved around a bit. Java, PHP, Ruby, Javascript, even Flash sometimes, but now it's generally Python and it's so far bucked the trend and managed to remain respectable. Pascal and BASIC had a grip on that slot probably since the late 1970s through maybe early 2000s. Before that it was Fortran.

I did y2k stuff 25 years ago, there's a lot of shit fortran out there.

Yes, it was the programming language I was taught in school. So there is some nostalgia at play, for me at least.