D and the world

Bill Baxter dnewsgroup at billbaxter.com
Sat Apr 28 12:31:03 PDT 2007


Sean Kelly wrote:

> One issue I have with many dynamic languages is that they don't require 
> variables to be declared before they are used.  In my experience, this 
> can turn a mistype into a bug that takes hours to find.  

Yep which is why serious Python developers swear up an down by unit 
tests.  "If it doesn't have tests it's broken code."  At least that's 
what I hear a lot ... however tests take time to write, and so they 
don't always get written.  And besides wasn't I using python so I could 
get things done quicker?  And now you tell me I have to give back all 
that time I saved and use it to write unit tests?!  Of course they'll 
reply that you should be writing unit tests for your compiled code too. 
  But it's not the same.  My compiled code at least is unlikely to have 
any type errors.

More recently,
> I've noticed that the lack of type information in dynamic languages can 
> make it very difficult to figure out how to use a piece of code.  Is 
> there an easy way to figure out what is returned from a class member 
> function?  

Yes.  Write good documentation. :-)  Every non-trivial python function I 
write gets a full-blown doc-string with INPUTS and OUTPUTS sections 
describing exactly what every parameter is for.   Of course everyone 
knows it's a good idea to do this in C++ too, so Python folks will 
probably tell you this isn't really adding to your workload, either.

In deep inheritance trees, figuring this out through code
> inspection can take a while, and it isn't always feasible to try and 
> figure it out using interactive calls (ipython).

I don't think deep inheritance trees are as necessary with duck typing. 
  You can can do a lot more with object composition and multiple 
inheritance of more specific bits of functionality.  Or just 
re-implement it.  Of course some things are naturally hierarchical.

> That said, the flexibility of such languages is what makes them so 
> powerful.  I'm just not convinced I'd actually want to use them for 
> anything but relatively compact chunks of code.

Python is catching on in the scientific community, at least.  Makes it 
easy to get the initial prototype working, similar to something like 
Matlab (that's usually a compact chunk of code), but gives you the 
option of building fancy gui web-enabled interfaces on top of that, 
which is difficult for most math-and-science-only tools.

--bb



More information about the Digitalmars-d mailing list