Recent

Author Topic: Why isn't Lazarus / Free Pascal more popular?  (Read 31489 times)

LV

  • Sr. Member
  • ****
  • Posts: 389
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #120 on: May 08, 2025, 03:36:45 pm »
Getting back to the topic, I don't think the situation with Pascal is all that pessimistic. The "Pascal Winter" that occurred in July 2020, one would like to believe, is behind us.
https://www.tiobe.com/tiobe-index/delphi-object-pascal/
According to this link, Pascal is on the rise. Just look at who’s ahead of it — these are programming languages backed by IT giants.

Fibonacci

  • Hero Member
  • *****
  • Posts: 788
  • Internal Error Hunter
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #121 on: May 08, 2025, 05:43:43 pm »
people in real life (...) When I tell people I use pascal they run away. Literally.

Would love to see it :D

440bx

  • Hero Member
  • *****
  • Posts: 6017
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #122 on: May 08, 2025, 06:09:28 pm »
people in real life (...) When I tell people I use pascal they run away. Literally.

Would love to see it :D
That opens the door to another use of Pascal.  Tell Olympic runners: win or else you'll have to program in Pascal.  If it makes them run faster... why not ? Cheaper and safer than unleashing a rabid dog on them ;)
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

JD

  • Hero Member
  • *****
  • Posts: 1909
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #123 on: May 08, 2025, 09:50:09 pm »
When I tell people I use pascal they run away. Literally.

In my case, it was laughter and unbelief. But once I showed them how it can be integrated into a modern full stack software design (in my case on the server side) with containers and VPS, the smiles were wiped off their faces. And when it performs very well in that environment on legacy machines with a reasonable amount of RAM, no one cares about what language is used anymore. The tool becomes less important if the problem is solved except for large corporates for maintainance reasons.

The Object Pascal language  is likely to remain a niche language. I don't think it will disappear. In the last couple of days, I've noticed newer channels on YouTube teaching/promoting products with Lazarus/FPC. Some of the channels are in Portuguese and Spanish due to South American market especially in Brazil and also in Argentina. That in my opinion is a very welcome development.
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

silvercoder70

  • Full Member
  • ***
  • Posts: 200
    • Tim Coates
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #124 on: May 09, 2025, 12:23:26 am »
Pascal (in some form or another) has been around for a while and will remain for a while yet where others might come and then disappear. I can also say there are both positive and negative connotations about Pascal being niche.

Anyway, I have started a thread here -

https://forum.lazarus.freepascal.org/index.php/topic,71081.msg554279/topicseen.html

on "Practical Ways to Help Lazarus and Free Pascal Thrive" where we can all contribute ideas. And I guess the question also turns into

What you do you want the language to become?
🔥 Pascal Isn’t Dead -> See What It Can Do: @silvercoder70 on YouTube

Lenny33

  • New Member
  • *
  • Posts: 49
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #125 on: May 10, 2025, 06:06:47 am »
I will explain you like a 5-years-old:

Here we are comparing the performance of C++ vs FPC.

Example: If you use assembler to optimize FPC code but you do not use assembler to optimize C++ code then you can not say "FPC is faster!"

You need to use assembler in both codes (or not use it in any of them) for a reliable comparison.
It is useless to explain this to fanatics of only one programming language.
People like Seenkao do not understand 2 things:
1) Nowadays it is almost impossible to write assembly code better than well optimizing compilers can do, f.ex. like VC++ or especially Intel C++ for x86 architecture;
2) No one wants to spend hours on manual optimization if the compiler itself can do it for a seconds. And especially for different processor generations and different architectures.

Unfortunately, existing Pascal compilers cannot boast of good optimization of computational algorithms.
Therefore, nobody uses them in tasks that require intensive computations. Obviously except Seenkao and maybe few others who like to write everything by hand in assembly language in 2025.

Thaddy

  • Hero Member
  • *****
  • Posts: 18676
  • Jungle wars. And failing health it seems.
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #126 on: May 10, 2025, 09:03:41 am »
A five year old would know that the compilers should in theory compile to binaries of equal speed.
It is not the language. Anyone who does not understand that is less than four years old.
(In some fields, fpc can beat C++ compilers, but that is really not relevant, because it is implementation detail)
« Last Edit: May 10, 2025, 09:12:43 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

LV

  • Sr. Member
  • ****
  • Posts: 389
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #127 on: May 10, 2025, 01:12:35 pm »
1) Nowadays it is almost impossible to write assembly code better than well optimizing compilers can do, f.ex. like VC++ or especially Intel C++ for x86 architecture;
2) No one wants to spend hours on manual optimization if the compiler itself can do it for a seconds. And especially for different processor generations and different architectures.

If you are involved in high-performance computing, you may have examined the source code of mathematical libraries, much of which is written in assembly language.
https://github.com/OpenMathLib/OpenBLAS/blob/develop/kernel/x86_64/sum.S
Let's take a simpler approach and write a basic test for those uncomfortable with assembly language, AVX, or multithreading.

Code: C++  [Select][+][-]
  1. #include <iostream>
  2. #include <vector>
  3. #include <chrono>
  4. #include <cstdlib>
  5. #include <cmath>
  6.  
  7. constexpr int MATRIX_SIZE = 1000;
  8. constexpr int MATRIX_ELEMENTS = MATRIX_SIZE * MATRIX_SIZE;
  9.  
  10. void transpose_matrix(const std::vector<double>& src, std::vector<double>& dst) {
  11.     for (int i = 0; i < MATRIX_SIZE; ++i) {
  12.         for (int j = 0; j < MATRIX_SIZE; ++j) {
  13.             dst[j * MATRIX_SIZE + i] = src[i * MATRIX_SIZE + j];
  14.         }
  15.     }
  16. }
  17.  
  18. void naive_matrix_mult_transposed_unrolled(const std::vector<double>& a, const std::vector<double>& bT, std::vector<double>& c) {
  19.     for (int i = 0; i < MATRIX_SIZE; ++i) {
  20.         for (int j = 0; j < MATRIX_SIZE; ++j) {
  21.             double sum = 0.0;
  22.             int k = 0;
  23.  
  24.             // unroll by 4
  25.             for (; k <= MATRIX_SIZE - 4; k += 4) {
  26.                 sum += a[i * MATRIX_SIZE + k]     * bT[j * MATRIX_SIZE + k];
  27.                 sum += a[i * MATRIX_SIZE + k + 1] * bT[j * MATRIX_SIZE + k + 1];
  28.                 sum += a[i * MATRIX_SIZE + k + 2] * bT[j * MATRIX_SIZE + k + 2];
  29.                 sum += a[i * MATRIX_SIZE + k + 3] * bT[j * MATRIX_SIZE + k + 3];
  30.             }
  31.  
  32.             // tail loop for remaining elements
  33.             for (; k < MATRIX_SIZE; ++k) {
  34.                 sum += a[i * MATRIX_SIZE + k] * bT[j * MATRIX_SIZE + k];
  35.             }
  36.  
  37.             c[i * MATRIX_SIZE + j] = sum;
  38.         }
  39.     }
  40. }
  41.  
  42. int main() {
  43.     std::vector<double> a(MATRIX_ELEMENTS);
  44.     std::vector<double> b(MATRIX_ELEMENTS);
  45.     std::vector<double> b_transposed(MATRIX_ELEMENTS);
  46.     std::vector<double> c(MATRIX_ELEMENTS);
  47.  
  48.     srand(static_cast<unsigned>(time(nullptr)));
  49.     for (int i = 0; i < MATRIX_ELEMENTS; ++i) {
  50.         a[i] = static_cast<double>(rand()) / RAND_MAX * 100.0;
  51.         b[i] = static_cast<double>(rand()) / RAND_MAX * 100.0;
  52.     }
  53.  
  54.     transpose_matrix(b, b_transposed);
  55.  
  56.     auto start = std::chrono::high_resolution_clock::now();
  57.     naive_matrix_mult_transposed_unrolled(a, b_transposed, c);
  58.     auto end = std::chrono::high_resolution_clock::now();
  59.     std::chrono::duration<double, std::milli> exec_time = end - start;
  60.  
  61.     std::cout << "C++: Naive (transposed B, unrolled) multiplication time, ms: " << int(exec_time.count()) << std::endl;
  62.  
  63.     return 0;
  64. }
  65.  

Code: Pascal  [Select][+][-]
  1. program MatrixMultUnrolled;
  2.  
  3. uses
  4.   SysUtils,
  5.   DateUtils;
  6.  
  7. const
  8.   MATRIX_SIZE = 1000;
  9.  
  10. type
  11.   TMatrix = array of double;
  12.  
  13.   procedure TransposeMatrix(const src: TMatrix; var dst: TMatrix);
  14.   var
  15.     i, j: integer;
  16.   begin
  17.     for i := 0 to MATRIX_SIZE - 1 do
  18.       for j := 0 to MATRIX_SIZE - 1 do
  19.         dst[j * MATRIX_SIZE + i] := src[i * MATRIX_SIZE + j];
  20.   end;
  21.  
  22.   procedure NaiveMatrixMultTransposedUnrolled(const a, bT: TMatrix; var c: TMatrix);
  23.   var
  24.     i, j, k: integer;
  25.     sum: double;
  26.   begin
  27.     for i := 0 to MATRIX_SIZE - 1 do
  28.       for j := 0 to MATRIX_SIZE - 1 do
  29.       begin
  30.         sum := 0.0;
  31.         k := 0;
  32.         while k <= MATRIX_SIZE - 4 do
  33.         begin
  34.           sum := sum + a[i * MATRIX_SIZE + k] * bT[j * MATRIX_SIZE + k];
  35.           sum := sum + a[i * MATRIX_SIZE + k + 1] * bT[j * MATRIX_SIZE + k + 1];
  36.           sum := sum + a[i * MATRIX_SIZE + k + 2] * bT[j * MATRIX_SIZE + k + 2];
  37.           sum := sum + a[i * MATRIX_SIZE + k + 3] * bT[j * MATRIX_SIZE + k + 3];
  38.           Inc(k, 4);
  39.         end;
  40.         while k < MATRIX_SIZE do
  41.         begin
  42.           sum := sum + a[i * MATRIX_SIZE + k] * bT[j * MATRIX_SIZE + k];
  43.           Inc(k);
  44.         end;
  45.         c[i * MATRIX_SIZE + j] := sum;
  46.       end;
  47.   end;
  48.  
  49.   procedure FillRandomMatrix(var mat: TMatrix);
  50.   var
  51.     i: integer;
  52.   begin
  53.     for i := 0 to High(mat) do
  54.       mat[i] := Random * 100.0;
  55.   end;
  56.  
  57. var
  58.   a, b, bT, c: TMatrix;
  59.   startTime, endTime: TDateTime;
  60. begin
  61.   SetLength(a, MATRIX_SIZE * MATRIX_SIZE);
  62.   SetLength(b, MATRIX_SIZE * MATRIX_SIZE);
  63.   SetLength(bT, MATRIX_SIZE * MATRIX_SIZE);
  64.   SetLength(c, MATRIX_SIZE * MATRIX_SIZE);
  65.  
  66.   Randomize;
  67.   FillRandomMatrix(a);
  68.   FillRandomMatrix(b);
  69.   TransposeMatrix(b, bT);
  70.  
  71.   startTime := Now;
  72.   NaiveMatrixMultTransposedUnrolled(a, bT, c);
  73.   endTime := Now;
  74.  
  75.   WriteLn('FCP: Naive (transposed B, unrolled) multiplication time, ms: ',
  76.  
  77.   MilliSecondsBetween(endTime, startTime));
  78.  
  79.   Readln;
  80. end.
  81.  

Here are the results averaged over five runs of the programs
Code: Text  [Select][+][-]
  1. -------------------------------------------------------------------------
  2.             |  FPC 3.2.2 (-O3) |   C++ (GCC 14.2.0 -O3) | difference    |
  3. -------------------------------------------------------------------------
  4. Time, ms    |  972             |   924                  |      5%       |
  5. -------------------------------------------------------------------------
  6.  

P.S. Sorry, but I'm not interested in discussing who is a fan of a particular programming language. :)

JdeHaan

  • Full Member
  • ***
  • Posts: 171
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #128 on: May 10, 2025, 02:49:32 pm »
Testing your program MatrixMultUnrolled on my 2019 MBP-Intel I7 and MacOS Sequoia, and Lazarus+FPC trunk.

If I use {$mode ObjFPC) I get 1049 msec.
However if I use {$mode delphi} it takes 2279 msec. - twice as long...

Both in -O3

Can someone else confirm this?



LV

  • Sr. Member
  • ****
  • Posts: 389
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #129 on: May 10, 2025, 03:31:10 pm »
I tested with compiler directives {$mode ObjFPC} and {$mode delphi} for configuration: 

Lazarus 3.4 (rev lazarus_3_4) FPC 3.2.2 x86_64-win64-win32/win64
on Windows 11 (Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz).

The results are the same as those shown in the table above.

Lenny33

  • New Member
  • *
  • Posts: 49
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #130 on: May 10, 2025, 04:36:13 pm »
If you are involved in high-performance computing, you may have examined the source code of mathematical libraries, much of which is written in assembly language.
I have already written that our application among other things uses a lot of calculations for signal processing.
Experimentally it was found that the same algorithms compiled in VC++ for Win work almost twice as fast. Why this happens is obvious from what was given in this forum thread.
To achieve comparable speed on FPC or Delphi, some characters of this forum suggest manual optimization or even rewriting critical parts in assembler. But why?
It is much easier and much faster for us to write these parts of the program as C++ libraries. And the result is still better.

And now if we go back to the question, why isn't Lazarus(FPC) so popular?
So let's at least outline for ourselves the niche for Lazarus.

On the one hand, it is naive and does not require a managed environment for execution, but on the other hand, my opponents tell me that C++ also native, but generate more fast naive code.
Then why they should bother with hand memory management and so on if the performance of Lazarus apps is actually not higher than in f.ex. C#?

On the other hand Lazarus provides a good and free IDE with many libraries and components. But my opponents can say that VS Community Edition is also free and even more convenient (of cause if only on Win).
And there is also conditionally free Qt for C++, where the library is much more extensive, there is a more modern approach to interfaces ( QML ). And so on.
Yes, from the point of view of a completely free license Lazarus will definitely win, but is it so important for a serious commercial project? Licenses are usually cheaper than programmer salaries and other overheads.

What can be written in Lazarus FPC that could not be written in, for example, C#? I don't have an answer. The speed is almost the same. Computational algorithms +/- run at the same speed.
Maybe only very heavily loaded servers are better written in a naive language with no gabage collection. But practice shows that C# and even Node.js can handle such tasks quite well.
More then there are a huge number of commercial and free libraries on the C# side. And you can make projects directly for WEB out of the box (ASP.NET / Razor / Blazor ).
If only backend, then .NET Core is as free as Lazarus.

P.S. Sorry, but I'm not interested in discussing who is a fan of a particular programming language. :)
So in connection with the above:
let's start by admitting at least to ourselves that it's primarily about programming language. Most of us are old enough. We've liked Pascal language since school or university.
And we like the approach of creating interfaces interactively rather than declaratively, even though LCL/VCL interfaces are becoming obsolete.

Can FPC/Lazarus become more popular against this backdrop?
I don't know. Time will tell. There needs to be a serious investsments. But where to get it from in an opensource project?
IMHO If Delphi manages to rise in popularity Lazarus will rise with it.

« Last Edit: May 10, 2025, 04:55:24 pm by Lenny33 »

munair

  • Hero Member
  • *****
  • Posts: 887
  • compiler developer @SharpBASIC
    • SharpBASIC
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #131 on: May 10, 2025, 05:12:21 pm »
What can be written in Lazarus FPC that could not be written in, for example, C#? I don't have an answer. The speed is almost the same. Computational algorithms +/- run at the same speed.
Maybe only very heavily loaded servers are better written in a naive language with no garbage collection. But practice shows that C# and even Node.js can handle such tasks quite well.
More then there are a huge number of commercial and free libraries on the C# side. And you can make projects directly for WEB out of the box (ASP.NET / Razor / Blazor ).
If only backend, then .NET Core is as free as Lazarus.

One very good reason to use Lazarus/FPC as a RAD is its cross-platform support. It is one of the main reasons I use it, to cross compile with relative ease, especially on Linux where I start out developing most of my projects. So while speed can be an argument to use specific development tools, there are also practical considerations. And the code FPC generates is definitely NOT slow.
It's only logical.

440bx

  • Hero Member
  • *****
  • Posts: 6017
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #132 on: May 11, 2025, 01:14:29 am »
What can be written in Lazarus FPC that could not be written in, for example, C#? I don't have an answer. The speed is almost the same. Computational algorithms +/- run at the same speed.
Maybe only very heavily loaded servers are better written in a naive language with no gabage collection. But practice shows that C# and even Node.js can handle such tasks quite well.
C# code does not run nearly at the speed of compiled FPC code.  Not completely sure but I think MS Visual Studio is written mostly in C# and unless you have a _really fast_ machine, it is barely usable.  It is barely usable on a 2.8Ghz machine.  When code doesn't run well on a 2.8Ghz, my opinion of it is "rather low".    I know because I use it and I have a 2.8 Ghz machine which I have no intention of upgrading because it's more than fast enough to execute the code I write in the blink of an eye and, if my code runs fast on my box, it will be faster than water sliding on greased teflon on today's machines.

Garbage collection is the last "feature" I'd like to have in a language.  I can and do my own memory management a hundred times better (and that's a sharp understatement) than any garbage collector, not to mention that I don't need to program like I'm walking on eggshells because the garbage collector cannot correctly handle what I want to do.   That's not what I call a programming language.  Garbage collected languages are toys for wannabe programmers. 
« Last Edit: May 11, 2025, 01:18:09 am by 440bx »
FPC v3.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

LV

  • Sr. Member
  • ****
  • Posts: 389
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #133 on: May 11, 2025, 08:22:19 am »
I have already written that our application among other things uses a lot of calculations for signal processing.
Experimentally it was found that the same algorithms compiled in VC++ for Win work almost twice as fast. Why this happens is obvious from what was given in this forum thread.
To achieve comparable speed on FPC or Delphi, some characters of this forum suggest manual optimization or even rewriting critical parts in assembler. But why?
It is much easier and much faster for us to write these parts of the program as C++ libraries. And the result is still better.

These are just words, but not supported by source code.

A widely used, simple benchmark with matrix multiplication is given just above. The texts of the programs in C++ and Pascal are given. The testing results under equal conditions give a speed difference of only 5%. Online, you can find publications that test algorithms in different programming languages systematically. For example, earlier I provided links to the work. Quote "We compared several programming languages ​​that are commonly used in biomedical research (S in the R implementation and Python) or that are optimized for speed (Swift, C++ and Object Pascal). In benchmarking experiments with two prototypical feedback loops, we found the implementations in Object Pascal to deliver the fastest results." The authors provide source codes that can be double-checked. My not very extensive experience (I started using FPC-Lazarus in 2022) in high-performance simulations when solving computational physics problems shows that FPC is a good, but underestimated tool.

JD

  • Hero Member
  • *****
  • Posts: 1909
Re: Why isn't Lazarus / Free Pascal more popular?
« Reply #134 on: May 11, 2025, 08:39:43 am »
Not completely sure but I think MS Visual Studio is written mostly in C# and unless you have a _really fast_ machine, it is barely usable.  It is barely usable on a 2.8Ghz machine.  When code doesn't run well on a 2.8Ghz, my opinion of it is "rather low".    I know because I use it and I have a 2.8 Ghz machine which I have no intention of upgrading because it's more than fast enough to execute the code I write in the blink of an eye and, if my code runs fast on my box, it will be faster than water sliding on greased teflon on today's machines.

I also had the same experience with Visual Studio Community Edition 2009. I installed it because I needed it to compile C++ code. The IDE is very resource hungry on legacy machines. It is one of the reasons why I upgraded all my development machines to 16GB and higher.

And like you, I like to deliberately try my applications on legacy machines, knowing that if I get it right, the applications will be lightning fast on the newer machines.
« Last Edit: May 11, 2025, 09:01:49 am by JD »
Linux Mint - Lazarus 4.0/FPC 3.2.2,
Windows - Lazarus 4.0/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

 

TinyPortal © 2005-2018