Live data from Hacker News

Why use Pascal?

castle-engine.io

241–250 of 516 posts

Re: Why use Pascal?

#241
post #164
post #61

I won't even bother clicking this click bait title. I learned Pascal as a sophomore in high school and by my senior year I knew I'd never touch it again. At the time it was a great introductory language but there's very little reason anyone should even be thinking about Pascal these days. Fun fact: I still have my old pascal files on floppy disks in a box somewhere with a not so thin layer of dust on them.

I still think it is brutal we let our industry rookies learn complicated programming concepts in complicated languages like Java, python, js or god forbid anything functional. I still think it is a huge mistake be Microsoft to let Basic rot away and that our industry should focus teaching on something like Pascal which does not stand in your way

Visual Basic 6 remains unmatched in how to deal with COM.

It is incredible given how much WinDev doubles down on COM, that they keep failing on producing any kind of tooling that is as productive as the VB 6 experiece used to be.

Re: Why use Pascal?

#242
post #84
post #12

Earlier quoted context omitted.

> On the other hand, the ecosystem is great. Hard disagree. I worked with Pascal for about 10 years, and the lack of modern libraries was a source of frequent frustration, meaning we often had to develop the solutions ourselves, or abandon an idea entirely.

May we please have a few examples of what's missing?

The situation may obviously have changed today, it's been a few years since I last worked with Pascal. Back around 2016, we were looking for a different way of communicating between our services (you could kind of see them as micro-services, but I would not describe them as "micro"), which until then had relied on our own communication implementation on top of Windows socket. Our implementation was OK, but could not communicate beyond a single Windows machine, and it definitely did not allow multiple instances of the same services. We wanted to scale up, so we started looking into new technologies.

Our lead developer was interested in building a RabbitMQ prototype. There were two libraries around to find, but none of them were finished, so we spent a lot of time finishing one of those implementations. We also looked into ProtoBuf, but that was a steeper hill to climb. When I left in early 2019, we were still using the old WinSock communication, though I understand from former co-workers, that they've switch to an UDP-based system instead now.

That's the most vivid one I can remember, because we pushed on, despite the available libraries being weak. I also remember trying MongoDB, which required a lot of polishing the available libraries as well. Other ideas I remember pursuing briefly, until I recognised finished some of the libraries would be too tall an order.

For the record, I don't have a problem with Pascal in general, nor its community. But considering how trivial it is to find a solid robust library for modern technologies (even if kind of fads) for other popular languages, compared to Pascal, it definitely feels weird to call its ecosystem "great".

Of course, the libraries I've mentioned may be great today. But RabbitMQ and MongoDB are also a bit older technologies today.

Re: Why use Pascal?

#243

Earlier quoted context omitted.

The syntax is timeless, because it is much closer to math than B/BCPL/C heritage. It has its own issues but overall it is much better thought out than most other languages. Here is a comment I wrote a couple of months ago with more arguments for Pascal's syntax: "Yes, Rust does indeed and a long time before that it was Pascal. I really love Pascal's syntax, it makes a lot of sense when you approach it with a math bac…

> Range Types! Love'em! You need a number between 0 and 360? You can easily express that in Pascal's type system. I did not know those existed that early. > Array indexing is your choice. Start at 0? Start at 1? Start at 100? It's up to you. Reminds me again of GNU Guile's arrays, which also allow you to specify what index an array starts with. Very flexible.

> Reminds me again of GNU Guile's arrays, which also allow you to specify what index an array starts with. Very flexible.

Reminds me of the "OPTION BASE" statement in BASIC. Found in Microsoft BASICs all the way from GW-BASIC (and probably even earlier than that) through to classic Visual Basic, VBA and VBScript (but not VB.NET). Not sure when it originated, possibly it goes all the way back to some version of the original Dartmouth BASIC (they changed the array base at some point from 1 to 0, so "OPTION BASE" enabled backward compatibility). Also found in some non-Microsoft BASICs, e.g. IBM System/34 BASIC. ANSI Full BASIC (did anyone ever implement it?) supported arbitrary array bases, not just 0 or 1, e.g. "DIM A(100 TO 200)"

Re: Why use Pascal?

#244

Earlier quoted context omitted.

One of my primary languages is C89 and don't find it an impediment. It's been over 2 decades since I last touched Pascal so I'm not sure how it works there, but in C you can always open a new inner scope with { and declare more variables there. and at times even in performance (you only declare variables you actually use). All but the stupidest compiler (which usually means no optimisation at all, not even precomputi…

> All but the stupidest compiler (which usually means no optimisation at all, not even precomputing constants) will not be affected by completely extraneous variables. The statement is certainly false in this general form, even with full link-time optimizations. If the type has a constructor with side effects external to the program (e.g. it makes syscalls), the compiler cannot remove the variable.

If they cause visible side-effects, they are by definition not extraneous.

Re: Why use Pascal?

#245

Earlier quoted context omitted.

I’ve written a few compilers in my time so I have some idea about scoping rules ;) As I and other have already said, it depends on the specific language. Some languages scope local variables at the function level (irrespective of {} or Begin End), and other languages scope local variables inside the containing {} or Begin and End block. In that regard {} and Begin End serve identical purposes of defining a local exec…

this post is specifically about pascal - my comment about {} vs begin...end was intended for that context. pascal has no way of defining variables within a local scope - it was added to delphi as a kludge much later. i admit i should have said something like "... {} in C and C++".

> this post is specifically about pascal - my comment about {} vs begin...end was intended for that context

That link was Pascal. It was just one of many dialects of Pascal.

> pascal has no way of defining variables within a local scope

I just did a quick search and turns out Pascal does support nesting variable scopes too.

> it was added to delphi as a kludge much later

Is it a kludge though? Or are you just calling it that because it disproves your point? The syntax is pretty similar to a lot of C-like languages. So you’d be calling their variable declarations a kludge too.

It feels like you’re being overly dismissive.

> i admit i should have said something like "... {} in C and C++".

it certainly would have helped your case to have opened with a little more context rather than assuming other people don’t understand how scoping works ;)

But even that aside, Pascal does support scoping inside compound statements.

Begin End and {} are just tokens to denote the start and end of a compound statement. Just like how Python uses indentation to group compounds.

Everything else you put is missing the point about how language grammar is parsed.

Re: Why use Pascal?

#246
post #138

Earlier quoted context omitted.

> I'm still trying to find information about the specific optimizations done in the current FP compiler. AFAIK there isn't any explicit documentation but the "toptimizerswitch" and "twpoptimizerswitch" (the latter is for whole program optimizations) types in the compiler define the available optimizations in globtype.pas and have the following values: cs_opt_level1,cs_opt_level2,cs_opt_level3,cs_opt_level4, cs_opt_re…

Thanks for the hints. I was already concerned that I would have to analyze the source code directly myself, and so I started to build tools for this purpose ( https://github.com/rochus-keller/FreePascal ). I read somewhere that there are issues with higher optimization levels. Can you confirm that?

> Thanks for the hints. I was already concerned that I would have to analyze the source code directly myself, and so I started to build tools for this purpose (https://github.com/rochus-keller/FreePascal).

FWIW you may want to check out the fcl-passrc package[0] which provides units for scanning and creating a syntax tree from FPC source code, including some helpers like resolving references.

It is used by the fpdoc documentation generator and the pas2js transpiler that converts Free Pascal source code to JavaScript, both official FPC projects. fcl-passrc is itself part of Free Pascal.

> I read somewhere that there are issues with higher optimization levels. Can you confirm that?

AFAIK the main issue is that -O4 enables some optimizations that may break code that relies on things like having the exact same math output as non-optimized versions as it enables FASTMATH, code that relies on classes having specific field order (technically class field order is not guaranteed to remain the same) since -O4 enables reordering the fields to remove unnecessary padding and code that depends on runtime errors or exceptions being thrown from code that the compiler (in -O4) decided it has not explicit side effects and removed it.

These are not "issues" per-se but Lazarus labels -O4 as having "aggressive optimizations, beware" which might give a false impression.

Aside from that there might be bugs, but that is the case with any compiler.

[0] https://wiki.freepascal.org/fcl-passrc

Re: Why use Pascal?

#247
post #138

Earlier quoted context omitted.

Thanks for the hints. I was already concerned that I would have to analyze the source code directly myself, and so I started to build tools for this purpose ( https://github.com/rochus-keller/FreePascal ). I read somewhere that there are issues with higher optimization levels. Can you confirm that?

> Thanks for the hints. I was already concerned that I would have to analyze the source code directly myself, and so I started to build tools for this purpose ( https://github.com/rochus-keller/FreePascal ). FWIW you may want to check out the fcl-passrc package[0] which provides units for scanning and creating a syntax tree from FPC source code, including some helpers like resolving references. It is used by the fpdo…

Thanks again for the hints; I'm not (yet) fluent with FreePascal and assumed to be much faster when quickly implementing a rudimentary parser to make arbitrary queries over the source code (the one I implemented for Lisa Pascal/Clascal including the browser/cross-referencer took a week as a side project) than discovering and learning all the required FP libraries and tools; but the FP language turned out to have some pretty dark corners which are much harder to parse than I expected from a Pascal descendant.

Re: Why use Pascal?

#248

Earlier quoted context omitted.

you are probably talking about C++ vs pascal. But you should be talking C.

no, c and c++ have basically similar rules for the scope of variables, with the regard to braces

I don't think you know much about pascal, C or C++

Re: Why use Pascal?

#249
post #247

Earlier quoted context omitted.

> Thanks for the hints. I was already concerned that I would have to analyze the source code directly myself, and so I started to build tools for this purpose ( https://github.com/rochus-keller/FreePascal ). FWIW you may want to check out the fcl-passrc package[0] which provides units for scanning and creating a syntax tree from FPC source code, including some helpers like resolving references. It is used by the fpdo…

Thanks again for the hints; I'm not (yet) fluent with FreePascal and assumed to be much faster when quickly implementing a rudimentary parser to make arbitrary queries over the source code (the one I implemented for Lisa Pascal/Clascal including the browser/cross-referencer took a week as a side project) than discovering and learning all the required FP libraries and tools; but the FP language turned out to have some…

Yeah, Free Pascal is far from simple. It not only tries to implement everything Delphi provides (itself never being a "simple" language) but also as much as other Pascal dialects provide (via compiler modes) and various useful features from other languages - and that in backwards compatible ways (often via "modeswitches" - kinda like submodes).

With that in mind it is kinda interesting that there are (AFAIK) three parsers for it anyway: FPC itself, lcl-passrc and Lazarus' CodeTools. It does mean that any new stuff in the language gets some time to be implemented in others though.

Re: Why use Pascal?

#250
post #221

Earlier quoted context omitted.

> free widgets Are you saying there are paid widgets? I use Qt5, which comes with more widgets than I know what to do with. Are the ones that come with Lazarus limited? Last time I tried Lazarus (and Delphi), Unicode was difficult. Everything seemed to assume ASCII.

Unicode was fixed in 2007 (or thereabouts). I think thats a problem with Delphi (and Lazarus) everyone compares it to when they used Delphi (in 1999) it didn't do this cool thing that languages in 2023 do, however modern day Delphi does a lot more stuff. It's worth a revisit, I use it with the skia graphics engine to create multi platform apps very easily.

I had to use Delphi professionally in 2018, still ran into this everywhere?
Post reply on HN