Live data from Hacker News

Why use Pascal?

castle-engine.io

71–80 of 516 posts

Re: Why use Pascal?

#71
post #58

Earlier quoted context omitted.

Can’t speak about Object Pascal, but the old Pascal was objectively better than C. You can like or dislike the differences in syntax, but Pascal’s type system was pretty solid which can’t be said about C

The way I remember the pascal type system is arrays of different lengths were different types.

There's more to it than that. You could (from early Pascal days) and can have arrays where the array index range is a previously defined subrange of integers, or maybe even of an enumerated type.

Then you have sets as a built-in type, which is big.

Some more.

Re: Why use Pascal?

#72

Unless you want a C++ with a different syntax and less features then there's no reason to learn Pascal in 2023. And the syntax is much worse, you can't even declare variables in the middle of a function it has to go before the function. This slows you down from real work (art code comes later). It also makes worse code as declaring near the usage point makes code more clear.

I've been playing around with Lazarus the last couple of weeks, and I can say there is at least one reason to learn pascal in 2023: it's fun!

Re: Why use Pascal?

#73
post #66

Earlier quoted context omitted.

> Fast: FPC doesn't generate particularly fast code, and the nature of OP objects doesn't help with locality. It's faster than scripting languages, but generally slower than AOT compiled languages, even those with GC. You're selling it short. Firstly, as the other poster downthread pointed out, it benchmarked as fast as C++ in the past. Secondly, it's main use is local gui apps, and there's nothing I've seen, includi…

> it benchmarked as fast as C++ in the past Does this mean it's no longer as fast as C++ today? Do you have specific benchmark results?

You can find some in Debian benchmark game. In general FPC generated code is around 1.5 to 2 times slower the fastest entry (often C++). Note though that this is with FPC's own code generator and there is a new LLVM backend in the development version (FPC's own code generator is the default and will always be, the LLVM backend is for those who really want it and is much slower).

I'd expect synthetic benchmarks like those in the Debian benchmark game to be closer to C++'s performance with the LLVM backend.

Re: Why use Pascal?

#74

Unless you want a C++ with a different syntax and less features then there's no reason to learn Pascal in 2023. And the syntax is much worse, you can't even declare variables in the middle of a function it has to go before the function. This slows you down from real work (art code comes later). It also makes worse code as declaring near the usage point makes code more clear.

Delphi/Lazarus seems like a fairly productive environment.

Also if I recall correctly some Pascal compilers (similarly to Ada) could actually generate somewhat memory safe code with array bounds checking, which is something that C/C++ usually lacks.

Re: Why use Pascal?

#75

My first languaje after BASIC was Modula2, which looks a lot like Pascal. I studied OOP, algorithms and data structures with Pascal in college, so it's a languaje for which I have great memeories. Nice to see it's still around.

Modula-2 is a much better language than original Pascal, but if you want OO features Oberon-2 is the corresponding Wirth language.

Re: Why use Pascal?

#76

Does Pascal still require all variables to be declared at the top? I did a quick search and that seems like the case, but I want confirmation from someone that knows the language. If so, that's a immediate "no" for me. We know by now that keeping variable declarations close to their usage is a big boost in readability, and at times even in performance (you only declare variables you actually use). I know Pascal has e…

Delphi allows inline variable declaration but Free Pascal does not (the developers explicitly decided against implementing it). Note that in Pascal (FPC, Delphi, whatever) you can have nested functions so this isn't that much of a limitation as it sounds. For example if i have a procedure that is very long i often end up splitting it in multiple nested procedures and each one has its own variable section. Also from a…

> Delphi allows inline variable declaration

it may do so now, but for the longest time it didn't, which made it compare poorly with C++ and even with C, which allows definitions in a scope. in fact the OP concept of scope is a bit crap - basically the whole function,

Re: Why use Pascal?

#77
> Why use Pascal?

Because you like Niklaus Wirth's languages, and only those ... but only up to Pascal.

You don't think that the improvements in his subsequent Pascal-like languages are Wirth a damn.

You believe that Wirth went soft in the 1970's and 1980's, and sold out Pascal.

If that is you, you probably write code in Pascal, implement Pascal, write about Pascal ...

(Everyone else should probably skip Pascal and take a look at Modula-2 and Oberon.)

Re: Why use Pascal?

#78

Does Pascal still require all variables to be declared at the top? I did a quick search and that seems like the case, but I want confirmation from someone that knows the language. If so, that's a immediate "no" for me. We know by now that keeping variable declarations close to their usage is a big boost in readability, and at times even in performance (you only declare variables you actually use). I know Pascal has e…

Seems a bit shallow. JavaScript equals is an abomination, which to me seems like a larger issue, and people use it just fine.

Re: Why use Pascal?

#79

Unless you want a C++ with a different syntax and less features then there's no reason to learn Pascal in 2023. And the syntax is much worse, you can't even declare variables in the middle of a function it has to go before the function. This slows you down from real work (art code comes later). It also makes worse code as declaring near the usage point makes code more clear.

> you can't even declare variables in the middle of a function

losing time with "static declaration follows non static" in C programs doesn't help either.

Re: Why use Pascal?

#80

Unless you want a C++ with a different syntax and less features then there's no reason to learn Pascal in 2023. And the syntax is much worse, you can't even declare variables in the middle of a function it has to go before the function. This slows you down from real work (art code comes later). It also makes worse code as declaring near the usage point makes code more clear.

I never understood why is declaring variables in the middle of the code a "pro" for some. In my experience that's a "con" especially because of maintainability. Same way you do a comment before declaring a function to explain its purpose, you do a comment for each variable to declare its goal within said function. That's proper maintainability for a project.

Also Delphi, for past 2 years, has this "middle" variable declaration style, and I hate it, never used it. So your comment missed the mark. If you want to advocate "don't learn Pascal in 2023" please do more research and come up with better argument.

Post reply on HN