Python was designed (was Re: Multi-threading in Python vs Java)

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Oct 21 22:29:34 EDT 2013


On Mon, 21 Oct 2013 01:43:52 -0700, Peter Cacioppi wrote:

> Specifically the following seems so misguided as to be deliberate
> trolling.
> 
> "One of the reasons multiple languages exist is because people find that
> useful programming idioms and styles are *hard to use* or "ugly" in some
> languages, so they create new languages with different syntax to make
> those useful patterns easier to use."

As the author of that quote -- and I wonder why you're dropping 
attributions -- I can assure you I am not trolling.

Why do you think that my comment is misguided? If you don't believe that 
people write new languages because they are dissatisfied with the 
existing ones, why do you think they write new languages?

I think that my comment should be uncontroversial. At least some 
languages were invented because the author was dissatisfied with some 
existing language and wanted a "better" language. Bjarne Stroustrup wrote 
C++ to be a better C supporting data abstraction, OOP and generic 
programming, which were too hard to do right in C.

http://www.stroustrup.com/bs_faq.html

Niklaus Wirth wrote Pascal because he wanted a *simpler* language than 
Algol -- he famously walked out of one of the Algol design conferences 
because he disagreed with the direction they were taking -- and then he 
followed Pascal with Modula 2 and Oberon to be "better" Pascals, e.g. 
adding support for parallisation, which was hard to do in Pascal.

Bertrand Meyer invented Eiffel because he liked the style of Ada and the 
OOP of Stimula, and wanted to make Design By Contract easier to use.



> This is just profoundly wrong. If anything, different languages strive
> to maintain common syntax.

With respect, I think that demonstrates a lack of experience with 
programming languages. What "common syntax" do you perceive between 
languages such as these?

- Hypertalk
- Forth
- Pascal
- Lisp
- Haskell
- bash
- Inform 7
- Prolog

All of these are real languages; none of them are joke languages. If you 
aren't at least aware of their existence, and the general "feel" of their 
syntax, then you aren't qualified to comment on programming language 
syntax. The world is much bigger than just the C family of languages.

Of course, languages tend to resemble the languages that most influenced 
them, and there are distinct "family resemblances", e.g. XTalk languages, 
Algol-based languages, etc. Some pairs of languages are closer than 
others, e.g. both Hypertalk and Haskell would accept "x + 1" as a valid 
expression to evaluate one more than x, whereas in Forth it means 
something completely different.


> You can see foo.bar() as legal syntax meaning
> essentially the same thing in C++, C#, Java and Python (and likely quite
> a few other languages). There is NOT a deliberate effort to create new
> syntax just for aesthetics, there is the exact opposite. There is a
> deliberate effort to maintain consistency with the syntax of
> pre-existing languages.

Perhaps you ought to re-read my earlier comment. I did not say that 
people "create new syntax just for aesthetics". I said that one reason 
for making a new language (there may be more than one!) is if a useful 
idiom or design pattern is *hard to use* in a language. Parallel 
processing is hard in Pascal, so Wirth created Oberon; OOP is hard in C, 
so Stroustrup created C++.

Often languages aren't just "another language, plus foo" for some foo. 
Java isn't just C-with-garbage-collection-and-objects, but James Gosling 
invented Java because he wasn't happy with the level of support for 
garbage collection and OOP in existing languages. They're not just gluing 
"one more feature" on top of an existing language. Here is Rob Pike's 
explanation for why Go was invented:

http://commandcenter.blogspot.com.au/2012/06/less-is-exponentially-
more.html

Short version: they wanted a language where concurrency was easy, and 
were dissatisfied with C and C++. Pike tried to do concurrency in C++ and 
failed:

    [quote]
    I actually tried and failed to find a way to bring the ideas 
    to C++. It was too difficult to couple the concurrent operations 
    with C++'s control structures, and in turn that made it too hard
    to see the real advantages. Plus C++ just made it all seem too
    cumbersome, although I admit I was never truly facile in the
    language. So I abandoned the idea.


Actually, depending on how you define aesthetics, that is *exactly* why 
people define new syntax. You can write loops with GOTO:

10 do this
20 do that
30 if condition GOTO 10

but it's "ugly", by which I mean it is hard to use, error prone, and not 
easily maintained. And so modern languages eschew GOTO for while loops. 
Likewise if you have while, you don't strictly need for loops as well:

i = start
while i < end:
    process(i)
    i += step

nevertheless compared to a for-loop, such a construct is "ugly" (harder 
to use, more error prone, less easily maintained, harder to read, harder 
to analyse), and so modern imperative languages tend to provide both.

(Functional languages tend to use recursion and comprehensions in place 
of explicit loops.)


> Languages sprout up for a variety of reasons. C++ has very significant
> functionality that doesn't exist in C. Java/C# can say the same thing to
> C++, and Python to all of the others.


Challenge: give some examples of things which you can do in Python, but 
cannot do *at all* in C, C++, C#, Java?

(Here's a hint: there are at least two Python interpreters written in C. 
How does Python manage to do things which the underlying C implementation 
is utterly incapable of? What if you embedded a mini Python-like 
interpreter in your C code?)

 
> Please lets not pretend that it's all just ballpark equivalent facades
> plastered on top of a Turing machine. 

I never said that.


> New languages pop up to automate
> boring and repetitive tasks that chew up your time in older languages.
> That's the trend - abstractions automating repetitious and error-prone
> tasks.
> 
> Not "hey, this syntax isn't too my taste, I'm going to toodle it up".

And that is certainly a straw-man.


-- 
Steven



More information about the Python-list mailing list