Pure dynamic casts?

Jeremie Pelletier jeremiep at gmail.com
Thu Sep 24 20:54:45 PDT 2009


Christopher Wright wrote:
> Jeremie Pelletier wrote:
>> language_fan wrote:
>>> Wed, 23 Sep 2009 10:43:53 -0400, Jeremie Pelletier thusly wrote:
>>>
>>>> You're right about concurrency being a different concept than 
>>>> threading,
>>>>   but I wouldn't give threading away for a pure concurrent model 
>>>> either.
>>>> I believe D is aiming at giving programmers a choice of the tools they
>>>> wish to use. I could see uses of both a concurrent model with message
>>>> passing and a threading model with shared data used at once in a
>>>> program.
>>>
>>> The danger in too large a flexibility is that concurrency is not easy 
>>> and it is getting incresingly complex. You need to be extraordinary 
>>> good at manually managing all concurrent use of data. If I may 
>>> predict something that is going to happen, it is that there will be 
>>> high level models that avoid many low level pitfalls. These models 
>>> will not provide 100% efficiency, but they are getting faster and 
>>> faster, without compromizing the safety aspect. This already happened 
>>> with memory allocation (manual vs garbage collection - in common 
>>> applications, but not in special cases). Before that we gave some of 
>>> the error detection capabilities to the compiler (e.g. we do not 
>>> write array bounds checks ourselves anymore). And optimizations (e.g. 
>>> register allocation). You may disagree, but I find it much more 
>>> pleasant to find that the application does never crash even though it 
>>> works 15% slower than an optimal C++ code would.
>>
>> 15% slower is an extreme performance hit. I agree that code safety is 
>> useful and I use this model all the time for initialization and other 
>> code which isn't real time, but 15% takes away a lot of the 
>> application's responsiveness, if you have 50 such applications running 
>> on your system you just spent $1000 more in hardware to get the 
>> performance of entry level hardware with faster code.
> 
> What are most applications these days? MS Office, a web browser, maybe 
> an email client, some odds and ends, and a whole bunch of web sites 
> running on servers somewhere (with associated database servers and some 
> other odds and ends).
> 
> How much does it cost to get a slightly better machine? Fully hosted? 
> Maybe $100/month.
> 
> How much does it cost to develop it in a faster but more error-prone 
> language? Maybe months more time to market, time you're not making money 
> but are still paying developers. Those developers will need to be more 
> skilled than the ones using a safer language, and thus will cost you 
> more. New features will take more time to develop.
> 
> It's a competitive advantage to use a slower, safer language on the web.
> 
> Desktop applications are not quite so straightforward.

I agree with you about web applications, scripting languages are fast 
enough to serve web pages in most cases. However I did see some pretty 
ugly code which took over a minute to generate a page from a 1.5Gb 
database using only string fields without any indexes and PHP was 
throwing more notices and warnings than actual html.

I was referring to desktop applications, where you can't just buy a 
second server to host your database and serve static content like images 
and whatnot. From the 2 years I worked in tech support the problem I saw 
the most often was computers slowed down to a crawl, many of them 
without viruses or spywares. There are so many people who upgrade their 
computer just so they can run new software that really doesn't have many 
new features, but just is written in a safer language. That 15% 
performance hit over all the programs they ran at once was just too much 
for their old processor, when 2 months ago before they upgraded the 
software it was working just fine. Live messenger should not take half a 
minute to load and perform poorly when the old msn messenger was running 
perfectly fine.

>> If you wrote a real time renderer for example with that 15% hit, you 
>> get a very noticeable difference in framerate. Not to mention standard 
>> GUIs to be laggy on slower machines (just MSN messenger runs to a 
>> crawl on my old computer, yet it can run the first UT which does way 
>> more operations per second, because there's no performance hit by 
>> safer code bloat).
> 
> Games are not interesting in this regard. They require performance, and 
> they're hideously expensive. A studio can throw developers at the 
> problems and make them go away.
> 
> Not all games are like this, of course. But most are.

<rant>

What happened to one man armies like John Carmack and Tim Sweeney? These 
were the guys who inspired me to get into coding in the first place. I 
just loved how they could put together entire engines on their own and 
carefully optimize them. What about Walter who wrote the first C++ 
compiler and optlink as well as dmd from which I learned so much about 
compiler internals, or Andrei and his extensive work on meta programming 
and generic programming, from which I also learned so much.

There's also that one guy developing the game LOVE all on his own using 
only C, he wrote his tools, his engine, his model format, does his 
artwork, *everything*. And he is making some quick progress that would 
make teams of 50+ jealous.

Point is, only companies have the resources to throw more people at the 
problem and forget about it. At the end of the day, if you multiply the 
number of people involved by the development time, the one man army 
still is winning by far, both in time and resources spent.

Games were only an example, what about programs like flash, photoshop, 
autocad, 3dsm, and others. No matter what domain you're interested in 
you're gonna come across program that require every bit of performance 
they can get. Be it developed by teams of 50+ programmers or a single one.

I'm not saying safer languages are bad, far from that, I'm just saying 
there's a way to get the productivity of these languages and the 
optimization power of unsafe languages together, and there's a target 
audience for that.

Having a single language which provides enough features to allow either 
safe development or unsafe development will also get everything in 
between. This is what got me hooked on D in the first place, even when I 
first read about it this is what was going through my head, and I 
haven't looked back since.

</rant>

Jeremie.



More information about the Digitalmars-d mailing list