dynamic classes and duck typing

retard re at tard.com.invalid
Tue Dec 1 22:55:36 PST 2009


Tue, 01 Dec 2009 16:58:32 -0500, Adam D. Ruppe wrote:

> On Tue, Dec 01, 2009 at 09:17:44PM +0000, retard wrote:
>> The lack of type annotations at least removes all typing bugs.
> 
> Quite the contrary, leaving off the type annotation spawns bugs.

It spawns new bugs, for sure, but it removes all static typing bugs cause 
those aren't checked anymore and cannot exist under that category!

> I had
> to write a web app in Ruby last year, and well remember the little
> things that slipped past tests, pissing off end users.
> 
> "Why can't I access this obscure page?"
> 
> Because a != b since for some reason, the database returned a as a
> string, and b was assigned by an integer literal.
> 
> In D, that would have been an instant compile time error. In Ruby, it
> was a runtime error on a page obscure enough that it slipped past
> testing into the real world.

The thing is, nowadays when all development should follow the principles 
of clean code (book), agile, and tdd/bdd, this cannot happen. You write 
tests first, then the production code. They say that writing tests and 
code takes less time than writing only the more or less buggy production 
code. Not writing tests is a sign of a novice programmer and they 
wouldn't hire you if you didn't advertise your TDD skills.

In this particular case you use a dummy test db fixture system, write 
tests for 'a is int' and 'b is int'. With these tests in place, the 
functionality provided by D's type system is only a subset of the 
coverage the tests provide. So D cannot offer any advantage anymore over 
e.g. Python.



More information about the Digitalmars-d mailing list