google translate: I admit, in some ways I could be wrong! Don't get turned on by words! But everything that you write is more perceived as a dislike for Pascal!
I think thats the nature of the post and the context. My posts are about popularity of pascal, which is one of it's weaknesses, so when I talk a lot about it, it of course looks like i'm only bringing up negative points, because there isn't much good things to say about a language being not popular.
But let me ensure you there is plenty I like about Pascal, to name some of my favorite things, nested functions are pretty much one of the best tools I've seen in a language to organise code. I really like the structure of pascal in general, and that there are no scoped variables (I think that an opt-in scoping mechanism like pythons with statement could be neat, but thats another topic). The unit structure is absolutely great, making using the FPC very comfortable for any scope of project, you don't need to make overcomplicated buildsystems like you have to for C and C++, and you are not forced in a rigid package structure like Java or C#. You can start of with a small project and let it naturally grow, without having a heavy structuring effort thats either frontloaded or backloaded being a huge timesink. It has a great mix of high and low level features, which allows you to simultaniously have a very abstract/model based code utilizing the whole aspects of OOP, while in other parts going down bare metal, without either feeling cumbersome. And not to mention that I have yet to find another solution for GUI development across all classic desktop systems thats as easy to use as Lazarus with the LCL, from a simple 1 file calculator to my big 10 kloc IDE I've wrote a few years back Lazarus just makes it really easy.
I could go on
google translate: If I need to, I use Pascal. There are no unsolvable problems!
Yes, I admit that this is often a costly and unrewarding "job". If urgency is needed, it is easier to do the work in another language if you have the opportunity.
[...]
My opinion: there are no "best", "worst", "suitable", "not suitable" programming languages! Everything can be solved in one - ANY programming language. You just need to know how to use it in the right path.
You can solve any problem with any language, thats true, but it doesn't mean that they are all comparable. Some languages will make solving some problems easier than others, in some languages a given action will require a lot of boilerplate code making the code less readable, and at other times simply require more and different code (e.g. for different platforms) that mean more maintainance effort.
The simpelest example I can give you is this, I've created the program gdiff, which simply shows me the diff of a single commit in git. I chose to use bash script for it, the script is:
#!/bin/bash
COMMIT=${1-HEAD}
git diff $COMMIT~1 $COMMIT
I could have written it in Pascal:
program gdiff;
{$Mode ObjFPC}{$H+}
uses SysUtils;
var
commit: String;
begin
if ParamCount < 1 then
commit := 'HEAD'
else
commit := ParamStr(1);
ExitCode := ExecuteProcess('git', [commit+'~1', commit]);
end;
The bash solution is defenetly the better one here. It was much less effort to create, is concise but still conveys all the information you need with a single glance, and can be directly incorporated into the git ecosystem (which already requires a bash to be present), without the need to be compiled.
Now this is of course the most obvious example, it compares a script language that is made just to call other programs with a general purpose language. So me give you three projects, real, rather big programs I have worked on in the past and explain what languages I used and why I chose them over other, similar languages.
First one is a data visualization software. So I had a software that produced gigabytes of raw outputs in different formats, a lot of statistics and some text information as well as meta information about the run. The goal was to visualize multiple aspects of the data, compare to different runs of the same program, etc. It started out really small, I've started with a simple table program that would load the data into a table and make it searchable and so on. I wrote this in Lazarus because you can basically start lazarus and start creating a simple GUI and the very simple logic. When I was done I thought about another feature, a plotting program, that would take the data and plot it in multiple different ways. Again I decided to use Lazarus, create a new project, copy some of the code from the original and was done really quickly.
I then got a few other ideas for new features, also the table view and plot should be linked together, so I just took these seperate projects, made the forms to frames, put the common code into a seperate datastructure and created an overarching program that simply loaded these frames as "tools" into different parent objects. So I could easiely develop each tool individually, even in it's own project, as the frames where shared between projects and simply use the large program in the end to combine all the features.
Here Lazarus was by far the best solution I could have picked. It started out really small as just a small idea, but has evolved into one of the biggest projects I had worked on at the time. Because of the huge amount of data, performance was a key issue, which is not a problem with ObjectPascal and the FPC, also reading binary data is really easy using TStreams and Records. I could also reuse components I have written for previous programs (especially the plotting frame was custom created by me and the codebase is something I am using now for more then a decade).
I could have had the performance and ease of reading binary data with for example C++, but there creating the GUI and the overall project structure would have meant like tenfold the effort it did for pascal. I could have used Javascript and make it a webapp, which allows for similar ease of managing different views and creating complex GUIs, but working on binary data in javascript is a real pain in the neck and the performance of JS in the computationally expensive algorithms for preparing the data might have resulted in massive loading times (It already was like 30seconds per imported project with heaviely optimized native code). An other alternative might have been C#, but this would have bound me to windows and Linux support was key, and I don't even know if .Net would have been fast enough (if the GC starts during a computationally heavy algorithm, it can slow it down massively)
Any other solution I can think of would have meant more work for probably a worse result.
The second project is an emulator for an old console. Here I chose C++, the reason being that C++ provides a lot of tools to write really optimised code in a very elegant way. For example you can write so called constexpr which are functions (or expressions) that are evaluated during compiletime. Basically it allows you to write compiletime code within the language pretty similar to runtime code.
Take the following code:
constexpr uint8_t ®ister(Register reg) {
if constexpr(reg == Register::A) {
return accumulator;
} else if constexpr(reg == Register::F) {
return *reinterpret_cast<std::uint8_t*>(&statusRegister);
} else {
return gpRegister[static_cast<int>(reg)];
}
}
This function dispatches registers to a logic that is known during compiletime. If you write "cpu.register(Register::A)" this will be simply translated to "cpu.accumulator" with not a single instruction being executed on runtime for this dispatching.
This means you can put code into functions without any runtime overhead, allowing for more readable code without any performance penalty. The example above allows for example to access every register in the same manner, using the same syntactic construct, which can massively help cleaning up the code. Pascal for example has no method to define functions that are guaranteed to be evaluated on compiletime.
Another thing is the power of templates in C++, they are like generics, just more powerful (turing complete infact). You can for exmple use them to implement a shallow form of inheritance using the CRTP pattern, allowing to have most features of inheritance but also restricting the virtual depth (i.e. the length of virtual function call chains) to 1. Basically you get many of the advantages of inheritance, without the runtime penalty of inheritance.
Long story short, C++ allows for some very interesting ways to write high performance code with high level concepts that usually, in languages like Pascal, are only reserved to runtime functionality and has therefore a runtime penalty to it.
So to get back to my project, as the nature of an emulator, especially one that should function well platforms with low computational power, performance is a key issue, unlike the first example, not only for key algorithms, but across the whole code base. So while in the example above I could use Pascal for both, as it is usally very clean when writing high level code, and the low level code was only a few algorithms, where "I could get my hands dirty", in this project I needed to archive peak performance in every aspect, and here C++ simply makes it much easier because it applys high level concepts at a compile time level, something pascal simply can not provide.
The last project is a chat, which uses encryption. I chose javascript (well technically typescript but I consider them both to be the same). One key was the requirement for a crypto library that is up to date and well tested. I already talked about the issues with crypto libraries earlier, so I won't rehash it here. Javascript has access to the browser crypto functionality, meaning the cryptolibrary is Firefox or Chromium itself, some of the arguably most well tested pieces of software available, and always providing state of the art security, you probably can't get better then this. Next is that this chat must run on mobile, I wouldn't care if it won't run on Desktop, but mobile is a must have. I am not going to pay for any of the cross platform solutions (like Xamarin or Firemonkey) so if I don't want to create two seperate apps (one for android and one for iOS), there is pretty much not an alternative. Even native development is much more tedious for android then web technology, so even disregarding cross compatibility, I would probably have chosen javascript over like Java.
I could have chosen Pascal with Lazarus here, there is the ability to write native android and iOS apps, but these apps need to be developed seperately (where as one webapp can target both platforms with the same code) while also being much more effort to implement. I could have used Lazarus with Pas2JS to generate the Javascript code, or C++ with emscripten, but this results often in even more effort, not only setting up the toolchains, but also using non web languages in the web environment, which has it's own structures and paradigms, feels very forced and often requires a lot of boilerplate code. Javascript is basically nothing but Dicts, Arrays and atomic datatypes, with everything being dynamic, which makes using it with a static language like Pascal or C++ feel very out of place.
So with these three projects, I could have done in each of them in each of the other languages, but the effort would have been much higher, and the quality of the product (let that be performance or code quality or features) would have suffered greatly.