Live data from Hacker News

Why use Pascal?

castle-engine.io

101–110 of 516 posts

Re: Why use Pascal?

#101

Earlier quoted context omitted.

> numeric data types are 'integer' and 'real', no single/double nonsense Actually in Free Pascal (and AFAIK Delphi) there are Single and Double (and Extended) that map to 32bit and 64bit floats (Extended depends on the target CPU, e.g. for 32bit x86 is 80bit floats but for 64bit x86 is 64bit floats) since you actually do need to differentiate between the two in practice. > 'functions' are for returning values, 'proce…

When it comes to real vs float I should not have called the later nonsense. I agree that both have their place depending whether you want to express things at a lower (closer to hardware or wire protocol) level or more abstractly. It is still sad that languages like C (and even Rust) only offer the lower level types. What you said about functions and procedures is also true. I still think that it is valuable to have…

> Maybe one day we will have a Pascal compiler that can enforce that functions are side-effect free...

Pure functions are actually one of the WIP functionality in Free Pascal :-). AFAIK the ultimate goal is to have the compiler evaluate them at compile time where possible.

Re: Why use Pascal?

#102

first word they use to justify using Pascal is that it's "modern". Gave a glimpse at the code source screenshot. No, that syntax is very much the past.

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.

Re: Why use Pascal?

#103
post #18

Earlier quoted context omitted.

the greatest difference btw Pascal and C++ is developer experience. Pascal uses a single-pass LL(1) compiler, which allows you to compile in milliseconds. Pascal enables REPL-like experience where you can Edit->Compile->Run in less than a second. C/C++ with macros and slower compilation times is worse developer experience, at least it was the reason for me to learn Pascal instead of C and Delphi instead of C++

Just to add more context: Niklaus Wirth's foresight was to design Pascal's syntax to allow a single-pass compile. But it took more than 15 years until we actually had a blazingly fast single-pass compiler and that is totally Anders Hejlsberg's merit.

Every so often a thread pops up about Turbo Pascal and I'm astonished as to how nice an IDE you could fit onto a 64K CP/M system. (See also comments above/below.)

Re: Why use Pascal?

#104
post #41
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.

Yep. Unless it's part of a legacy project, or I'm developing something as a fun experiment, I have no interest in languages that lack modern, robust, stable, up-to-date libraries.

> I have no interest in languages that lack modern, robust, stable, up-to-date libraries.

I guess JavaScript is out then. ;-)

Re: Why use Pascal?

#105
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…

I seem to recall Golang being inspired by it too, but I could be misremembering.

Re: Why use Pascal?

#106
post #93
post #75

Earlier quoted context omitted.

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.

Go has surprisingly little in common with Oberon or Modula (mostly the receiver syntax of Oberon-2 bound procedures). The coroutines were not a language feature of Modula, but a library feature; also the Oakwood guidelines of Oberon (not by the original authors) include a coroutine API, but I'm not sure whether there was a working implementation.

Re: Why use Pascal?

#107
post #99

Earlier quoted context omitted.

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

> The LLVM backend is not officially supported by FP

It used to be a separate project but these days is part of the main development branch. Though indeed the OS and CPU support is very limited.

Also i agree about the micro benchmark comparison, they tend to exaggerate differences. FWIW in my own programs i never found Free Pascal's code generator to be inadequate.

I do not remember the exact difference but last year i did compile my 3D game engine with the LLVM backend and the difference was small enough for me to decide that i don't want to bother with the much slower compile times.

Re: Why use Pascal?

#108

Often overlooked, the Ada embedded ecosystem has advantages of maturity in static analysis, debugging, and target support.

I always thought that Ada was underrated. Personally I appreciate features like memory safety, a standard concurrency model, support for unit/measurement types, and ahead-of-time compilation.

Ada's Pascal-like syntax seems verbose to me but isn't hard to read. And VHDL is based on Ada syntax, perhaps making it easier for people who are working in both languages.

Swift seems to check some of those boxes (and adds many other convenient features including closures, automatic reference counting, type inference, etc.) I don't know about measurement types, but it seems they should be doable. There doesn't seem to be a Swift-like HDL yet though.

Re: Why use Pascal?

#109

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

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

I did check out Oberon-07 because of its minimalism but i really couldn't get over the SHOUTY keywords :-P.

(Wirth used uppercase for Pascal's keywords too but unlike Oberon, Pascal is not case sensitive - my pet theory is that Oberon is case sensitive as a reaction to Pascal programmers not using shouty capitalization :-P)

Re: Why use Pascal?

#110
post #68
post #18

Earlier quoted context omitted.

the greatest difference btw Pascal and C++ is developer experience. Pascal uses a single-pass LL(1) compiler, which allows you to compile in milliseconds. Pascal enables REPL-like experience where you can Edit->Compile->Run in less than a second. C/C++ with macros and slower compilation times is worse developer experience, at least it was the reason for me to learn Pascal instead of C and Delphi instead of C++

> Pascal uses a single-pass LL(1) No longer the case with the Pascal version used by the game engine.

which Pascal compiler is it - Embarcadero or FPC?
Post reply on HN