4 ms·
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.
by troupo 3y ago
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 dumbed down version of it
etc. etc.
Pascal is the way Pascal is because Wirth wanted the simplest possible language according to Wirth's own criteria that could be compiled in a single pass on a 1980s computer.
It's the go [1] of its time.
That is it. Both the syntax and Pascal's concept are severely outdated. It's a very good thing that modern languages never adopted Pascal's syntax and went for something that is actually usable. Hell, Erlang is a more mathematical and timeless syntax than Pascal, and it's a trivial langauge at it's core.
[1] Can't find the actual text now, but there was a rationale by Rob Pike that go was amed at junior engineers, and needed to be simple.
- weinzierl 3y ago"- 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 = anymore because you already used it for something else. "- there are no procedures in maths, everything is a function" Exactly and that's why functions and procedures in Pascal are separate things, like it is meant to be. Functions have an equivalent in math, procedures don't. Mixing the two concepts up into the weird thing C calls a function is just wrong. "- functions cannot be nested in maths (unless I'm mistaken)" In some sense they can. In C they can't because of technical restrictions, no one ever was fond of that restriction, not even back in the day. "- types is maths, but Pascal uses a very narrowed down and dumbed down version of it" Pascal is a programming language, not 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. It has some consistency and elegance and certainly flaws as well. C's syntax decisions were more driven by long gone technical restrictions than what makes sense to a human. Now we have to live with that baggage.
- troupo 3y agoEdit: In his Pascal report Wirth mentions math zero times: http://pascal.hansotten.com/uploads/books/Pascal_User_Manual_and_Report_Fourth_Edition.pdf 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_language_pascal.pdf 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_symbols https://en.wikipedia.org/wiki/Glossary_of_mathematical_symbo... [2] https://math.stackexchange.com/questions/1289339/what-is-meant-by-the-delta-equivalent-sign https://math.stackexchange.com/questions/1289339/what-is-mea...