Interview at Lang.NEXT

Jacob Carlborg via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Jun 5 11:56:23 PDT 2014


On 2014-06-05 15:31, Bill Baxter via Digitalmars-d-announce wrote:
> On Thu, Jun 5, 2014 at 2:42 AM, Jonathan M Davis via
> Digitalmars-d-announce <digitalmars-d-announce at puremagic.com
> <mailto:digitalmars-d-announce at puremagic.com>> wrote:
>
>
>     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.
>
>
> Yeh, that's possible, but that doesn't look like something anyone with
> any sense would do.
>
> The things I found most enjoyable about working on javascript were
> 1) REPL / fully interactive debugger
>      When you hit a break point you can just start typing regular js
> code into the console to poke the state of your system.
>      And the convenience of the REPL for seeing what bits of code do as
> you write them.
> 2) Duck typing / introspection ability
>      If you have a bunch of objects that have a .width property, and
> that's all you care about, you can just look for that.  No need to
> declare an IWidthHaver interface and make all of your objects declare
> that they implement it.
> 3) Relative ease of writing tests
>      We used the Closure compiler for the js I worked on, so it wasn't
> totally wild west.  It has a fair amount of static type checking.
>      But when it comes to tests, it's very convenient to just be able to
> fake any object by slapping some dummy functions in between curly
> braces.  For example if I want a fake "IWidthHaver" instance, I just
> have to write x = { width: 10 }, and I'm done.  Plus I can monkey patch
> things in tests, replacing whatever method I want with a wrapper that
> does some custom monitoring before or after calling the real method.
>   Writing tests for C++ is a pain in the butt in comparison.

In D you can use a wrapper and opDispatch to delegate and intercept 
method calls.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list