Live data from Hacker News

Why use Pascal?

castle-engine.io

121–130 of 516 posts

Re: Why use Pascal?

#121

I'm finding myself using Pascal for fun these days due to resource constraints. The old release of Borland's Turbo Pascal, version 3.00A, runs under CP/M and provides an editor, compiler, and libraries all under 64k. It's fast enough to use interactively, and produces code that is good-enough to implement low-level utilities, simple games, and other random hacks. I've not used Pascal on anything larger, or more moder…

Oh Pascal!, oh the nostalgia. I saved up the princely sum of $80-$100 back in TRS-80 Model III days to buy the Pascal 80 package, the New Classics version, which was basically a proto-IDE, and a pretty sweet one at the time. http://www.trs-80.org/pascal-80/ I recall it being a huge step up from the M-III BASIC dev environment and the games and utilities I wrote ran well enough in the 48K of RAM that was available. I wonder what became of the Pascal-80 codebase? Not that it would be any better than the modern tools available for retro hardware, probably far worse. Oh yeah, "Oh Pascal!" was the book from which I learned the language, and I doubt there were many other options, as this predated Pascal's commercial use by quite a few years.

Re: Why use Pascal?

#123

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.

> Unless you want a C++ with a different syntax and less features then there's no reason to learn Pascal in 2023.

For me, personally, there there is a good reason to learn Pascal in 2023; the quick and almost painless ability to produce fast GUI applications.

The alternatives are not nearly as polished or as nice.

Re: Why use Pascal?

#124

Earlier quoted context omitted.

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.

I would be curious to see references that claims that dynamic and static typing are orthogonal with strongly typed systems, as “strongly type” is rather ambiguous and the only reason I used the term was because that was how Pascal was promoted back in the day (or at least how was taught to me) From Wikipedia: In 1974, Liskov and S. Zilles defined a strongly-typed language as one in which "whenever an object is passed…

You already found the wikipedia page, try reading it. See where it puts a lot of dynamically typed languages under the category of "strongly typed". You've decided it's a good enough source apparently.

But really, I used "strongly" in quotes deliberately. It's a terrible phrase since it means nothing in practice because it can mean too many things (as that same page notes) that often are at odds with each other.

> Note that the definition refers to type declaration, both being optional in Python and Common Lisp, so I wouldn’t use either as an example of strongly type languages.

Even this definition would potentially exclude SML and OCaml where types are inferred, not declared. So according to you those two languages are weakly typed? I think a lot of people would be surprised to learn that.

Re: Why use Pascal?

#125

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

defining all variables as near to their point of use as possible is a pretty obviously good thing, for readability if nothing else.

Re: Why use Pascal?

#126

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

Does Ada support Android and iOS targets yet? Last I checked there didn't seem to be any obvious way to build for NDK.

Re: Why use Pascal?

#127
post #87

Earlier quoted context omitted.

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 was teaching programming with Pascal until three years ago, and I think the pedagogical argument might have made sense in the past, but not in 2023 (or 10 years ago for that matter). The syntax is rigid in all the wrong places. For example, not being able to declare variables anywhere doesn't really help students, this isn't something that typically leads them to errors. What does lead to lots of errors? Dereferenc…

>For example, not being able to declare variables anywhere doesn't really help students, this

Disagree. Creating variables in the middle is the reason why beginners create spaghetti code and mix up control flow. This is the reason for dangling pointers, memory leaks, and de-referencing pointers in wrong places.

If student needs to declare variable in the middle of method, this is a good sign to split the method or rethink control flow.

What really I learned from Pascal is managing clean control flow, and var section in the beginning forces you to think in advance what you are going to need in this particular method vs what needs to be done in a separate function.

Re: Why use Pascal?

#128
Pascal is actually good and perfomant. It was the second language I picked up in high school after Basic.

I don’t understand why as an industry we had to regress to Python, Ruby, Java, & Javascript in late 90s & early 2000.

Re: Why use Pascal?

#129
post #35

Earlier quoted context omitted.

It's only "mathematical" if you chose very specific parts of the language from a very specific version of Pascal when looked at at a very specific angle. E.g. the argument falls apart immedately: - there's no assignment operator in maths - there are no procedures in maths, everything is a function - functions cannot be nested in maths (unless I'm mistaken) - types is maths, but Pascal uses a very narrowed down and du…

"- there's no assignment operator in maths" There is no assignment but in math we use := to express that two things are equal per definition . I never said it was the same thing, just that it is the closest thing. From a math perspective it makes total sense, while singular = for assignment makes no sense at all. Especially when you want express the concept of equality as well and cannot use the obvious choice = anym…

Edit: In his Pascal report Wirth mentions math zero times: http://pascal.hansotten.com/uploads/books/Pascal_User_Manual...

And in fact in 1971 he wrote that it was basically copied from ALGOL: https://oberoncore.ru/_media/library/wirth_the_programming_l...

Edit2: Most relevant part from second link: "The syntax has been devised so that Pascal texts can be scanned by the simplest techniques of syntactic analysis". That's it.

On to other comments which are basically relevant given Wirth's own words:

> but in math we use := to express that two things are equal per definition.

Then it isn't variable assignment. It's what you pretend it is because Pascal defined variable assignment this way, and now you're trying find an angle for which "Pascal is closer to math" works.

When we write "x = f(y)" or "x = y + z where z = f(t)" in maths there's no confusion as to what this expresses. No need for "equal by definition".

Note: Interestingly enough, Wikipedia doesn't list `:=` in its glossary of mathematical symbols [1] And then there's another sign used for definitions: equality sign with delta [2]

> Especially when you want express the concept of equality as well and cannot use the obvious choice = anymore because you already used it for something else.

Math also has the same problem, because equalities are not equal :)

Hence you have:

- equal

- equal by definition

- ~ has six different definitions depending on context

- ≡ has two different definitions

etc.

> Exactly and that's why functions and procedures in Pascal are separate things, like it is meant to be.

It's not "meant to be". Programming languages are not math. The distinction between functions and procedures in Pascal exists only because Wirth decided that's how it should be.

> In some sense they can.

It means that it makes no sense to pretend that nesting functions in Pascal has anything to do with math.

> Pascal is a programming language, not math.

Precisely. And yet, just two paragraphs above you argue for a distinction between functions and procedures because math ;)

> My point is solely that Pascals syntax is superior to C's because (among other reasons) the former is closer to centuries old tried and tested and well established syntax of mathematical notation.

Modern math notation didn't become "old tried and tested" until somethig like 19th century, and even now it still remains somewhat fluid. And it's only closer if you arbitrarily twist definitions and meanings like "equal by definition" is surely "variable assignment". As I said in the very first line of my original comment: "It's only 'mathematical' if you chose very specific parts of the language from a very specific version of Pascal when looked at at a very specific angle."

It's also "better than C" only for some vague defintion of "better" where "is closer to math" has no relation to either reality or to being better.

[1] https://en.wikipedia.org/wiki/Glossary_of_mathematical_symbo...

[2] https://math.stackexchange.com/questions/1289339/what-is-mea...

Re: Why use Pascal?

#130

Earlier quoted context omitted.

> 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.

how can Python be strongly typed if it doesn't enforce types for declared arguments?

What is the value of this supposedly "strongly typed" Python's type system?

class Object:

    pass
def f(arg:int):

    print("type of arg = ", str(type(arg)))
f(1)

f(666.0)

f("kek")

f(Object())

type of arg =

type of arg =

type of arg =

type of arg =

and not a single error/warning thrown

Post reply on HN