Live data from Hacker News

Why use Pascal?

castle-engine.io

91–100 of 516 posts

Re: Why use Pascal?

#91

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.

Just a few days ago I found a bug in someone's code where a variable was introduced twice with slightly different name, like "var jobno", and then "var jobn". Made me think that Pascal's approach to keep vars declarations at one place is not a bad thing. As for slowing down - probably yes, but I doubt that speedtyping is really a big virtue for a software developer. Also, in a decent IDE it should be possible to make binding/macro to insert declaration after the current function header without jumping away from the current position (though I don't know what Pascal devs use nowadays for IDE)

Re: Why use Pascal?

#92
post #58

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.

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

> but Pascal’s type system was pretty solid

To be honest, this is a matter of styles, coming from a dynamic type background I don’t appreciate strongly typed systems as an advantage.

Re: Why use Pascal?

#93
post #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.

Both made it into modernity as large swaths of Golang. Modula-2 even had coroutines.

Re: Why use Pascal?

#94
post #82

I'm using Free Pascal for my 3D game engine (recent-ish screenshot[0]). For me there is really two main simple reasons: 1. Lazarus. A game engine is -waaay- more than just a 3D engine with the tools being a very important aspect. Lazarus and LCL provide a rich and well featured WYSIWYG RAD IDE and framework for making desktop applications. As a bonus Lazarus as an IDE (even ignoring the LCL framework) is very fast. 2…

What about performance, e.g. compared with C++?

I never really had a problem with it, at least so far.

Actually a few years ago i wrote a 3D game for DOS using Free Pascal[0] (here is a review from a YouTuber[1]) and the performance was decent, though i did write the rasterizer inner loop in assembly (not that great assembly TBH but still slightly better than what FPC generated).

I did optimize it over time and expectedly, the biggest gains weren't from microptimizations but from changing how rendering works (e.g. i got a boost by adding a PVS and then another by replacing the PVS with portals since the PVS wasn't that great :-P and then yet another when i added mesh occlusion culling using data from the previous frame).

About the engine i linked at in my post, i also did a few optimizations but again they weren't microoptimizations but just algorithmic changes. I did write a profiler[2][3] a couple of years ago that helped (the video shows it in practice with the engine) but it uses some Windows-specific functionality and i've switched to Linux since then. Perf works fine under Linux with FPC, but FPWProf (my profiler) has some useful functionality and i'd like to port it to Linux at some point.

[0] https://bad-sector.itch.io/post-apocalyptic-petra

[1] https://www.youtube.com/watch?v=Lo7VlrYiTeE

[2] https://www.youtube.com/watch?v=yF0wmN9J8Ts

[3] http://runtimeterror.com/tools/fpwprof/

Re: Why use Pascal?

#96

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.

C used to be that way too, but Pascal stopped evolving when it fell out of popularity.

Re: Why use Pascal?

#97
post #87

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.

That's completely missing the point. While Pascal can be used for serious work, it is first and foremost a teaching language friendly to beginners meant for introducing people (who back in the day) likely started with something like BASIC to concepts of structured and objects oriented programming. The syntax is easy to learn, fairly clean and the language has very fast compilation (C++ really can't compete here). Whi…

Much of the original Mac was Pascal based with 68k for performance pinch points.

Of note it was faster to compile than C with MPW Shell.

Re: Why use Pascal?

#98
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

> but Pascal’s type system was pretty solid To be honest, this is a matter of styles, coming from a dynamic type background I don’t appreciate strongly typed systems as an advantage.

Strongly typed is orthogonal to dynamic and static typing. Python and Common Lisp are both "strongly" typed and dynamically typed. There's no reason to shun strong typing if you also like dynamic typing.

Re: Why use Pascal?

#99
post #66

Earlier quoted context omitted.

> 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 t…

When I had a look at the CLBG results last time the code generated by FreePascal was even about three to four times slower than C/C++; but the benchmark rules are not particularly well suited for fair comparison (some code is obviously written with inside knowledge of the particular compiler/version and not what you usually see for the given language, and the Pascal code likely includes range and overflow checks which make it slower compared to a language without these, etc.). The LLVM backend is not officially supported by FP and doesn't support all platforms as far as I know; and unfortunately micro benchmarks are usually not representative for the daily overall performance of an application; the Are-we-fast-yet benchmark suite would be better in this regard.

Anyway, I would be interested in why FP benchmarked as fast as C++ in the past, but no longer today.

Re: Why use Pascal?

#100
post #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.

I agree that triple equals is an abomination. It's one of the many things ensuring I use JavaScript as little as possible.
Post reply on HN