Lazarus

Programming => General => Topic started by: Webdrifter on June 25, 2020, 10:12:17 pm

Title: Is Pascal the right language for me ?
Post by: Webdrifter on June 25, 2020, 10:12:17 pm
Hello,

I,m new to this forum so I hope this is the right place for my questions.

I would like to pick up programming again.
I learned programming in Assembler and Pascal (have been out that for 35 years),
and I have had some experience with HTML, PHP and SQL (about 10 years ago).

I would like to realize a project. It is however not the easiest project to program, to say it mildly.   
So I’ve been searching for the best program language(s)/frameworks  to work with.
And I prefer to learn as little languages and frameworks as possible, since it will already be demanding enough.

My needs:
I know I’m setting myself up for failure. But hey, as long as I’m having fun doing it….
For instance the more info I search on the subject the less I seem to see the forest for the trees.

However, I ended up with this shortlist (for now):
(Your welcome to come up with better ones)

I would like to know how good Pascal/Lazarus can fulfil the strength mentioned with the other languages
(If Pascal/Lazarus can do equally good on all accounts, it would make it a killer Language/IDE combo).

Question 1:
Nowadays React Native is used a lot for Cross Platform Mobile Apps.
Can Pascal use React Native or even do better itself? When yes then how?

Question 2:
The best property of Smalltalk is live coding (REPL).
Can this also be done with Pascal? When yes then how? 

Question 3:
Microsoft is open sourcing the .net framework.
Can Pascal use the open source .net framework or even do better? When yes then how?

Question 4:
The best property of Python is it’s neural network frameworks/libraries.
Which of those frameworks/libraries can Pascal use, or can it do better itself? When yes then how?

Question 5:
What role can Lazarus play in all this?
Or would VS-code be a better option for certain needs?

And off course I would be obliged to get all other info for instance on good frameworks or libraries needed to fullfill my needs.

I know that in the end it might all be a matter off taste, nonetheless I would very much like to have some good input on the subject.
So, can anybody enlighten me?

Big please! 😉 And thanks in advance.
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 25, 2020, 11:37:44 pm
That is such an incredibly broad set of questions that I suspect that the community won't know quite where to start, so I'd like to get a couple out of the way based on my own experience.

Question 2:
The best property of Smalltalk is live coding (REPL).
Can this also be done with Pascal? When yes then how? 

Not easily, and any solution- irrespective of language- risks running foul of things like anti-virus protection.

Seriously: if you think that Smalltalk is the best match for your requirements then stick with it: it needs as much attention and TLC as it can get :-)

Quote
Question 5:
What role can Lazarus play in all this?
Or would VS-code be a better option for certain needs?

If you decide that Pascal is worth investigating, then you will find that Lazarus is a good language-specific development environment. I can't comment on (recent) VS, but you will definitely find it more appropriate than something like Eclipse.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: heejit on June 26, 2020, 12:34:21 am
I don't think you will find any programming language which has all needed
library/framework for all type of programming projects.

You have to select programming language based on the project.
Title: Re: Is Pascal the right language for me ?
Post by: Leledumbo on June 26, 2020, 10:13:40 am
Question 1:
Nowadays React Native is used a lot for Cross Platform Mobile Apps.
Can Pascal use React Native or even do better itself? When yes then how?
React Native does what we do: native compilation, differing only in source language (it uses JavaScript), but unlike C, it doesn't share usable interface so we can't use it as a library.
At the moment, there's no unified mobile UI library framework for both Android and iOS. Android seems to get more attention here, though iOS is stll possible. Somebody will need to unify the effort but no one seems interested to do that for now. I myself would be happier if LCL can also be implemented for those mobile OSes but apparently they have a fundamental differences than desktop style rendering that makes it a little harder to port LCL into.
Question 2:
The best property of Smalltalk is live coding (REPL).
Can this also be done with Pascal? When yes then how? 
Can be done but no existing solution available (easy to find some abandoned efforts online). REPL is more appropriate for scripting languages. I don't think it's necessary as compilation is fast or if you want instantfpc can help you execute the programs like scripts.
Question 3:
Microsoft is open sourcing the .net framework.
Can Pascal use the open source .net framework or even do better? When yes then how?
I haven't checked this, but I've made a Pascal program calling .net dll in the past, just the dll initialization must be done by a .net program as I didn't know how to call the initializer back then. Once called, it will stay in memory and you can use it for as long as the OS keeps it there. I have no idea what you expect from "do better", we already do some things better than .net framework, like not requiring .net framework to run our programs ;)
Question 4:
The best property of Python is it’s neural network frameworks/libraries.
Which of those frameworks/libraries can Pascal use, or can it do better itself? When yes then how?
TensorFlow is written in C++ and has C interface, Pascal can certainly use that. There are various neural network implementations, just search the forum, someone here is very dedicated on the topic.
Question 5:
What role can Lazarus play in all this?
Or would VS-code be a better option for certain needs?
I don't see any Lazarus specific requests from your questions, Lazarus should remain as is: an easy way to write cross platform native GUI applications for various platforms.
VS code is just an extensible text editor that you can treat like a decent enough IDE but that's it.
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 26, 2020, 01:30:33 pm
React Native does what we do: native compilation, differing only in source language (it uses JavaScript), but unlike C, it doesn't share usable interface so we can't use it as a library.

General comment if I may. These days, it appears that almost all languages are tending towards having some minimal set of features which include

* Type safety

* Classes and other OO basics

* Managed strings

* At least the option of reference counting or garbage collection.

A number of people feel that C++ is only kept going by inertia and by its attempt to be backward compatible with the vast corpus of programs written in C. Unfortunately, there is so much sloppiness implied by that backward compatibility that in order to at least attempt to implement type safety the complexity of the compiler results in compilation times going up exponentially: I believe it was Rob Pike who juxtaposed the fact of a big C++ build taking 45 minutes even on a server farm with the incongruity of the C++ standardisation effort adding ever more features which obviously required increased compilation time.

This will affect any language which uses C++ for its code generation, and I suggest that the same also applies to Javascript which initially was even more sloppy than C++.

I'm not saying that Pascal is the answer to a maiden's prayer, but I think the fact that it is still able to compile programs fast despite having garnered its own share of "modern" features says a lot for the language's fundamental design.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on June 26, 2020, 02:28:17 pm
There is no "one fits all" language, therefore I would simply use multiple lanaguages for that project:
Frontend: if it has to run on iOS, Android, browser and Desktop, I would probably go with apache cordova here and use web technology (i.e. js, html and css, maybe webasm). Here you could also use Lazarus with pas2js.
Server backend: Here I would probably use Lazarus, C++ or Java, depending on the specific needs. I really like writing server protocols in Pascal, but if you need to use an already established protocol, chances are good that in java it will be only one maven dependency and 10 lines of code
Neural net: Defenetly python, no question, the amount of information about Torch, TensorFlow, etc. on the web is pretty good for python, and even if there are also bindings to many other languages, you don't find much information about it.

And for your specific points:
Quote
Good adaptivity to screen sizes;
Javascript and webtechnology
Quote
Scrape information from the web;
I've had good experiences with java and python in that regard. Python scripts will be shorter, but to be honest I really like Java because of it's simplicity and robustness
Quote
Get additional information from users all over the world;
Server architecture that I would write in Pascal, probably using HTTP (because it's easy) and communicating with a decentralized Mariadb backend.
Quote
Prepare this information for use in a neural network;
I would suggest that the backend server chooses a sensible intermediate format, and the processing for the NN would than be done in the language chosen for the NN (probably python) because changes in the NN should not require changes in the backend.
Quote
Use this information in a neural network (preferably peer to peer redundantly distributed);
Python with pytorch
Quote
Us the results for actions on the internet (connecting to API’s running on 3rd party servers);
Also doable with python, but also possible with any other language
Quote
Us the results for actions on user devices;
Frontend -> JS
Quote
Off-line first where possible (using PouchDB?);
If you want to use PouchDB you need JS, otherwise there is the Java version of this CouchDB. If you want to use certain tools, this often takes the language decision for you
Quote
Fast UI, fast reliable communication, fast response from neural net, even on mobile phones;
Javascript is great for UI, reliable communication is possible with every language, and fast response from the NN is dependend on your NN, if its a large network and you don't have a great GPU (like Phones) it will take long. My suggestion, do the NN stuff on the server side and not on the phone, because large networks take time, simple as that.
Quote
Fiercely secured against attempts to disrupt data collection, -communication and -processing;
Use a CDN for your backend, this is completely language independend
Quote
Automated backup facility if so needed (Central, distributed, hybrid; Whatever would be best; It’s open for suggestions).
This is also language independend

About your questions:
Quote
Question 1:
Nowadays React Native is used a lot for Cross Platform Mobile Apps.
Can Pascal use React Native or even do better itself? When yes then how?
React native is basically just a javascript interpreter that grants access to system APIs to javascript via a framework. It is built for javascript and has no interface for other languages (afaik).

Quote
Question 2:
The best property of Smalltalk is live coding (REPL).
Can this also be done with Pascal? When yes then how?
Live coding is a bit against the spirit of a compiled language, and I don't think it would work that great with pascal, where you have to write a lot of boiler plate code before anything can happen

Quote
Question 3:
Microsoft is open sourcing the .net framework.
Can Pascal use the open source .net framework or even do better? When yes then how?
.Not uses a bytecode language that runs in a sort of VM. It is not compatible with assembly. While on windows there are possibilities to use .Not DLLs with native code, I don't know if it is portable at all. So the conservative answer is a "maybe but probably not"

Quote
Question 5:
What role can Lazarus play in all this?
Or would VS-code be a better option for certain needs?
Lazarus is great for Fpc-Pascal, simple as that. If you want to use any other language or any other compiler (like Delphi) it's probably better to use a different environment. For example, for Pyhton and C++ I really like Emacs, for JS or C# VS-Code is really great, for Java I'd go with Intellij.

So to summarize, I would use different languages for different needs, simple as as that. Every language has it's pros and cons and to do everything with only one language will only make your life harder

PS: Whenever I write JS I personally would use Typescipt, because I'm not an insane person. But it's compatibility is bascially the same
Title: Re: Is Pascal the right language for me ?
Post by: PascalDragon on June 26, 2020, 04:13:39 pm
PS: Whenever I write JS I personally would use Typescipt, because I'm not an insane person. But it's compatibility is bascially the same

Or pas2js? ;)
Title: Re: Is Pascal the right language for me ?
Post by: Curt Carpenter on June 27, 2020, 11:51:24 pm
I've been a "casual programmer" for (remarkably) fifty years now, doing it mostly for fun and for small projects.  I'd offer this advice.

1)  Your goal is very demanding and there will be a lot to learn to reach it.  I'd suggest that you break it into some smaller "sub goals" as a first step.  It will help you hold onto your enthusiasm as you climb your (long but fun!) learning curve.

2)  Because you have experience with Pascal, your learning curve will be a little less steep if you adopt it as your language.  You probably remember more than you think you do, and the investment you make in it will carry you a long way (if not 100% of the way) forward toward reaching your ultimate goal.

3)  I'd also suggest that Pascal is the most "literate" and readable language I've encountered over the years, and I'm guessing from your comment that you're someone that will value and appreciate that.  It's very painful to write a program and try to revise it after a few months -- only to discover that it's painful to try and read your own code.

4) Lazarus has good debugging support.  Crucial for people like me.

5)  Lazarus is cross-platform, but to take advantage of it, you're going to have to have some pretty well-developed understanding of each of the operating systems you want to program for.  Android in particular poses some hard challenges, in my opinion.   I haven't tried to cross from linux (my preferred OS) to android, but have use other systems to do Android phone apps. It was painful.

6) For the casual programmer, I don't think you can beat Lazarus (supported by this forum and a wealth of help from other places on the internet) for an enjoyable programming experience.  So if you have some fun overcoming the usual challenges/frustrations of getting a program to do what you want it to, I'd recommend it hands-down.

Hope some of that helps!
Title: Re: Is Pascal the right language for me ?
Post by: Webdrifter on June 29, 2020, 11:28:06 pm
I would like to thank you guys for your answers above. As you can imagine it didn't make my choice fully clear yet. To put it mildly  :D But it did give me new insight that will help me tough. If anybody else is willing to also give me his thoughts, please don't hesitate. I really appreciate the effort. And maybe it will also help others clear up some question they have on the matter.   
Title: Re: Is Pascal the right language for me ?
Post by: Handoko on June 30, 2020, 04:22:07 am
As this is the forum for Lazarus/FPC/Pascal, I'm sure you already got what are the advantages of using Lazarus/FPC/Pascal. But I'm the less biased so I will tell you no, don't use Lazarus, Free Pascal, nor Pascal.

Lazarus and Free Pascal are not commercial supported.
You should consider the other paid alternatives first. Lazarus/FPC is free, you can use it and start making money without spending a dollar. That is not as great as you thought, that also means no one is 'really' responsible for fixing the bug you may have someday when you use it. Here we have bugtracker, but as open source project, Lazarus and Free Pascal rely on volunteers and we currently are lack of volunteers.

Lazarus and Free Pascal are general purpose development tools.
You can use them to build anything you can imagine, if you know how. Games, image processing software, database/inventory/accounting/ERP applications, audio/video players, web servers and even operating systems. But as a general purpose tool, they have disadvantage too. I can use Lazarus to build games for days, but I can achieve the same result in less than half hour if I use game specialized development tools.

Pascal's golden era has passed.
Pascal was so popular in the 80s. Nowadays, Pascal is still alive but not many people are using it. Which are the industry standard are not important if you are a hobbyist. But if you're planning to start a career or business in the software development field, you really need to pay attention about it.
Title: Re: Is Pascal the right language for me ?
Post by: 440bx on June 30, 2020, 09:52:41 am
@Handoko,

You made a number of good points in your post.

I'd say that if a programmer intends to develop commercial applications with Free Pascal, it would be good for that programmer to pick a stable version of the compiler, usually the latest one but, it doesn't have to be and, not upgrade unless there is really a very significant gain to be obtained from upgrading.  That way, the programmer gets to know the bugs and "peculiarities" of the compiler and figures out ways to avoid them.  Upgrading is basically a new set of bugs and peculiarities that have to be dealt with as they come up.  That's often time consuming.

One thing about the Golden Age of Pascal I vividly remember, Turbo Pascal made reasonably small executables that were also reasonably fast and, the development cycle was the fastest in town.  In many cases, it was reasonable to use Turbo Pascal as a replacement for Assembler.  The price paid in size and execution speed was acceptable and,  there really were few, if any, limits to what you could do with it, including replacing interrupt handlers, programming the hardware on the motherboard and, just about anything a programmer wanted to do.  Attempting those things with Pascal today, when doable (which is not often), the result is so-so at best.

To the OP, whether using Pascal, Free Pascal in this case, is a good solution for you, depends on the project.  For some things it will be great, for others, "not so great".   

There is no tool/language that does everything well.  For whatever a language does well, there is a "price" to pay in whatever areas it doesn't do so well and, those are always present in one way or another.

You presented a long wish list.  I cannot think of one language that is really good at all of those things.
Title: Re: Is Pascal the right language for me ?
Post by: marcov on June 30, 2020, 10:46:49 am
As this is the forum for Lazarus/FPC/Pascal, I'm sure you already got what are the advantages of using Lazarus/FPC/Pascal. But I'm the less biased so I will tell you no, don't use Lazarus, Free Pascal, nor Pascal.

Lazarus and Free Pascal are not commercial supported.
You should consider the other paid alternatives first. Lazarus/FPC is free, you can use it and start making money without spending a dollar. That is not as great as you thought, that also means no one is 'really' responsible for fixing the bug you may have someday when you use it. Here we have bugtracker, but as open source project, Lazarus and Free Pascal rely on volunteers and we currently are lack of volunteers.

Commercial support was often stated as any reason to not use open source, it is an old, year 2000 argument.
How many bugs have you gotten fixed from big commercial vendors on personal title? Rare if not never.
Most commercial support is beginner hand holding, but as soon as it gets difficult and real skills are needed, it dries up, or gets crazy expensive(we have "services" for that). Specially if the product is not the focus of corporate policy anymore.  It might be easier to actually pay a fpc/lazarus devel to fix something than to get a big corporation to do something.

Small, specialized vendors might be different, but they are again not as rock steady (might not survive even the current crisis, or change business directly completely), and thus fail the "surety" argument.

And that was before everybody wants to start using some javascript derivate in free VS Code. No support...

Quote
I can use Lazarus to build games for days, but I can achieve the same result in less than half hour if I use game specialized development tools.

But that kind of games are the domain of dozen+ large teams with a multimillion budget anyway. It is not just a specialized tool, but also a specialized market.

Quote
Pascal's golden era has passed.
Pascal was so popular in the 80s. Nowadays, Pascal is still alive but not many people are using it. Which are the industry standard are not important if you are a hobbyist. But if you're planning to start a career or business in the software development field, you really need to pay attention about it.

It depends very much on what you do. I think this is a bit overly black and white. And one of the problem is that currently the popular choices are changing so often they might not even be there any more if you quit your current job. 

If you are really in hardcore IT work-for-hire, as in a new project every 4 months, then you probably go whatever the majority of your team goes with. Even if you have the power to force them to use your choice, it will just make you responsible for every little problem ad infinitum.   

If you are self employed or work in a situation where IT is part of a product or service, it is less important, and your long term maintainability becomes important. And nowadays Lazarus' continuity is actually a plus there.

If you are hobby, that long term view is even more important, since your development will go slower, and you want to be able to maintain for a while to reap the rewards of your effort.

Despite Delphi's current crazy pricing throwing a spanner in the old switcheroo trick, it is also still possible: start with lazarus, and continue with Delphi if necessary if it hits off.   

Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 10:50:49 am
[...] as open source project, Lazarus and Free Pascal rely on volunteers and we currently are lack of volunteers.

Which I suppose could be translated as "there are more people who like what we have produced than are able (i.e. have both the time and the capability) to contribute to the project". That might actually be a healthy situation, but as has already been said it does suggest that it's wise to keep away from the "bleeding edge" (currently 3.2.0) and instead to use a version which has accumulated bugfixes (e.g. 3.0.0, with fixes to 3.0.4).

And if you're avoiding the latest compiler, you also need to be aware that you will need to peg your version of Lazarus down, since eventually the current/stable version will start using recently-introduced features of the compiler.

Quote
Pascal's golden era has passed.
Pascal was so popular in the 80s. Nowadays, Pascal is still alive but not many people are using it. Which are the industry standard are not important if you are a hobbyist. But if you're planning to start a career or business in the software development field, you really need to pay attention about it.

I think that a lot of people would agree with that, but it's difficult to know what to recommend as an alternative /particularly/ when considered in conjunction with Lazarus as a RAD/IDE.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: Handoko on June 30, 2020, 12:18:48 pm
Pascal's golden era has passed.
Pascal was so popular in the 80s. Nowadays, Pascal is still alive but not many people are using it. Which are the industry standard are not important if you are a hobbyist. But if you're planning to start a career or business in the software development field, you really need to pay attention about it.

For example, if you're a boss who own a software development business. You want to hire new employees, you will get more candidates if your use C/C++, Java, Python, PHP, etc.

[...] as open source project, Lazarus and Free Pascal rely on volunteers and we currently are lack of volunteers.

Which I suppose could be translated as "there are more people who like what we have produced than are able (i.e. have both the time and the capability) to contribute to the project". That might actually be a healthy situation ...

You're very smart.  :)
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on June 30, 2020, 01:25:35 pm
Lazarus and Free Pascal are not commercial supported.
You should consider the other paid alternatives first. Lazarus/FPC is free, you can use it and start making money without spending a dollar.

This is a very weak argument especially regarding programming languages. Most programming languages and tools are FOSS, and even those who have a company behind them are often OpenSource (like C#) or have OpenSource alternatives (like Java). Most prevalent of the most used languages mainly utilize a fully FOSS infrastructure. C/C++, the most important tools are gcc, gdb and clang, all FOSS. Javascript: node, chrome (v8), Firefox FOSS. Python, CPython: FOSS. Java OpenJDK: FOSS, PHP: FOSS, C# Mono: FOSS, hell even Swift, the apple language is released under a FOSS license.

For all of these languages you have the problem that
Quote
no one is 'really' responsible for fixing the bug
but they still get that job done

The problem is not that Lazarus and FPC are free and open source, but the lack of volunteers. That said, it's pretty rarely that you run into a breaking bug. With rather advanced generic stuff this occurs rather oftern (how i loathe the error message: "an internal exception occured during compilation" or "fpc internal error ...", which occurs nearly every time generics projects start to get big), but aside from this, if you don't do anything fancy, fpc is pretty stable.

Quote
Lazarus and Free Pascal are general purpose development tools.
You can use them to build anything you can imagine, if you know how. Games, image processing software, database/inventory/accounting/ERP applications, audio/video players, web servers and even operating systems. But as a general purpose tool, they have disadvantage too. I can use Lazarus to build games for days, but I can achieve the same result in less than half hour if I use game specialized development tools.
Most languages and tools used today are general purpose tools, none of the languages listed above are specialized for anything. Python got the defacto ML language, but not because Python is built for ML, but because it is used by many in that area over others. Torch or Tensorflow bindings exist for any language.
Similarly, while many Game Engines use C++ or C# and scripting languages like JavaScript or LUA, you could very easily just convert the Godot C headers to Pascal and use it to program your games in Pascal using a specialized game engine (which btw. is also FOSS under MIT license).

But as I said in an earlier post, no one shoe fits all, and I personally decide for which language to use based on the specific task. I personally really like Pascal for two things: 1. Desktop application 2. Server applications. I wouldn't use it for mobile development (maybe with Pas2JS and cordova, but haven't tried this rn) or for developing a neural network. But I don't see much of a reason in the cases where pascal works great, to not use it.
Title: Re: Is Pascal the right language for me ?
Post by: Handoko on June 30, 2020, 01:39:06 pm
As I do not make money from programming, what I said should not be taken too seriously.

I remember a fellow here, he later switched to other paid development tool. He told me he was looking for a development tool which he wished to start a business. One reason he said if I remember correctly, he cannot 'yell' on the customer/technical support team if something not working as it should be if he uses Lazarus.

Also, you know if someone asks new feature and be too pushy in this forum, probably s/he will get the answer, "it is open source, take the source code and do it yourself."

I don't mean open source is bad, but I just want to let the OP know the disadvantages of using open source. Of course I could be wrong.

For you information, Godot is far too inferior compare to Unreal Engine.
https://www.youtube.com/watch?v=a694QEQeFDg (https://www.youtube.com/watch?v=a694QEQeFDg)
Title: Re: Is Pascal the right language for me ?
Post by: PascalDragon on June 30, 2020, 01:50:27 pm
Which I suppose could be translated as "there are more people who like what we have produced than are able (i.e. have both the time and the capability) to contribute to the project". That might actually be a healthy situation, but as has already been said it does suggest that it's wise to keep away from the "bleeding edge" (currently 3.2.0) and instead to use a version which has accumulated bugfixes (e.g. 3.0.0, with fixes to 3.0.4).

FPC 3.2.0 has accumulated many bug fixes as well that have not found their way back into 3.0.4. Also 3.2.0 is not really bleeding edge anymore. It was branched around two years ago and took all that time to ripe.

The problem is not that Lazarus and FPC are free and open source, but the lack of volunteers. That said, it's pretty rarely that you run into a breaking bug. With rather advanced generic stuff this occurs rather oftern (how i loathe the error message: "an internal exception occured during compilation" or "fpc internal error ...", which occurs nearly every time generics projects start to get big), but aside from this, if you don't do anything fancy, fpc is pretty stable.

I personally prefer exceptions and internal errors as they're usually rather easy to fix. Take a problem like this (https://bugs.freepascal.org/view.php?id=37259) and I'd like to bash my head against the desk or the next wall. %)

I remember a fellow here, he later switched to other paid development tool. He told me he was looking for a development tool which he wished to start a business. One reason he said if I remember correctly, he cannot 'yell' on the customer/technical support team if something not working as it should be if he uses Lazarus.

If a customer would 'yell' at my workplace's support then he wouldn't be a customer of us for long. We try to deescalate such customers of course (and in 99% of such cases that works), but if they insist to think they're the most important being in the world then it's "We don't need to do business with you, good day". It didn't happen very often in the past, but happen it did. *shrugs*
Title: Re: Is Pascal the right language for me ?
Post by: thehidden on June 30, 2020, 02:01:30 pm
...Pascal or not Pascal...

In my opinion you can say  ** or not ** and replace the ** with any programming language. Existing or dead.

Every application or requirement has his favorite programming language. For me it is more a philosophic question, based on needs, experience, policies, etc.

There is no right or wrong programming language.

You want to use Pascal? Do it - or not. Depending on your feelings.

You want to work for somebody with Pascal or Delphi Experience. Maybe harder to find an employer, but not impossible. Pascal isn't dead as long as people talk about and use it.
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on June 30, 2020, 02:04:51 pm
I don't mean open source is bad, but I just want to let the OP know the disadvantages of using open source. Of course I could be wrong.
At least with regards to software development, languages and tools, Free tools are the norm, with the overwelming majority even being FOSS, while paid tools are ususally only niche tools where there is no big community behind. In such cases FOSS simply can't survive, because it lives from there being many contributers

Quote
For you information, Godot is far too inferior compare to Unreal Engine.
Of course an engine that is only around for 5-6 years will be inferior to one thats been around for 22 years. But for the time godot is around it makes incredible progress. Especially as companies start pouring money into it, because they want to have a good FOSS engine themselves (as this is cheaper in the long run)
Title: Re: Is Pascal the right language for me ?
Post by: Handoko on June 30, 2020, 02:12:55 pm
You want to work for somebody with Pascal or Delphi Experience. Maybe harder to find an employer, but not impossible. Pascal isn't dead as long as people talk about and use it.

+1

If a customer would 'yell' at my workplace's support then he wouldn't be a customer of us for long. We try to deescalate such customers of course (and in 99% of such cases that works)

The problem is, we don't have any 'real' customer service here.
Title: Re: Is Pascal the right language for me ?
Post by: thehidden on June 30, 2020, 02:16:53 pm
Quote
The problem is, we don't have any 'real' customer service here.

 :D :D :D
Have you tried to get 'real' customer support from some companies?

Not much companies have a support which is worth enough to call it so...

My experience: Have a Lazarus problem, talk about here and problem mostly solved. Some can't be solved, but this is a nature thing. Not every idea is possible in real live.
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 02:19:28 pm
Also, you know if someone asks new feature and be too pushy in this forum, probably s/he will get the answer, "it is open source, take the source code and do it yourself."

There is, obviously, a massive learning curve... and it tends to be exponential relative to the size of the codebase.

However as somebody (Marco?) said earlier, if somebody really had a requirement he could always ask if any of the core developers were available for paid contract work, if necessary to generate a "fork" for him if what he needed was likely to be incompatible with the mainstream.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 02:21:52 pm
Have you tried to get 'real' customer support from some companies?

20+ years on, I still cringe whenever I hear Vivaldi's "Four Seasons" due to the hours I spent listening to it waiting for OS/2 support from IBM- for which I was paying. If I were in the USA I'd sue...

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: Handoko on June 30, 2020, 02:25:55 pm
Also, you know if someone asks new feature and be too pushy in this forum, probably s/he will get the answer, "it is open source, take the source code and do it yourself."
However as somebody (Marco?) said earlier, if somebody really had a requirement he could always ask if any of the core developers were available for paid contract work, if necessary to generate a "fork" for him if what he needed was likely to be incompatible with the mainstream.

That's interesting. Please write it on the FAQ or somewhere. So if any newbie asking for hard-to-implement features, I will direct him to the page.
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 02:29:41 pm
https://wiki.freepascal.org/Bounties

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: marcov on June 30, 2020, 02:49:01 pm
Quote
The problem is, we don't have any 'real' customer service here.

 :D :D :D
Have you tried to get 'real' customer support from some companies?

Not much companies have a support which is worth enough to call it so...

Take for instance the logical commercial party to compare with, Delphi. With the buying of Delphi you only got installation support. For actual issues or other help you needed to have subscription (usually 25% of purchase price an year, several hundred to 500-600 dollar/euro)

Title: Re: Is Pascal the right language for me ?
Post by: thehidden on June 30, 2020, 03:53:30 pm
Take for instance the logical commercial party to compare with, Delphi. With the buying of Delphi you only got installation support. For actual issues or other help you needed to have subscription (usually 25% of purchase price an year, several hundred to 500-600 dollar/euro)

For some old projects I need to support RAD Studio Enterprise. There we are talking about 1000+ for updates only...
Title: Re: Is Pascal the right language for me ?
Post by: korba812 on June 30, 2020, 03:58:26 pm
Real Programmers Don't Use PASCAL
https://www.ee.ryerson.ca/~elf/hack/realmen.html (https://www.ee.ryerson.ca/~elf/hack/realmen.html)
but I'm a quiche eater  :P
Title: Re: Is Pascal the right language for me ?
Post by: winni on June 30, 2020, 04:25:50 pm
Hi!

This is an old version of "Real Programmers Don't Use PASCAL"

In a  newer version there is also

"Real programmers code a pattern  matching for the Jupiter moons. In the last 570 free bytes of the Voyager IV. "

Winni
Title: Re: Is Pascal the right language for me ?
Post by: Handoko on June 30, 2020, 04:30:48 pm
Lol.

Well, I'm not a real programmer. I'm just a hobbyist. That's why I use Pascal. Pascal is great for hobby projects, I remember I ever heard so.
Title: Re: Is Pascal the right language for me ?
Post by: marcov on June 30, 2020, 04:55:49 pm
This is an old version of "Real Programmers Don't Use PASCAL"

In a  newer version there is also

"Real programmers code a pattern  matching for the Jupiter moons. In the last 570 free bytes of the Voyager IV. "

"Real Old school programmers had no computers, they carved their programs in sheets of ice with an old walrus-tooth"
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 05:00:41 pm
This is an old version of "Real Programmers Don't Use PASCAL"

In a  newer version there is also

"Real programmers code a pattern  matching for the Jupiter moons. In the last 570 free bytes of the Voyager IV. "

Yes, but you have to look at that in the context of the culture in which it was written: it's not so much that "X doesn't like Pascal" but "X is so tough and proficient that he doesn't need stuff to make his life easier".

It's exactly the same as Dijkstra's language pronouncements:

Code: [Select]
* FORTRAN --"the infantile disorder"--, by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use.

* PL/I --"the fatal disease"-- belongs more to the problem set than to the solution set.

* It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

* The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.

* APL is a mistake, carried through to perfection. It is the language of the future for the programming techniques of the past: it creates a new generation of coding bums.

It's sad- or at least I consider it to be sad- that those five points are now considered to be the last word on those languages, when they are merely a small part of a paper entitled "How do we tell truths that might hurt?" which starts with the words "Sometimes we discover unpleasant truths. Whenever we do so, we are in difficulties: suppressing them is scientifically dishonest, so we must tell them, but telling them, however, will fire back on us." https://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html

Dijkstra was, I am quite sure, being intentionally obnoxious: it was not so much "these are definite truths" as "how can we even find a way to talk about this stuff? And for anybody unfamiliar with his corpus, I can assure you that he was far more vocal in his disdain for IBM than in his dislike of BASIC etc., despite any popular belief to the contrary.

Now I'm not saying that Pascal's perfect, and I'm not saying that criticism of the language and- dare I say it- community is unjustified. But both Pascal and Dijkstra need to be judged by their contribution to the profession, and since today's popular languages are overwhelmingly tending towards managed variables and robust type checking I think that Wirth and Dijkstra have won hands-down.

It's most unfair that Dijkstra died too young to have expressed a robust opinion of C, C++ and Javascript, since it leaves us having to make do with Stroustrup's "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off". With friends like that...

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: winni on June 30, 2020, 05:08:02 pm
Hej - Stroustrup knows exactly what he is talking about!

And he is the first one who knows it!

Winni
Title: Re: Is Pascal the right language for me ?
Post by: marcov on June 30, 2020, 05:13:18 pm
But both Pascal and Dijkstra need to be judged by their contribution to the profession, and since today's popular languages are overwhelmingly tending towards managed variables and robust type checking I think that Wirth and Dijkstra have won hands-down.

Don't forget C++20's modular programming proposals!

Title: Re: Is Pascal the right language for me ?
Post by: winni on June 30, 2020, 05:15:45 pm

Don't forget C++20's modular programming proposals!

50 years after UCSD Pascal had it.

High time! Or too late????

Winni
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 05:50:36 pm
Don't forget C++20's modular programming proposals!

I suspect that compiling-every-time makes templates etc. easier. I think that Stallman's observations on a variant of Pascal with parameterised types are relevant: the entire program had to be compiled to a parse tree before it was possible to generate code, so as soon as a program got too big for local memory (usually a few hundred Kb on a PDP-11) you were in trouble.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on June 30, 2020, 05:56:18 pm
Now I'm not saying that Pascal's perfect, and I'm not saying that criticism of the language and- dare I say it- community is unjustified. But both Pascal and Dijkstra need to be judged by their contribution to the profession, and since today's popular languages are overwhelmingly tending towards managed variables and robust type checking I think that Wirth and Dijkstra have won hands-down.

It's most unfair that Dijkstra died too young to have expressed a robust opinion of C, C++ and Javascript, since it leaves us having to make do with Stroustrup's "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off". With friends like that...

I find it rather interesting on the different routes the different programming languages go. Languages like Kotlin or Swift for example got rid of null pointers, which Hoare called his "Billion dollar mistake". Rust has its strict ownership semantics, that allow for extremely efficient memory management without the use of ref counting or garbage collection. And of course a big focus in many modern language is the usage of functional style programming like higher order functions, pattern matching, closures, etc.
I mean even JavaScript (and trust me, I could rant about JavaScript all day) is based on a pretty unique concept.

And this is IMHO a pretty neat thing, you have a lot of languages that are simply conceptually different, giving you a lot of variaty on how you can solve a task. Pascal is for example a pretty classical imperative language, which does not support a lot of fancy new paradigms, which has the charme that one who hasn't used pascal for years can simply sit down, open up an old project and continue working on it, while languages like python let you solve problems in a very easy and concise way
And the best thing about this is, it is mostly free. Everyone can download a compiler/interpreter for a given language, open the getting started page and start programming with it (assuming you already are familiar with a lanugage it is usually rather easy to learn a new one).
I recently (re)discovered Haskell which is a really wonderful language, but sadly I don't have so much free time to learn new programming languages anymore (the list of languages I want to try out is steadily increasing).
But if one starts a new project, thats the perfect time to check out whats out there and what would be a great fit for the given Project (that said, in a commercial project you should calculate some extra time for getting used to the language and initial mistakes)
Title: Re: Is Pascal the right language for me ?
Post by: 440bx on June 30, 2020, 06:42:34 pm
All this stuff reminds me how different it is when you use a programming language on "big iron".

Yes, the company pays a monthly support fee (more than most individuals can afford) but, when a customer finds a bug in the compiler, it doesn't take long for that bug to be acknowledged, fixed and, at least an "interim" release be made available to the customers who need it.

Also, there is little inclination from any of the parties (supplier and customer) to see more and more features added to the compiler.  A compiler isn't supposed to be Imelda Marco's shoe closet of features.  Object oriented polymorphic high heels... on generic leather.

The above isn't a problem specific to Pascal.  It seems PC class software is driven by upgrade cycles fueled by featurities.

Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 06:55:39 pm
And the best thing about this is, it is mostly free.

Yes, now that people know how to do it. Back in the day, when compiler writing and API/library design were black arts, stuff was most definitely /not/ free:

Quote
Shortly before beginning the GNU Project, I heard about the Free University Compiler Kit, also known as VUCK. (The Dutch word for “free” is written with a v.) This was a compiler designed to handle multiple languages, including C and Pascal, and to support multiple target machines. I wrote to its author asking if GNU could use it.

He responded derisively, stating that the university was free but the compiler was not. I therefore decided that my first program for the GNU Project would be a multilanguage, multiplatform compiler. -- https://www.gnu.org/gnu/thegnuproject.html

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: ASBzone on June 30, 2020, 07:50:57 pm
"Real Old school programmers had no computers, they carved their programs in sheets of ice with an old walrus-tooth"

Bah!  That's when they started getting soft.

"Real Old school programmers had no computers, they carved their programs in sheets of ice with a walrus-tooth which they recently relieved from the biggest walrus around!"
Title: Re: Is Pascal the right language for me ?
Post by: ASBzone on June 30, 2020, 07:59:57 pm
The above isn't a problem specific to Pascal.  It seems PC class software is driven by upgrade cycles fueled by featureitis.

This is driven by the economics model.  Big Iron has it's long term support contracts.  There is steady money coming in, a focus on keeping customers happy enough to renew the contract, and so there is little need for featureitis.

The PC world was based on primarily on competition, and licensing subscriptions went away ages ago (only to return in the SaaS / Cloud era), and so there are all sorts of attempts at lock-in, and featureitis, because change is relatively easier than Big Iron (where software changes are often synonymous with hardware changes).

These represent the two most common ways to keep the money flowing for vendors.
Title: Re: Is Pascal the right language for me ?
Post by: 440bx on June 30, 2020, 08:15:18 pm
This is driven by the economics model.  Big Iron has it's long term support contracts.  There is steady money coming in, a focus on keeping customers happy enough to renew the contract, and so there is little need for featureitis.

The PC world was based on primarily on competition, and licensing subscriptions went away ages ago (only to return in the SaaS / Cloud era), and so there are all sorts of attempts at lock-in, and featureitis, because change is relatively easier than Big Iron (where software changes are often synonymous with hardware changes).
All very true.  It would be nice if some of these companies using the "upgrade model" also offered a "stability model" for those who are more interested in ever increasing reliability and stability than fancy new features.  As the saying goes: it is what it is.  oh well...
Title: Re: Is Pascal the right language for me ?
Post by: 440bx on June 30, 2020, 09:08:30 pm
"Sometimes we discover unpleasant truths. Whenever we do so, we are in difficulties: suppressing them is scientifically dishonest, so we must tell them, but telling them, however, will fire back on us." https://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html
I couldn't resist making a comment on that one.  The three things he said that I find ever more brutally applicable to the field are:

Quote
1. The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities.

2. Besides a mathematical inclination, an exceptionally good mastery of one's native tongue is the most vital asset of a competent programmer.

and

3. Simplicity is prerequisite for reliability.

The first one is particularly insidious and amazingly widespread.
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on June 30, 2020, 09:24:03 pm
"Sometimes we discover unpleasant truths. Whenever we do so, we are in difficulties: suppressing them is scientifically dishonest, so we must tell them, but telling them, however, will fire back on us." https://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html
I couldn't resist making a comment on that one.  The three things he said that I find ever more brutally applicable to the field are:

Quote
1. The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities.

One has to be careful with that philosophy, it can lead in inconvenient directions.

For example, many computer scientists profess to be followers of Whorf and to be searching for a notation which prevents common programming errors, while at the same time being prepared to countenance syntaxes which can't be parsed easily and semantics which require complex run-time support.

If you have the stomach for it, https://www.jsoftware.com/papers/tot.htm is another classic paper.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: ASBzone on June 30, 2020, 09:27:55 pm
1. The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities.


Yes, I agree.  This is becoming more and more evident to me as time goes by...
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on June 30, 2020, 09:52:38 pm
Quote
1. The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities.

Yeah, but It's not really insightful, this is basically a rephrasing of "If you have a hammer, everything is a nail".
Thats why it's so important to have many different tools at hand. If you give a life long C programmer the task to parse an string, he will most probably start by writing a low level state based text parser, while if you give the same task to a python programmer, he will probably just write a regex for it. That's the reason why I believe everyone should try out at least a few different paradigms like functional programming, it really broadens your horizon and allows you to think differently about problems.

For example, many computer scientists profess to be followers of Whorf and to be searching for a notation which prevents common programming errors, while at the same time being prepared to countenance syntaxes which can't be parsed easily and semantics which require complex run-time support.
It fully depends on what your needs are. For example, garbage collection is pretty slow, but if you don't need that performance and you simply want to get something done without having to think a. about ownership or b. about memory management, it works great (see Java, the performance penalty is not stopping it from being one of the most prevalent languages).
But even if you are concerned about performance there are many compile time possibilities, like they are employed by rust (and partly C++). Or, my favorite example for this are Null pointers. Null pointer errors are extremely tedious, even in pretty "safe" languages like Java.
But there is no need for them to exist. In for example TypeScript, Swift or Kotlin, there are no Null pointers, there are only Nullable variables. This means, every variable that can become null, must be marked as such. If a variable is marked as null, everywhere where it is used, you need to check if it is assigned (provable at compile time). If you know a variable will never be null, you will not mark it, and then you (and the compiler) knows, what ever happens, in this variable will always be a valid pointer.
All of this happens during compile time, and with this little change, Nullpointer derefenrencing seg-faults are simply not possible anymore. One of the major bug sources simply gone by a better language design without any penalty

Languages are designed with specific goals in mind. For example, haskell applications become huge because haskells lazy evaluation strategy requires a lot of boilerplate code for the compiler to generate. It is also not the fastest, but in haskell you can handle infinitely large objects with ease, something that is not easily possible in other languages.

It's all a matter of requirements. I would never write an OS in Java, but I also wouldn't write a cross plattform gui program in C.
Title: Re: Is Pascal the right language for me ?
Post by: gour on August 11, 2020, 02:38:44 pm
It depends very much on what you do. I think this is a bit overly black and white. And one of the problem is that currently the popular choices are changing so often they might not even be there any more if you quit your current job. 
...
If you are self employed or work in a situation where IT is part of a product or service, it is less important, and your long term maintainability becomes important. And nowadays Lazarus' continuity is actually a plus there.
If you are hobby, that long term view is even more important, since your development will go slower, and you want to be able to maintain for a while to reap the rewards of your effort.

Let me just share my story...Five years ago I was already interested in FPC/Lazarus wanting to work in my spare time on a hobby project -- open-source multi-platform desktop application, but due to several reasons had to postpone it until today...In the meantime I was considering/evaluating and/or played with several languages and eliminated them for the various reasons, like:

Then I did try/consider some like:
From the very beginning I also eliminated Electron and similar JS-powered stuff wanting to have native application.

To make the story short, I ended up with the following possibilities:
When I was already a bit in despair I've remembered FPC/Lazarus which I did explore in the past and which seems as the only solution for my use case to fulfill (almost) all of my requirements and I really wonder why it is not used more widely.  :o

Considering I plan to work on the project in my free time for a longer period of the time, I also consider that FPC/Lazarus' "Lazarus' continuity" is a great 'pro'.  :D

Moreover, FPC/Lazarus does offer opportunity, afaict, to even write 'lighter' version of my application for e.g. my Android phone. 8-)

I was writing code on my university using Turbo Pascal (compiler course) and like...after graduating my life went into another direction, but I'm happy to, somehow, close the circle, by returning back to Pascal hoping it won't take me too long to get into it, while, afaics, Lazarus does provide environment for RAD.

I've some question about recommended procedure to learn/master FPC/Lazarus, but that's not appropriate for this thread.  ;)

Any comment on my reasoning and/or whether I've arrived to the proper solution?
Title: Re: Is Pascal the right language for me ?
Post by: marcov on August 11, 2020, 02:57:06 pm
Any comment on my reasoning and/or whether I've arrived to the proper solution?

It's basically my reasoning too. Even if I for some reason change the tooling for some main app, and in my line of work (Vision) that usually means C++, I think all the small programming stuff, the utils, the scripts etc remains in FPC/Lazarus.
Title: Re: Is Pascal the right language for me ?
Post by: BeniBela on August 12, 2020, 11:02:15 pm
For example, garbage collection is pretty slow, but if you don't need that performance and you simply want to get something done without having to think a. about ownership or b. about memory management, it works great (see Java, the performance penalty is not stopping it from being one of the most prevalent languages).
In many cases garbage collection can be faster than heap allocatiojn.

Moving garbage collectors could also move data around to improve cache locality.

Or, my favorite example for this are Null pointers. Null pointer errors are extremely tedious, even in pretty "safe" languages like Java.
But there is no need for them to exist. In for example TypeScript, Swift or Kotlin, there are no Null pointers, there are only Nullable variables. This means, every variable that can become null, must be marked as such. If a variable is marked as null, everywhere where it is used, you need to check if it is assigned (provable at compile time). If you know a variable will never be null, you will not mark it, and then you (and the compiler) knows, what ever happens, in this variable will always be a valid pointer.

It is very silly that Pascal went from having only record and objects on the stack, which are never null, to classes where every class object can be null
Title: Re: Is Pascal the right language for me ?
Post by: winni on August 12, 2020, 11:30:20 pm

It is very silly that Pascal went from having only record and objects on the stack, which are never null, to classes where every class object can be null

Hi!

Yes - that is true.

But look at Borlands situation in the mid 90s:

Turbo Pascal for Windows was awful and a big flop.
But in the background Delphi was developed - with one great idea:
It was a milestone for Rapid Prototyping .
The second big change was not so brilliant:
The introduction of classes.

But Classes came then into fashion despite all the debates:
There were the critics of N. Wirth, there were the critics because of the inheritance.
And there were fans of the "old" Turbo Object Model which was introduced then not long ago.

But we allways have to be a "dedicated follower of fashion" (Ray Davis, The Kinks, 1966).
So the Classes were implemeted into Delphi 1.
And 25 years later they are still there.

Not mater if sense or nonsense.

Winni


Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on August 13, 2020, 09:06:20 am
It is very silly that Pascal went from having only record and objects on the stack, which are never null, to classes where every class object can be null

Would I be right in assuming that an object on the stack has its lifetime defined by the scope of the function in which it is declared? If that is correct then ISTM that it implies excessive reliance on global variables, or alternatively Pascal would have needed an equivalent to ALGOL's OWN which is generally considered to be a mess.

It's not instances of classes that are nullable, it's anything on the heap as a general statement. And ISTM that the bigger problem is not null (pointers to) instances, but invalid pointers in general (uncluding doubly-freed as a special case).

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: 440bx on August 13, 2020, 10:18:15 am
Would I be right in assuming that an object on the stack has its lifetime defined by the scope of the function in which it is declared?
That's correct. Just like any other variable, an object (not a class) on the stack "vanishes" when the function/procedure goes out of scope.

If that is correct then ISTM that it implies excessive reliance on global variables,
Not really.  The program can use heap blocks for data it wants to be persistent, that said, heap blocks do share some of the global variable problems and, an additional one which is, one must remember to free them when no longer needed.  Classes give you the _worst_ of both worlds, there is almost always at least one class variable that is a global variable and its data is allocated on the heap.  Gotta love it. :)


Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on August 13, 2020, 10:26:21 am
But at that point if you're using a heap block you've already got a (nullable) pointer to it. Delphi-style classes and instances only change things by hiding the indirection.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: 440bx on August 13, 2020, 10:42:03 am
But at that point if you're using a heap block you've already got a (nullable) pointer to it.
True. 

Personally, I firmly believe that memory management should be tailored to the problem at hand.  That means, a one-size-fits-all "solution" such as class data always being in a heap block is inherently limiting (I'm abstaining from saying it's wrong, even though I firmly believe it's so highly deficient that it would be fair to consider it wrong at least most of the time.)

I think that's the real problem: trying to make a one-size-fits-all "solution" work well in _all_ cases.  I know it doesn't exist and, I seriously doubt it ever will.
Title: Re: Is Pascal the right language for me ?
Post by: marcov on August 13, 2020, 12:53:51 pm
For example, garbage collection is pretty slow, but if you don't need that performance and you simply want to get something done without having to think a. about ownership or b. about memory management, it works great (see Java, the performance penalty is not stopping it from being one of the most prevalent languages).
In many cases garbage collection can be faster than heap allocatiojn.

It often also depends on your testing parameters. The problem is that you rarely can make a pure comparison:


Truth be told, in my year doing .NET, and separate 1.5 years Java, I never saw the wonders of GC for non trivial programs. (In one source programs, global optimizers might simply optimize the GC usage away, or the allocation pattern might be very simple (e.g. always the same size)). At best the slowdown was not really bad, never better.

Quote
Moving garbage collectors could also move data around to improve cache locality.

Which of the main GC languages do this? Other than just after allocation when they are still in the same generation of course?

Or, my favorite example for this are Null pointers. Null pointer errors are extremely tedious, even in pretty "safe" languages like Java.
....
If a variable is marked as null, everywhere where it is used, you need to check if it is assigned (provable at compile time).

Well, actually sounds like replacing one tedious chore by the other.

I never got the obsession with nullability. Basically it only helps when you change a piece of source from non-nullable types to nullable types, and for that case a limited language extension seems to be overkill IMHO.

Most code is made with nullable types, and remains so.

Quote
It is very silly that Pascal went from having only record and objects on the stack, which are never null, to classes where every class object can be null

Yes. No tricks under the hood to make static types to look like dynamic ones. No autoboxing either (well, one could maybe consider type helpers a form of that)
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on August 13, 2020, 01:29:45 pm
Quote
Moving garbage collectors could also move data around to improve cache locality.

Which of the main GC languages do this? Other than just after allocation when they are still in the same generation of course?

My recollection is that the Smalltalk "Green Book" documents a GC that does that: alternately consolidates data to one end of the heap or the other.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: marcov on August 13, 2020, 01:56:51 pm
My recollection is that the Smalltalk "Green Book" documents a GC that does that: alternately consolidates data to one end of the heap or the other.

I'm just trying to distinguish alleged possible features from features that are actually proven. Quite often these kinds of optimizations are demonstrated with crafted one piece source on some convention, but it is often hard to successfully integrate it in a production toolchain, because there is much more competition for a place in the cache then, and it requires an overall optimization.
Title: Re: Is Pascal the right language for me ?
Post by: MarkMLl on August 13, 2020, 03:00:26 pm
My recollection is that the Smalltalk "Green Book" documents a GC that does that: alternately consolidates data to one end of the heap or the other.

I'm just trying to distinguish alleged possible features from features that are actually proven. Quite often these kinds of optimizations are demonstrated with crafted one piece source on some convention, but it is often hard to successfully integrate it in a production toolchain, because there is much more competition for a place in the cache then, and it requires an overall optimization.

In any event, Smalltalk was a special case since the entire system- including RAM and any swapspace on disk- was dedicated to a single environment.

MarkMLl
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on August 14, 2020, 01:20:34 pm
In many cases garbage collection can be faster than heap allocatiojn.

Moving garbage collectors could also move data around to improve cache locality.

The two big GCs (.Net and Java) are both generational garbage collection systems optimized for speed of small allocations. They consist basically of three stacks, gen 1-3, and when you allocate an object it is just pushed to the g1 stack. When the garbage collector starts running (after a certain time, or if g1 stack reaches a certain size), every object that is still in use in g1 gets pushed to g2 and g1 will be completely erased.
If g2 reaches a certain size (much bigger than g1) it will go through the same procedure and everything that survives now lives happiely in g3. There the assumption is, that everything that survived the gc 2 times, is probably here to stay, and g3 will never be cleared (Might sound stupid, but in reality, this seems to be a good assumption).

So the cleartime is O(StackSize*AverageNumReferencesToObjects) because for every object, all references need to be rewritten. But the allocation of an object, as this is just increasing a stack pointer, is basically free (compared to traditional heap allocation systems which have to search free space) and while g2 gc is expensive, Microsoft reported somewhen that their g1 gc is performed in around the time it takes Windows to handle a page fault.

So if you allocate a lot of temporary objects (like in Pascal is often done with for example streams or string lists), gc might even be faster, but the thing about GC is that it is unpredictable on when  the g2 gc runs, which can cause notable lags. Also memory fragmentation simply doesn't happen with such GC systems. It all depends on what you need.
Which is exactly why I like pascal old school objects, because they live on the stack and it always feels like a complete waste of resources to create a TStringList for only one small procedure. But thats historic and we can't travel back in time and tell borland to do it any other way

Btw. while on the desktop the g2 gc lag is not that notable, even in GUI applications, on android, when you control your device on your fingertips every lagg is notable instantly, which is why google had to become creative, but thats a whole different story.
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on August 14, 2020, 01:34:21 pm
Well, actually sounds like replacing one tedious chore by the other.

I never got the obsession with nullability. Basically it only helps when you change a piece of source from non-nullable types to nullable types, and for that case a limited language extension seems to be overkill IMHO.

Most code is made with nullable types, and remains so.

In my experience, while this nullability marking can be pretty tedious at times, depending on the API, checking for null pointer in languages like Java is much more tedious. Of course when you do something like (typescript example, which also has this system):
Code: Javascript  [Select][+][-]
  1. if (map.contains(key)) {
  2.   let result = map.get(key); // optional but I know it's not
  3. }
It is annoying, but for this there is the "Hack" of simply writing !, which means: "I know what I'm doing, trust me" and avoids these checks.

But the thing where it is useful (I must confess this is more a problem in the Java world but anyway) is not when types change, but null pointer errors are most often documentation errors, where someone uses an API or a lib and thinks a value can't be null, but then it is. Maybe the user has not looked closely enough into the API docs, or the API docs are not sufficient, both things happen often (and simply telling programmers to do it right hasn't worked out for 30 years now). Another problem that can lead to null pointer errors is complexity, when you carry a variable around through many paths, on which one might lead to it not being initiated (some cornercase or so) but it is not obvious to see.

The optional type solves this problem on a technical level, where the type itself tells you if it is optional or not and if the compiler can't prove that a type will be be initilized on all paths and it is not marked as optional, it won't compile. It basically goes the route of replacing documentation by a clear coding pattern, which is great, because documentation is something that somehow never works (either outdated, not written at all, or ignored by the users)

From my experience this works incredibly well. The only main source of annoyance are interfaces with languages that don't have this type system, like in typescript, when you use a classical js library, a value from the js library can always be everything, so it always optional and then you get to the same problems as before, just with additional syntax.
Title: Re: Is Pascal the right language for me ?
Post by: marcov on August 14, 2020, 02:57:39 pm
So if you allocate a lot of temporary objects (like in Pascal is often done with for example streams or string lists), gc might even be faster, but the thing about GC is that it is unpredictable on when  the g2 gc runs, which can cause notable lags.

It would be maybe, if Object Pascal strings weren't already refcounted and copy-on-write that avoids a lot of copying and recreating when passed through the call chain, and the .NET a purely GC solution without the  deduplicated immutable string table ducttaped on.

Quote
Also memory fragmentation simply doesn't happen with such GC systems.

Of course it does. At a given time not all allocated memory will be referenced by the program. And not all those tiny bits can fit any size program.

It is just that it can prevent that by moving them, making memory fragmentation solvable, even if the basic heuristics (e.g. multiple freelists by size of object) fail.   They can also postpone those standard heurtistic tricks to when later generations are collected and emptied, rather than on every allocation.

Quote
It all depends on what you need.
Which is exactly why I like pascal old school objects, because they live on the stack and it always feels like a complete waste of resources to create a TStringList for only one small procedure. But thats historic and we can't travel back in time and tell borland to do it any other way

A tstringlist has a fixed size, since the contained strings don't add to the class size. If it is used a lot, there might be dedicated freelist for it, making it fairly cheap to recycle.

But anyway, one can discuss from a theoretic viewpoint till the cows come home, but it the end it is all about benchmarking an application that has equivalent behaviour to your application

Quote
Btw. while on the desktop the g2 gc lag is not that notable, even in GUI applications, on android, when you control your device on your fingertips every lagg is notable instantly, which is why google had to become creative, but thats a whole different story.

Do all threads still halt on GC or has that meanwhile been fixed? I have been out of it for a good decade now, bar attending some Fosdem lectures.
Title: Re: Is Pascal the right language for me ?
Post by: BeniBela on August 14, 2020, 05:39:44 pm
Which is exactly why I like pascal old school objects, because they live on the stack and it always feels like a complete waste of resources to create a TStringList for only one small procedure. But thats historic and we can't travel back in time and tell borland to do it any other way

But we can stop using them

I have started to  write my own records/objects for such small tasks instead of using these classes

TStringList is the worst class. It can do everything a little, but nothing well.


It would be maybe, if Object Pascal strings weren't already refcounted and copy-on-write that avoids a lot of copying and recreating when passed through the call chain, and the .NET a purely GC solution without the  deduplicated immutable string table ducttaped on.


Ref counting is a kind of GC, and  the worst GC for multi threading.


The atomic increment/decrementing really kills all parallelism between threads using the same string


And FPC's implicit exception handling with longjmps makes it even worse
Title: Re: Is Pascal the right language for me ?
Post by: marcov on August 14, 2020, 05:55:32 pm
Ref counting is a kind of GC, and  the worst GC for multi threading.

Most Boehm GCs stop all threads when GCing, so that choice is very debatable. At least refcounting only has very small sync points between threads.

Quote
The atomic increment/decrementing really kills all parallelism between threads using the same string

If you do it extremely fine grained, yes. And that is also pointless. Note that Java/.NET make using strings for such scenarios next to impossible, referring you to tstringbuilder instead.

But maybe if it is guaranteed readonly there is a weakness there. But IMHO that is better than the GC disadvantages.

Quote
And FPC's implicit exception handling with longjmps makes it even worse

FPC 3.2.0+ is SEH on sane platforms.
Title: Re: Is Pascal the right language for me ?
Post by: lainz on August 14, 2020, 09:58:11 pm
Code: Pascal  [Select][+][-]
  1. Is Pascal the right language for me ?

No.

You must ask if FPC and / or Lazarus tools will fit the problem you want to solve. You then must adapt to the language, not the language to you, or well yes if you can, if you're compiler developer or library developer that can extend it as you wish...
Title: Re: Is Pascal the right language for me ?
Post by: Warfley on August 15, 2020, 04:06:36 pm
It would be maybe, if Object Pascal strings weren't already refcounted and copy-on-write that avoids a lot of copying and recreating when passed through the call chain, and the .NET a purely GC solution without the  deduplicated immutable string table ducttaped on.
In the case of String(Lists)s sure, but for example when you use a temporary memory stream to dump a few kb into, this is pretty much uneccessary overehad.

Quote
Of course it does. At a given time not all allocated memory will be referenced by the program. And not all those tiny bits can fit any size program.
Depends on what you call fragmentation, because even though this memory might not be referenced anymore, it is still allocated, so you always have a continuous block of memory. In .Net (I think this does not work in Java) you can poke the GC to clean up, and at any point in time you only have one continous block of allocated memory.

Quote
A tstringlist has a fixed size, since the contained strings don't add to the class size. If it is used a lot, there might be dedicated freelist for it, making it fairly cheap to recycle.

But anyway, one can discuss from a theoretic viewpoint till the cows come home, but it the end it is all about benchmarking an application that has equivalent behaviour to your application
Doesn't all classes have fixed size? That said, I've already writte n a lot of classes like Lists, Hash- and Bitsets, etc. as advanced records for temporary usage. But sadly, as advanced records do not support inheritance, it sometimes a real pain in the neck to do so

Quote
Do all threads still halt on GC or has that meanwhile been fixed? I have been out of it for a good decade now, bar attending some Fosdem lectures.
Afaik there are a few mechanics in Android java that classical JVM java does not have. For one it might optimize the GC stuff completely away by detecting that an object is function local and puts it on the stack. Also the programmer can call the GC manually when the app is working anyway to not interupt the use flow. About threding, you can start a thread to be the "GC root", meaning for object created by that thread, the gc will only consider this thread (I think you can also relate other threads to it) so only that thread needs to be halted.
But take that information with caution, this is things I've learned about a few years ago, and I can of course misremeber, these information could be outdated, and I don't know which of those things are actually implemented in android and which where active research topics at the time that never made it into android. So I don't know this defenetly.

Which is exactly why I like pascal old school objects, because they live on the stack and it always feels like a complete waste of resources to create a TStringList for only one small procedure. But thats historic and we can't travel back in time and tell borland to do it any other way

I have started to  write my own records/objects for such small tasks instead of using these classes
I already try to do this, but the problem is, the whole LCL and FCL infrastructure is built around common super classes (like TStream, TStrings, whatever) so very often it is just much more convinient.

Also, I really like the managed records, but as they don't support inheritance they are also pretty limited. And for some things you need to use classes, for example thanks to this bug: https://bugs.freepascal.org/view.php?id=37164 which I encountered, using records as enumerator is completely broken as soon as managed types get into the mix (double free), but for-in is IMHO a prime case where objects are completely unecessary
Title: Re: Is Pascal the right language for me ?
Post by: marcov on August 15, 2020, 10:07:53 pm
It would be maybe, if Object Pascal strings weren't already refcounted and copy-on-write that avoids a lot of copying and recreating when passed through the call chain, and the .NET a purely GC solution without the  deduplicated immutable string table ducttaped on.
In the case of String(Lists)s sure, but for example when you use a temporary memory stream to dump a few kb into, this is pretty much uneccessary overehad.

Maybe. But it is usually easily recycled in the few cases where it matters. I work with images a lot, and I have a pooling mechanism for them based on a generic.

But those are relative "performance" applications, for most people it won't matter.

Quote
Quote
Of course it does. At a given time not all allocated memory will be referenced by the program. And not all those tiny bits can fit any size program.
Depends on what you call fragmentation, because even though this memory might not be referenced anymore, it is still allocated, so you always have a continuous block of memory. In .Net (I think this does not work in Java) you can poke the GC to clean up, and at any point in time you only have one continous block of allocated memory.

IIRC you can poke the GC, but what happens is not guaranteed. But even if it happens, this comes all with a tremendous overhead potentially touching every reference in the system and paralysing a non trivial program for seconds, so this is not an easy oven ready workaround as it must be instrumented carefully, and wrongly guessing can have dramatic results.

Quote
Quote
A tstringlist has a fixed size, since the contained strings don't add to the class size. If it is used a lot, there might be dedicated freelist for it, making it fairly cheap to recycle.

But anyway, one can discuss from a theoretic viewpoint till the cows come home, but it the end it is all about benchmarking an application that has equivalent behaviour to your application
Doesn't all classes have fixed size?

Yes. I merely stressed it to show that it only has one fixed size allocation that can be easily pooled.

Quote
That said, I've already writte n a lot of classes like Lists, Hash- and Bitsets, etc. as advanced records for temporary usage. But sadly, as advanced records do not support inheritance, it sometimes a real pain in the neck to do so

I rarely fell the need for that. I do sometimes miss simple inheritance of records for generic purposes. (e.g. Tsomething<T:tsimplerecord>  with a tmoreadvancedrecord just adding some custom fields). But that is more in Delphi, since FPC is more forgiving wrt using undeclared properties in generic code.


TinyPortal © 2005-2018