OT: on IDEs and code writing on steroids
dsimcha at yahoo.com
Wed May 20 06:59:33 PDT 2009
== Quote from Ary Borenszweig (ary at esperanto.org.ar)'s article
> dsimcha escribió:
> > == Quote from Christopher Wright (dhasenan at gmail.com)'s article
> >> Nick Sabalausky wrote:
> >>> "Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message
> >>> news:gus0lu$1smj$2 at digitalmars.com...
> >>>> I've repeatedly failed to figure out the coolness of C#, and would
> >>>> appreciate a few pointers. Or references. Or delegates :o).
> >>> Outside of this group, I think most of the people considering C# really cool
> >>> are people who are unaware of D and are coming to C# from Java. What's
> >>> "cool" about C# is that it's like a less-shitty version of Java (and *had*
> >>> good tools, although the newer versions of VS are almost as much of a
> >>> bloated unresponsive mess as Eclipse - Which come to think of it, makes me
> >>> wonder - If Java has gotten so fast as many people claim, why is Eclipse
> >>> still such a sluggish POS?).
> >>> Compare C# to D though and most of the coolness fades, even though there are
> >>> still a handful of things I think D could still learn from C# (but there's
> >>> probably more than a handful that C# could learn from D).
> >> Generics and reflection. Generics just hide a lot of casts, usually, but
> >> that's still quite useful. And autoboxing is convenient, though not
> >> appropriate for D.
> > What the heck do you need generics for when you have real templates? To me,
> > generics seem like just a lame excuse for templates.
> Yesterday doob reported a bug in Descent saying "when you compile your
> project and it references a user library that has errors, when you click
> on the console to jump to the error, it doesn't work". I said to him: I
> never thought a user library could have errors! How did this happen to
> you? He replied: "I found a bug in a template in Tango".
> That's why generics doesn't suck: if there's something wrong in them,
> the compiler tells you in compile-time. In D, you get the errors only
> when instantiating that template.
> Generics might not be as powerful as templates, but once you write one
> that compiles, you know you will always be able to instantiate it.
Yes, but there are two flaws in this argument:
1. If you are only using templates like generics, you simply use a unit test to
see if it compiles. If you're not doing anything fancy and it compiles for one or
two types, it will probably compile for everything that you would reasonably
expect it to.
2. If you're doing something fancier, like metaprogramming, you have to just face
the fact that this is non-trivial, and couldn't be done with generics anyhow.
3. As Bearophile alluded to, templates are really a clever hack to give you the
flexibility of a dynamic language with the performance and compile time checking
of a static language. This is done by moving the dynamism to instantiation time.
Therefore, whereas in a dynamic language you pay at runtime in terms of the "here
be monsters, this code may not be being used as the author intended and tested
it", with templates you pay at instantiation time. However, IMHO this is orders
of magnitude better than not having that flexibility at all. I personally can't
figure out how people accomplish anything in static languages w/o templates. It's
just too inflexible.
More information about the Digitalmars-d