Interview at Lang.NEXT

Jonathan M Davis via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Jun 5 12:00:55 PDT 2014


On Thu, 05 Jun 2014 12:46:23 +0000
Atila Neves via Digitalmars-d-announce
<digitalmars-d-announce at puremagic.com> wrote:

> On Thursday, 5 June 2014 at 09:43:13 UTC, Jonathan M Davis via
> Digitalmars-d-announce wrote:
> > On Thu, 05 Jun 2014 09:30:44 +0200
> > Though I confess what horrifies me the most about dynamic
> > languages is code
> > like this
> >
> > if(cond)
> >     var = "hello world";
> > else
> >     var = 42;
> >
> > The fact that an if statement could change the type of a
> > variable is just
> > atrocious IMHO.
>
> No, it's not just that you're statically-minded. Your example
> above is definitely atrocious, and more often than not a bug.

Well, of course it's a bug (or at least _horribly_ designed code if it's not).
The problem is that it's _legal_, and while that particular example might be
obvious, more complicated code could run into the same problem in more subtle
ways, causing bugs (and you won't even see the bug until you hit that
particular code path). Static typing avoids the whole problem.

As far as I can tell, dynamic typing doesn't really give you anything of value
over static typing. It just lets you type less (and features like auto
actually make it so that statically typed languages can eliminate a lot of the
same typing that dynamic languages eliminate but without reducing type
safety). You trade in a tool that automatically catches all kinds of bugs for
you just so that you don't have to type quite so much. It makes me wonder if
the folks who like dynamic languages ever write anything larger than a simple
script (and given how often we all screw up on even simple scripts, having the
compilers help there as well is still huge). I _definitely_ don't understand
the folks who write whole products in dynamic languages.

- Jonathan M Davis


More information about the Digitalmars-d-announce mailing list