syntax difference

Bart bc at freeuk.com
Sun Jun 24 16:21:57 EDT 2018


On 24/06/2018 20:02, Steven D'Aprano wrote:
> On Sun, 24 Jun 2018 19:37:33 +0100, Bart wrote:
> 
>> I want to program in /my/ style
> 
> Python is not Java, and Java is not Python either. Nor is it "Bart's
> Language", or C, or Forth, or Lisp, or bash.
> 
> https://dirtsimple.org/2004/12/python-is-not-java.html
> 
> https://dirtsimple.org/2004/12/java-is-not-python-either.html
> 
> 
> To get the best out of any language, you should try to program to its
> strengths, in the idioms that work, not insist on writing FooLanguage
> code in BarLanguage.

I like to write in clear code in a manner that anyone can follow 
(although I'm mainly thinking about myself). That means not using idioms 
specific to a language and hard to translate to anything else.

Why might someone want to use something like Python rather than, for 
example, C? Here are some reasons:

* Clearer syntax less full of punctuation
* Simpler for-loops
* Module import system
* Much faster edit-run cycle
* Dynamic types to eliminate most variable declarations
* No need for forward declarations for functions
* First class string handling
* First class list handling
* Flexible arrays/lists (not strings as they are immutable)
* Namespaces
* Default and keyword parameters
* Can forget about using pointers

That would be plenty to get started with, and enough to make it 
worthwhile to use the dynamic language provided its libraries and its 
performance are suitable for the task.

But so far it has not been necessary to explicitly use a Pythonic style 
of coding or any of its esoteric features.

> You'd probably be pretty frustrated if one of your users (ahem) insisted
> on duplicating the form and structure of their bash scripts in your
> language, and complaining bitterly about how your language sucks because
> it isn't bash.

I've had half a dozen users and I don't recall any particular problems 
nor any complaints. The language, although cruder then, must still have 
been sweeter to use than what was typically available at the time.

-- 
bart



More information about the Python-list mailing list