4 ms·
I think it's worth bringing Perl into this discussion, as a language designed by linguists to to make it easier to express yourself in ways similar to how you t
by kbenson 13y ago
I think it's worth bringing Perl into this discussion, as a language designed by linguists to to make it easier to express yourself in ways similar to how you think. Thinking about this, it puts the following statement into new light:
Natural languages are exclusively used to talk to people, while programming languages are also used to talk to machines.
We also use programming languages to communicate to other programmers (which includes our future selves). Making clear delineations as above can serve to help define a problem, or arbitrarily reduce your options without cause. I think this is the latter.
Perl has many, many nuances. This is often derided by people that prefer more rigid languages. I like to think that it helps me see the programmer intent and thought process more clearly through the code.
Obviously there are downsides to this, just as there are downsides to overly rigid languages. Again, differentiating them based on what we assume they will excel at early may not be beneficial for us. People that move freely between different language dichotomies seem to have success in choosing the right tool for the job, whether that be algorithm, language or platform.
- cynicalkane 13y agoThe nuances of a given spoken language take years to master even with regular use. They are used for brevity, cultural identification, conveying meanings that are often different from the dictionary definitions, many other things that programmers don't need to do. Much lawyer and engineering jargon is motivated behind removing these nuances. You don't need nuances for a language to be expressive. Haskell is a formally rigid language that can express many things in a billion ways. Python is a simple language that accomplishes the same effect. Clojure has almost no syntax but is more expressive than almost any language I've seen. I don't want nuance in my programming languages. Nuance is how you get write-once source files and migrane-inducing bugs.
- chromatic 13y agoI don't want nuance in my programming languages. Does your programming language distinguish between period, semicolon, and colon? Are = and == separate operators? Is whitespace sometimes insignificant and other times significant?
- andrewflnr 13y agoDistinguishing lexical tokens is a red herring. Nuance has more to do with giving multiple meanings to tokens, depending on context, like maybe if the colon also worked as a statement terminator, but with slightly different semantics.
- Mithaldu 13y agoSo, you're saying: > Is whitespace sometimes insignificant and other times significant? (Yes, there are languages where whitespace is ALWAYS insiginificant. Well, that is unless you tell the parser to treat it as significant. Or a construct in the parser temporarily enables significance of whitespace.)
- pessimizer 13y agoDistinctness isn't a synonym for nuance. All programming languages that I'm aware of also distinguish between "toast" and "taste", or "4567" and "4587."
- chromatic 13y agoMaybe so, but some programming languages have case insensitive keywords or identifiers, or take into account only the first several letters of a keyword or identifier. Distinctness is nuanced too.
- rtpg 13y agoAs someone who has a passing knowledge of perl, what do you mean by nuances? It always seemed that perl the language is pretty minimal.
- stcredzero 13y agoNo. Perl has a lot of syntax. There is a lot of language containing a lot of nuance. Python is an example of a language with moderate syntax, probably several times smaller than Perl 5's, assuming Perl is about the same size as Ruby, which is a good assumption, given that they both depend on complex interactions between lexer, parser, and runtime to fully parse. Smalltalk is several times smaller than Python, and actual Lisp implementations have syntaxes that are 1/3rd to 1/2 the size of Smalltalk's. The above is all objective. You can reduce a language to a formal grammar and count the number of terminals and nonterminals in that grammar.
- jleader 13y agoNot all linguistic nuance is syntactic. For example, the semantics of object models can contain a lot of nuances, as can the lifetimes of variables, visibility of identifiers, etc. While there are ways of encoding semantics (denotational, axiomatic, etc.), the size of the encoding will depend a lot on how closely the language's semantics resemble the semantics of the encoding you choose.
- stcredzero 13y agoOkay, then. Single letters in regular expression statements.
- Mithaldu 13y agoAn interesting nuance, which many early Perl teaching books up until Modern Perl [1] failed to address properly is "context". Perl allows both single and multi-value function return. In return the function can ask whether the calling statement expects a single or multiple values. Additionally, this request for expectation propagates through the call stack from the first statement where this can be correctly determined, to the place where the question was asked. This makes it possible to do things like this: my $first = max( 1, 2, 3, 4, 5 ); my ( $first, $second, $third ) = max( 1, 2, 3, 4, 5 ); [1] http://onyxneon.com/books/modern_perl/ http://onyxneon.com/books/modern_perl/
- catnaroek 13y ago> We also use programming languages to communicate to other programmers (which includes our future selves). Communication using natural language is fundamentally different from communication using programming languages. The ability to be vague, redundant and even wrong - all of these are features in natural languages, but bugs in programming languages. > Perl has many, many nuances. This is often derided by people that prefer more rigid languages. I like to think that it helps me see the programmer intent and thought process more clearly through the code. Nuances obscure intent, because they require you to be actively aware of the possibility of their existence in order to understand code. > Obviously there are downsides to this, just as there are downsides to overly rigid languages. I see no downsides whatsoever to reducing the extent to which one can be wrong.
- Mithaldu 13y ago> I see no downsides whatsoever to reducing the extent to which one can be wrong. Then you need more creativity. :) Nuances make it possible to express extremely complicated (yet often used) concepts in a very concise manner that is still extremely clear. See for example Python Decorators [1]. Very rigid languages take less effort in learning, but at the same time can require the developer to spend a lot more time and effort expressing certain things. See Java. [1] http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/ http://simeonfranklin.com/blog/2012/jul/1/python-decorators-... (Only 12, imagine that!)
- catnaroek 13y ago> Very rigid languages take less effort in learning, but at the same time can require the developer to spend a lot more time and effort expressing certain things. See Java. I do not think of Java as a language with few nuances. Null references, broken covariance for arrays, two non-orthogonal notions of modularity (class-based: public, protected and private; package-based: default visibility), value semantics for primitives vs. reference semantics for everything else... it is all very nuanced! Plus, for all the supposed rigidity, you can break type safety via reflection. On the other hand, Haskell and Standard ML (especially the latter!) strike me as very simple languages, with a far more rigid notion of safety than Java programmers could ever dream of, but which nevertheless afford lots of expressivity. Far more than either Python or Java.