C++0x Concepts - Dead?

bearophile bearophileHUGS at lycos.com
Thu Jul 16 18:15:17 PDT 2009


BLS:
> I see your point... you are doing bio informatics..so speed matters.. 
> for me the things are a bit different...

Bioinformatics doesn't matter much here. One of the PCs I use has a CPU with 4 cores plus about a ~$100 3D card (that can be programmed with CUDA to produce spectacular programs, I have seen demos run on this PC that almost scare me, like this one: http://www.youtube.com/watch?v=RqduA7myZok  and this is a low-end 3D card: there are cards that probably have 3-6X more computing power), when I write normal D1 code today I am probably using 10-30% of such computing power. Compared to such "waste" even the performance gain of LDC over DMD is small.

A sufficiently determined programmer can learn CUDA for the GPU and do all the low level multithread programming you want on the CPU, to find ways to use most of that computing power. But something similar can be said about programming in assembly too. I'm willing to lose 20% of efficiency if the language (future D2) will give me handy&safe ways to use the other cores of the CPU and maybe even to use the GPU too at the same time (see OpenCL). Tapping some percentage of that CPU+GPU power in a handy enough way is today quite important.


> But I guess that you'll agree with me that Scala pattern matching has a 
> reasonable syntax. (Not necessarily talking about "How difficult is it 
> from a compiler author's view)
> 
> object MatchTest2 extends Application {
>    def matchTest(x: Any): Any = x match {
>      case 1 => "one"
>      case "two" => 2
>      case y: Int => "scala.Int"
>    }
>    println(matchTest("two"))
> }

Scala pattern matching, when used for simple/medium things, is simple to read and understand (when you use it for complex things it quickly becomes hard to understand).
But beside the extra syntax, if you want to add pattern matching to D2 (OCaML-style pattern matching may be more fit for D2, because it probably has a higher performance at run-time and it's closer to the style of C++-like languages where as much as possible is done at compile-time) you probably need a more complex type system, and adding such improved type system to D2 looks like a too much big work now (and it increases complexity of other things too, I fear). That's why I have stopped for long time asking to add a built-in pattern matching to D, even if I can't deny it's sometimes handy.

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list