About switch case statements...
Walter Bright
newshound1 at digitalmars.com
Mon Nov 16 13:46:08 PST 2009
Steven Schveighoffer wrote:
> You are totally free to make a language that nobody uses :)
About 10 years ago, I went out jogging with a colleague who was also a
programmer. We were talking about compilers, of course, and he said
"what the world really needs is a Java compiler that compiles to native
code, not this VM bull." He assured me that such a product would sweep
the world.
I told him I thought he was right, and so did a lot of people. So right
that about 5 years previously, I did just that (for Symantec). Turns
out, nobody wanted it. I told him I could get him a copy. He didn't want
it either.
<g>
Another fun story. Back in the 80's, a programmer told a friend that the
MOST IMPORTANT thing he looked for in a compiler was compilation speed.
My friend told him that was obviously the least important thing to him.
Shocked, the programmer asked why? My friend told him that he was using
the slowest compiler on the market by a factor of 4. There were several
other much faster C++ compilers available, but he stuck with the slow
one. The programmer reacted like this thought had never occurred to him.
<g>
More fun stuff. 10 years ago, I was convinced by many people that the
world needed a fast javascript engine. I built one that was twice as
fast as Jscript, and twenty (that's right, 20) times faster than
Mozilla's javascript engine. It passed all the test suites.
I couldn't give it away.
On the other hand, the advice I got when starting to write a C compiler
was "who the f*** needs another C compiler?" Nobody thought it was a
good idea. Turns out, there was a big market for it!
Now, I'm not saying you're wrong. I'm just saying that making a product
that people want isn't as simple as asking them what they want. With the
switch thing, there's a cost to all the solutions proposed here - rather
klunky to look at and significant extra work to type them in.
Perhaps the reason I don't have trouble with the usual switch statements
is because it seems natural to me, as I come from an asm/fortran/basic
background, where one would never write:
foo();
goto L1;
L1: bar();
goto L2;
L2: baz();
goto L3;
L3: asdf();
return;
and case labels look like, well, labels to me. The goto version is ugly
and hard to read.
Reminds me a bit of D a few years back, when people would say D didn't
have lambda's. But D did have them! The problem was the syntax was a bit
verbose. Simplified the syntax, and suddenly the lambda's got noticed
and got used.
More information about the Digitalmars-d
mailing list