4 ms·
"- 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 w
by 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...
- AnimalMuppet 3y agoYeah. weinzierl has his/her syntax preference, and that's fine. As the ancients said, "There's no disputing about tastes." But the attempt to provide a rationalization for why the taste is correct is complete nonsense.
- weinzierl 3y agoIt's not about taste, really. We all learn mathematical notation in primary school. It is an universal language. Programming languages support many concepts that are either the same in math or very similar. Using the symbols for the same concepts in both worlds is the obvious and sensible choice. The reason why C did choose a different convention was that it preferred similarity with FORTRAN which is so old that it was punched on cards that did simply not have a : character. Now it is 2023 and I argue that we should use the same symbols in programming that children are taught in primary school instead of ones that were chosen merely because more than 70 years ago the proper characters were not yet available.
- AnimalMuppet 3y ago> Using the symbols for the same concepts in both worlds is the obvious and sensible choice. Yeah, but has already been established in this conversation, you're not using them for the same concepts. So your argument doesn't work. Repeating it over and over isn't going to make it work, either. > The reason why C did choose a different convention was that it preferred similarity with FORTRAN which is so old that it was punched on cards that did simply not have a : character. I'd be interested in seeing your evidence for this assertion that you make so confidently. From my understanding, the logic was this: Assignment happens twice as often as comparison, so assignment gets the shorter symbol. Perfectly reasonable from an information-theory point of view. And, C didn't avoid := because the proper character wasn't available. They used : in the ternary operator, so they clearly expected it to be available. So all in all, your data is suspect, and doesn't support your argument.
- weinzierl 3y ago