99 points · by mariuz · 3y ago · 121 comments
No metaprogramming in the language meant we had some parts of the code that were written in pascal to generate pascal code before compilation of the main project.
The code was so verbose, and to get the same thing done in alternative languages would have easily been twice as shorter.
Refactoring always took twice as long as I thought it would. Just moving semicolons around was enough to break my concentration when I was in the flow.
I think the kicker was identifiers being case insensitive. That alone would have been enough to drive me crazy. People complain about Nim's case insensitive features a lot, but Nim's implementation is actually good and orders of magnitude better than Pascal's.
Also hiring a good pascal programmer was next to impossible for us at the time.
I don't know why anyone would pick Pascal today over Nim, Zig, Rust, Julia, Go etc.
Weird...if you are talking about Generics, FreePascal has them and work just fine, plus it compiles instantly!
Here's a demo:
program UseGenerics;
{$mode objfpc}{$H+}
type
generic TFakeClass<_GT> = class
class function gmax(a,b: _GT): _GT;
end;
TFakeClassInt = specialize TFakeClass<integer>;
TFakeClassDouble = specialize TFakeClass<double>;
class function TFakeClass.gmax(a,b: _GT): _GT;
begin
if a > b then
result := a
else
result := b;
end;
begin
{ show max of two integers }
writeln('Integer GMax: ', TFakeClassInt.gmax(23, 56));
{ show max of two doubles }
writeln('Double GMax: ', TFakeClassDouble.gmax(23.89, 56.5));
end.> Weird…if you are talking about Generics
But aren’t they very clearly talking about metaprogramming, which is a completely different thing than generics?
{$MODE DELPHI}
{$modeswitch advancedrecords}
type
TMatrix<T, R, C> = record
fCoordinates: array[R, C] of Double;
end;
function mul<T, R, X, C>(A: TMatrix<T, R, X>; B: TMatrix<T, X, C>): TMatrix<T, R, C>;
var
i: R;
j: X;
k: C;
begin
Writeln('yep');
Writeln(High(R)); // 3
Writeln(High(X)); // 4
Writeln(High(C)); // 3
for i := Low(R) to High(R) do
for k := Low(C) to High(C) do begin
Result.fCoordinates[i, k] := 0;
for j := Low(X) to High(X) do
Result.fCoordinates[i, k] += A.fCoordinates[i, j] * B.fCoordinates[j, k]
end
end;
type
R1 = 1..3;
R2 = 1..4;
var
A: TMatrix<Double, R1, R2>;
B: TMatrix<Double, R1, R1>;
C: TMatrix<Double, R2, R1>;
begin
mul<Double, R1, R2, R1>(A,B); // should fail because B would have to have as many rows as A has columns--and it doesn't.
mul(A,C) // does not work even with a right-size C--even though it should
end.The first bit is an interesting case and i wonder why it happens. It seems the root cause is that it considers the two type specializations equivalent as even ignoring the generic functions something like "A:=B" is allowed. I trimmed the code down to this:
{$MODE DELPHI}
type
TMatrix<R, C> = record
X: array[R, C] of Double;
end;
type
R1 = 1..3;
R2 = 1..4;
var
A: TMatrix<R1, R2>;
B: TMatrix<R1, R1>;
begin
A:=B;
end.
This is clearly a bug and not intentional behavior as doing the specialization by hand shows an error as expected. Also it seems related to multidimensional arrays as with a single element it also shows an error. Note that the other way (B:=A) doesn't work, so my guess is that at some point the type compatibility comparison only checks if assigning one array would fit memory-wise into the other.I'll check against latest trunk later and if it happens i'll file a bug report.
* The language has evolved. Delphi's pascal compiler has generics, lambda expressions for both proc and function, it has containers, map and filter functions.
* Design-time: You know how your code will behave without running it, as you are dragging and dropping components. It will draw data from your database and show it in dropdowns and grids. You have fine-tuned control ober widget alignment and anchoring .
* Data modules: Having your orm and data layer as composable components enforce separation of ui and db operations.
* Devexpress: They make the best grid components by far. I use their web products as well.
For the cases Delphi is a great choice, I'd steer clear as far as possible from julia, zig, go and nim. Maybe C# comes close.
When writing desktop apps probably the familiarity with well known IDEs such as Delphi or Lazarus makes the difference. Unfortunately decades passed, still nothing comes even close to them for rapid GUI development. Should one day Lazarus support different languages such as the ones you mentioned, we'll probably hear a rumble around the world. However things in certain fields progress much quicker, and I wouldn't be surprised at all if in some time we could use AI to analyze a drawing then create the corresponding desktop interface description to be linked with non GUI code.
1. https://pascalabc.net/en/ (PascalABC) 2. https://github.com/pascalabcnet/pascalabcnet (PascalABC GitHub)
For non-GUI apps, sure probably Nim, Rust or Go.
When were the last time I code in Swing/JavaFX? 4 or 5 years ago, perhaps. The 3rd party libs available for Delphi/FPC are more than enough for my needs.
Maybe Pascal isn't good for large code bases, but the same is true for Python, too. And nobody hates Python.
It's a language which had a reason to exist 25 years ago, but has since been surpassed in every way by other faster, more robust, more compatible languages that don't have such quirky syntax. So a lot like Pascal actually. (To be fair to Pascal, its syntax wasn't anything as inconsistent and frustrating as Python's.)
The same could be said about C++, but yet, here we are. Stroustrop's quip comes to mind: "There are languages people complain about, and languages no one uses". Just look at how much people complain about JS.
I don't know how old people here are, but from the early 2000's till probably the mid 2010's, Python really was the great language, with few alternatives - at least when you consider the libraries available for it.
It's not an accident that people began using it heavily for numerical computing. The only viable alternative at the time was MATLAB.
Pray tell, which ones are those?
Unfortunely most complaints about Pascal keep being reduced to that 1970 version of the language.
[0] https://people.inf.ethz.ch/wirth/ProjectOberon/PO.System.pdf
But yes, modern stuff should not be judged by the 1970 edition. I got soured on Pascal by having to use an ISO standard compiler on an embedded system; it was painful in several areas. But I shouldn't judge modern C by pre-ANSI C, or modern C++ by cfront. So, while I still say that ISO Pascal was deeply flawed, I shouldn't hold that against all Pascal versions.
I would take almost any other language, including Pascal, over Python for anything beyond a page of code.
The more I use julia, the more I hate python. Which is a lot by now.
Can you elaborate on this? In what ways specifically is it better?
Pascal evolved into Modula-2 and then Oberon which is both smaller and more powerful.
It produces of course far better code than free pascal/lazarus. It could even beat all other gcc backends. As you see in some gcc benchmarks, the modula2 part produces the smallest and fastest code of all backends, esp. C++ and C.
Which would be nice for safer system languages, since we have only ADA/Spark. And ADA is lost in commercial/military hell, even with Spark.
But we would really need a Concurrent Pascal or Oberon dialect, similar to Go. Nowadays I would just add dialects on top of modula2, like the different C standards.
Modula-2 beats C and Fortran on Fourmilab's FBENCH. See https://www.fourmilab.ch/fbench/fbench.html
There was a time when Pascal was almost as popular as C. In school we learned Pascal after learning Basic and before learning C. I think in US the East coast preferred Pascal and the West coast preferred C.
Is it the association with learning to program and for this reason with kids?
Or is it just the syntax that makes more sense to uninitiated, and thus less like some secret knowledge passed only to the worthy?
Also why Modula-2 exists since 1978.
edit - Apparently it was released yesterday?
https://computerhistory.org/press-releases/chm-makes-apple-l...
From GNU I wish projects like GNUStep + Applications were much easily built instead of having to do a chain of compilings. Also, Gnome was promoted from GNU back in the day and now it's corporateware too tied to profit/XML/complex settings so they gain lots of money on support but hindering the libre projects depending on GTK+.
>Note that the Raspberry Pi Pico is not supported by Ultibo core as it is based on a microcontroller instead of a microprocessor and is not able to support the features required by Ultibo core.