Free Pascal
freepascal.org
freepascal.org
...and you'll be up and running with (1) FreePascal compiler (2) Lazarus IDE (https://lazarus-ide.org) with integrated debugger and RAD (Rapid Application Development) GUI designer.
Lazarus and FPC can create high-quality native GUI's for macOS, Linux, and Windows. And many open-source 3rd party GUI components can be installed right from within the Lazarus IDE via the "Package" > "Online Package Manager" menu option.
I've been using Delphi and/or Lazarus + FPC for 15 years. It's truly the most productive way to build a GUI desktop application, and makes it extremely easy to build powerful console apps.
We had to wait until Windows 8 to properly get it, and still its being rebooted due to the way WinRT went, whereas it could bave been there since v1.0.
https://github.com/dotnet/designs/blob/main/accepted/2020/fo...
tl;dr is that if you create a RELEASE build, should be about 2 - 5mb for a GUI app, depending on the platform. And if you run `upx` against the resulting binary, it will be even smaller.
Win 7 x64:
------------
- 12.3 mb == Default build
- 3.2 mb == Default build without debug info
- 2.1 mb == Optimized compiler
- 2.1 mb == Optimized compiler without debug info
Ubuntu x64:
------------
- 13.4 mb == Default build
- 7.5 mb == Default build without debug info
- 4.4 mb == Optimized compiler
- 2.7 mb == Optimized compiler without debug info
Optimized compiler means: 1. Project|Compiler Options|Code|Smart Linkable (-CX) -> Checked
2. Project|Compiler Options|Linking|Debugging| Uncheck all except `Strip Symbols From Executable (-Xs) -> Checked`Strip Symbols From Executable (-Xs) -> Checked
3. Project|Compiler Options|Linking|Link Style|Link Smart (-XX) -> Checked
4. (Optional) Project|Compiler Options|Code|Optimizations|smaller rather than faster -> Checked (Warning: this might decrease performance)Which is rather bad. I used to use Delphi 4 and it would create 350 KB programs by default.
Which was also bad, so I sometimes used that Delphi without the GUI designer and without the VCL, using the win32 API directly, to create 50 KB programs. That is a reasonable software size. Software keeps getting worse every year
The strength of Lazarus was creating Windows GUI apps not console apps..
But I made a console app with it: http://www.videlibri.de/xidel.html
A query language for HTML, XML, and JSON
https://jonlennartaasenden.wordpress.com/2014/11/06/famous-s...
How does the experience compare to C#, .NET Core, and Visual Studio?
The original architect of Turbo Pascal is Anders Hejlsberg (https://en.wikipedia.org/wiki/Anders_Hejlsberg), who also was recruited to Microsoft directly by Bill Gates.
Anders went on to architect J++, the .NET Framework and C#, and TypeScript.
C# is heavily influenced by Turbo Pascal / Delphi because they have the same original architect. And Lazarus + FPC are open-source implementations of the Delphi 7 IDE + Object-Pascal language (same as Delphi).
If you are at home in Visual Studio, using Lazarus will feel very familiar.
Object-Pascal is easy to learn. A great site to bookmark when learning Delphi or Lazarus + FPC is: http://www.delphibasics.co.uk/
"Bill Gates saw the success of Turbo Pascal "in very personal terms, and 'couldn't understand why [Microsoft's] stuff was so slow. He would bring in Greg Whitten [programming director of Microsoft languages] and yell at him for half an hour.' He couldn't understand why Kahn had been able to beat an established competitor like Microsoft.""
[Edit] One of the nice things about pascal strings, and variable parameters, is that you can write functions like
getinteger(var s : string):integer;
Which literally pulls a sign plus digits from s, skipping spaces, until it hits a space, comma, etc... s gets shorter, you get the integer, and it just works.
I don't think that type of thing is even possible in C because of null terminated unmanaged strings.
Then the pointed-at pointer can be manipulated within the method body and changes will be visible on the outside as well, giving you both the numeric return value as well as the shortened string as the output. This is what the second argument of the strto{d,f,ld} function does: https://devdocs.io/c/string/byte/strtof
[Edit] For example, you can also insert into a string, making it longer, without having to worry about it.
var/out variables are much safer, since the variable exists at the calling site , is valid and not null.
It is also much safer than C++'s & references. It is very subtle, but rather amazing if you think about it. Because C++ can return a & reference, it can return a reference to a value on the stack frame of the callee, which then becomes invalid. But the var/out variable always exists on caller's site, so it is always safe.
(at least if it a reference to the stack. a reference to the heap could be freed indirectly through another reference. )
Is returning references frequently done in C++? I have only seen it in ostream's << operator-like constructs where you want to chain multiple calls to the same object.
Another source of issues might be the creation of temporaries.
Yes, in index operator as well.
It is rather common to avoid copying returned objects. (perhaps it becomes less common with std::move ?)
For example, the [] operator on the standard collections returns a reference, so the item can be modified
There Pascal has another clever idea. You can overload [] for reading and writing separately. Then x[k] := v becomes x.setItem(k, v)
int getint(const char **s) {
int res = 0;
for (; **s && isspace(**s); (*s)++);
for (; **s && isdigit(**s); (*s)++)
res = 10 * res + **s - '0';
return res;
} function getnum(var s : string):integer;
var
c : char;
value : integer;
begin
value := 0;
while (length(s) <> 0) and NOT(s[1] in ['0'..'9']) do
delete(s,1,1);
while (length(s) <> 0) and (s[1] in ['0'..'9']) do
begin
value := value * 10 + (ord(s[1])-ord('0'));
delete(s,1,1);
end;
getnum := value;
end;But it is unsafe. Someone might mistype * * s as *s and then bad things happen.
Pascal strings are basically memory safe. With range checking enabled, you can write whatever and it can only access characters in the string.
Ofc, then people disable the range checking in release builds to make it faster
Should be like, getinteger(const s : string; var startPos: sizeint):integer;
Pascal always has the best possible ideas, and then fucks up the implementation.
Confirmed by experiment.
Parsing 1,2,...1000 string 1000 times 0.355 seconds
Parsing 1,2,....10000 string 1000 times 42.835 seconds
A given string might have 1-10 parameters in it, so the actual execution time isn't going to be that bad. I always think in terms of those 10 Mhz 286s, and how much faster it is these days. ;-)
Obviously, if I were reading Gigabytes of text, I might optimize a bit.
Would have been a better title
Sure, that happened months ago, but there was no announcement thread on HN. It is sad. So many programming languages get an announcement thread, but FPC is forgotten all the time.
edit: actually there was such a thread. I just missed it. But it had no comments
Both advertise fast compilation, and they do compile quickly, but my experience with even 5-10k loc projects with those languages start to see some time sunk into the linker, even with Gold. This will inevitably lead to the change-execute cycle taking 1-3 seconds, while I have had no issue with substantially larger fpc code bases compiling and running in milliseconds.
For Rust and C++ devs a change-execute cycle sub 10 seconds is incredibly enticing. However, fpc has ruined me for what fast compilation really means. It also makes me really wish Nim had stuck to fpc as a backend.
I know very little about what is actually going on behind the scenes here. If anyone has any info about pascals compilation as well as linkers in general I would love to know more.
I checked HN and it looks like there is an old discussion here: https://news.ycombinator.com/item?id=9597406
So, I'll probably give this a read when I find time. Hopefully someone else will find it useful as well.
To get a fast edit/compile/test workflow I just set up my default backend to be tcc and automatically switch to gcc if "-d:release" or "-d:danger" is given on the compile line { really I abbreviate that to "-d:r" :-) } This makes it easy to develop quickly and then switch right over to quick timing tests.
Nim also has an interpreter whose startup is more like 100 ms, but which is limited to only what its virtual machine target (also used for compile-time computation) supports.
Turbo Pascal has spoiled me in 1990's hardware.
It's a real language. Skype for Windows was originally written in the Delphi dialect.
The "WMI Delphi Code Creator" (written in Delphi) is a great example of this.
"The WMI Delphi Code Creator (WDCC), allows you to generate Object Pascal, Oxygene, C++ and C# code to access the WMI (Windows Management Instrumentation) classes, events and methods. Also includes a set of tools to explorer and Query the content of the WMI."
Note that Object Pascal == Delphi == FreePascal (generally)
There are some of us who still work in Delphi. (Yes I know its not Freepascal)
Also here in Germany there is still a big enough community to warrant having Delphi conferences and articles in all major magazines that are language neutral, like Windows Developer one.
I spent 13 years developing and maintaining that system, around 2-3 MLOC at the time I left.
I found Delphi awesome in many ways but too enterprisey and too far removed from reality in others. Every few years a new technology would appear to replace the previous half baked attempt at solving the same problem, or dropped completely and replaced by third party components. Long term I found the software very frustrating to work with since everything about it was so volatile and there were so many random gaps in quality and functionality.
Their database, Interbase, was pretty good; and well integrated into the language/IDE. Open sourced and forked as Firebird SQL at one point.
For Delphi, maybe somewhere next year. They did put it on the road map, but there are no guarantees [2].
[1] https://forum.lazarus.freepascal.org/index.php/topic,52127.0...
[2] https://blogs.embarcadero.com/rad-studio-roadmap-november-20...
From the perspective of the Alan Perlis quote “A language that doesn’t affect the way you think about programming is not worth knowing,” is it worth it for me to give FreePascal a try? Or if I have experience in other procedural languages have I pretty much seen what it has to offer already?
Also what I really hate about Pascal is it is dishonest. It tells you it is very structured and your code will be better because of limited expressiveness. But then the 'writeln' 'function' needs to be intruduced at the compiler level - you cannot write such a function in the Pascal grammar. (maybe with freepascal you can nowadays)
What I liked though is that it didnt have the empty statement ';' so you really had to understand the semantics. Sometimes you were not allowed to end you statements with ';' (since they were ended by the block, so this would require the emptystatement). I think freepascal does not have this feature anymore (which is the thinking changing).
And just one more thing: Personally I would try to learn ADA before diving into Pascal.
It has the best possible ideas, and then fuck up the implementation.
Recently, I tried to use a set on a three valued enum. With three values it should have worked perfectly. But no, the set was not allowed. Because the values were -1, 0, 1 and FPC apparently only can create set on non-negative integers
I'm not sure how FreePascal compares to Delphi in compilation speed, but I expect both are blazing fast. The compilation speed is a result of the language design of Pascal, and the fact that compilation can use a "single pass compiler". Go is another language that has this feature. Compilation times are so fast that development can feel similar to using an interpreted language.
Pascal has empty statements. They are exactly that - empty. In C syntax ; is a statement end token, so the empty statement is ‘;’. In Pascal ; is a statement separator token, so the empty statement is ‘’, and ‘;’ is two empty statements. So the typical error is to write “....... ;” where only one statement is syntactically allowed.
Example:
if x > y
then x := y ;
else ... Syntax error.
Only one statement allowed between then and else.
then { x := y ; }
else ... is Ok.
The blocking makes two statements into one.Today, Delphi is used in some shops the same way C# or Java is used in others. Free Pascal with Lazarus is kind of like a free version of that. You can quickly build desktop apps.
Ada is nothing like that. It's almost exclusively used in the defense industry and others like aviation and infrastructure where the code is likely to be embedded and can NOT fail.
One is for standard business and one for critical infrastructure.
What do people use today? Java, C#, C, C++, Python, R, JavaScript, Php.
What might become popular someday? Rust.
I would say Pascal's killer app today is Lazarus. An open source, multi platform GUI RAD IDE.
The string handling are much better than C. Most is just automatically. You would not even encounter any difficulties until you start to interface with C libraries. And then it is still easy.
Due to this and strong typing and bounds-checking you automatically avoid most memory errors that you get in C. But you can make it as complicated as C, with pointers to pointers to arrays, disable bounds-checking/type-checking, etc. There are some limited parametric type possibilities.
The disadvantage is the absence of closures/lambdas. Instead you have to make pointers to functions, like in C. Or use Objects like in Java. But with manual memory management.
The manual memory management and type declarations give extra overhead. Like in C. A lot would be avoided with inline variable declarations with automatic typing.
The way primitive sets and enumerated types fit together is still a rarity, as far as I know. (You can accomplish the same things in any low-level language, but the pascal syntax make it really nice.)
Interfaces in pascal are fairly interesting because they allow you to implement your own addref/decref routines for automatic reference counting. This was made for COM, but you can plug it into whatever reference counting scheme you like (say if you want to write python extensions or whatever).
The main thing is still probably the component system though, and the tight integration with the development environment.
It's kind of a trip the first time you configure an IDE plugin and realize it just recompiled the whole IDE for you.
Free Pascal now has a new way for that, stack objects/record with custom init/cleanup code. Real RAII. But not if used with inheritance
The syntax will be the primary barrier. Things like nested if-else with multiple conditionals are just a little more persnickity if you've been using C braces for decades. But the language, in the Borland dialects that most are using now, is somewhere in between C and C++ in terms of power overall: it's a little safer by default, still manual memory, but without needing to fling around quite so many pointers. And those compile times! A pretty well-suited language for game coding, actually.
And in terms of writing production code, libraries may or may not be a barrier. Basically, Pascal's current ecosystem exists in the shadow of one of the best RAD environments of the 90's - Delphi. That's where a lot of the code got written, and there's a definite focus on native desktop apps that remains. There are certainly good libraries available, but many are old, Delphi-centric, and lack polish - haphazard accumulations from developers that are very "get-er-done" and unconcerned about reuse. You can always bind C code, of course, but today it's easy to end up saying, "well, but I could just get a working library in (Go/Python/Node/etc) and be done" and thus end your Pascal journey before it starts.
Does anyone know about the state of WebAssembly support?
No idea how many people are using this toolchain to produce real work, but I consider it to be my secret weapon. I've never seen a truly multi-platform, batteries-included dev tool that is so coherent and comprehensive. At this point, the only add I would love to see is better macro expansion beyond the simple code macros that are provided now.
At any rate, depending on your definition of success, if you want to see an example of a decades old, open source project that really does work, throw the FPC/Lazarus project in with Linux itself. I'll spend the day today writing code on both a Windows and a Linux machine for the same project, producing the same ui heavy app with hardly any differences, thanks to this toolchain that runs pretty much exactly the same in either environment.
Seeing the love and dedication put into this project by contributors is a great way to remember how cool writing software really is. All devs should at least fiddle around with FPC/Lazarus just so they know what it is.
Or this with Delphi syntax for generics: http://newpascal.org/assets/modern_pascal_introduction.html
Now with creekshaw being integrated we might be reaching there though.
I believe you meant cranelift.