5 ms·
What other kind of syntax is there? But yes, I've seen a lot of procedural code in every paradigm I can think of. Lots of cargo-cult programming results in it.
by betenoire 11y ago
What other kind of syntax is there? But yes, I've seen a lot of procedural code in every paradigm I can think of. Lots of cargo-cult programming results in it.
- jonathankoren 11y agoSit down dear child and hear of languages long ago... Back I. The days of vacuum tube and electromechanical switches, when punch tape rules the world p, there were two languages: The Algorithmic Language, and the List Processor. The List Process, or LISP, to its friends was built around s-expressions. The other, also known as ALGOL, was built around a strange and unholy hybrid of text and formulae that only an insane mathematician would love, for almost every statement was a special case. ALGOL syntax went on to rule the world. Seriously kid. There are only two syntaxes, and procedural, structural, object oriented, aspect, imperative, and all the rest are immaterial to the syntax, for they refer to how programs are organized, not what keys you press on the keyboard. Don't they teach programming languages anymore?
- catnaroek 11y agoHave you heard of Prolog? (Just to mention a single language whose syntax doesn't fall in either category you mentioned. Not that there aren't others.) Also, as someone who studies mathematics for fun, I disagree with your statement that a mathematician would love a system with lots of special cases. If anything, mathematicians are willing to pay a higher abstraction tax than most other people, just to unify special cases.
- groovy2shoes 11y agoI've noticed that the kinds of things a mathematician might pride an elegant proof over are the same kinds of things a programmer might recognize as elegance in code as well. I think the Curry-Howard Correspondence is actually an intuitive result rather than a surprising one, and that any experienced programmer who understands formal proofs as well as they understand computer programming would eventually arrive at the Correspondence on their own, or at least a suspicion of it.
- betenoire 11y agothanks dad. by the way, you are wrong, but you probably knew that already You've grossly oversimplified everything so nothing has useful meaning anymore.
- groovy2shoes 11y agoAbstract syntax.
- betenoire 11y ago...trees? Fair point, but we don't program with abstract syntax trees, unless we are talking about genetic programming.
- catnaroek 11y agoTell that to a compiler writer.
- betenoire 11y agocompiler writers write compilers in programming languages, not in syntax trees. Lisp is arguably the only language you write your code in "trees", but even then, it's still all lexical. A syntax tree is not syntax, it's a tree.
- catnaroek 11y ago> it's still all lexical. I have no idea what you mean. Are you talking about lexical scope? If anything, determining the lexical scope of a variable is much easier from a syntax tree than from the original program text. > A syntax tree is not syntax, it's a tree. Pretty much all the literature on programming languages identifies “syntax” with “abstract syntax (tree)”. It is typically understood that textual concrete syntax exists primarily as a convenience for the programmer, because it's easier to edit, but the very first thing a compiler does is recover the abstract syntax tree, and from then onwards proceed as if the concrete syntax had never existed (except perhaps for error reporting purposes).
- betenoire 11y agoLexical means "as it appears 'written' on the 'page' of code". So lexical scope allows you to look and see what the binding is. Contrasted to dynamic scope where you must run the program to find the binding. If you will, syntax is the vocabulary of the language. Also called "lexicon" and the syntactical tokens are sometimes called "lexemes". It's all about the text. Syntax is text. Or more technically, syntax is the format of the input. Syntax trees are data structures that represent syntax, but they are not syntax. There are different types of syntax trees, too. The trees are built by the compiler, and never written by hand unless for exercise. Syntax trees have already passed semantic analysis and contain context. They are much more than just syntax.
- catnaroek 11y agoNot that procedural programming is intrinsically a bad thing. Hierarchically decomposing tasks into simpler ones is a time-honored approach to dealing with complexity because it works. It's not “cargo-cult”.
- betenoire 11y agothat's not what procedural programming is, it has nothing to do with decomposing tasks. it has to do with a procedural style of telling the computer what to do. note that I didn't say procedural programming is cargo cult, I said cargo cult programming often results in procedural style programs
- catnaroek 11y agoWikipedia disagrees with you: > “Procedural programming is a programming paradigm, derived from structured programming, based upon the concept of the procedure call. Procedures, also known as routines, subroutines [emphasis mine], or functions (...)” [https://en.wikipedia.org/wiki/Procedural_programming https://en.wikipedia.org/wiki/Procedural_programming] Procedural programming is all about decomposing programs (descriptions of tasks) into subroutines (descriptions of subtasks). Maybe you were thinking about imperative programming instead? Procedural programs are certainly imperative, but not all imperative programs are procedural.
- betenoire 11y agoyes you are right, that's what I meant. Sorry