python vs d

Russel Winder via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 30 23:04:41 PDT 2014


On Wed, 2014-04-30 at 15:21 -0400, Nick Sabalausky via Digitalmars-d
wrote:
[…]
> I've heard this a lot, but I've yet to hear anyone explain concretely 
> how this "dynamic mindset" causes the lack of things like static code 
> checks and low-overhead primitives from being actual drawbacks. Maybe it 
> really is a case of me not "getting it", but it always sounds to me like 
> this "dynamic mindset" gets around these issues simply by ignoring them. 
> Since I don't personally do heavy development in dynamic languages, I'd 
> be interested in a strong rebuttal to this.

The best way of approaching this is not to try and attempt a long
theoretical essay, but to try (a possibly lengthy exchange of question
and answer accompanied by actually writing code in both Python and D.
Also looking at things like Rosettacode and all Bearophile and others'
work there.

There are two questions above to kick start things, let's take the
second first:

Low-overhead primitives: This immediately implies you are looking for
raw CPU-bound performance or you are undertaking premature optimization.
Python has no direct "play" in this game. If a Python code requires out
and out CPU-bound performance, you profile to find the small bit of the
total code that is performance critical. If it is not already a function
you extract it as a function, put it in it's own module and Cythonize it
(*). Still Python code but with a few judicious extra annotations so as
to enable Cython to generate C which is then compiled to native code.

Static code checks: The object (aka data) model, and variable model of
Python (and indeed other dynamic languages) means there cannot be any
static code checks. At this point, I have to yield (in this co-routine
exchange :-) with a question: what is it about static code checks that
you feel you have to have in order to be able to program?


(*) There are other techniques, but this is the lowest overhead in terms
of programmer time, and it gives excellent runtime speed-up.
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder



More information about the Digitalmars-d mailing list