4 ms·
Agreed. My first job they gave me a copy of Deitel & Deitel's "C How to program" along with the test. You actually lost points if you didn't open it!
by astrec 18y ago
Agreed. My first job they gave me a copy of Deitel & Deitel's "C How to program" along with the test. You actually lost points if you didn't open it!
- ntoshev 18y agoYou know the syntax of switch in the language you have been using in the last three months. If you don't, something's wrong!
- astrec 18y agoSure, but we're talking about testing ability vs. memory - switch is incidental.
- ntoshev 18y agoAbility requires memory, at least for basic things. You can't be a good programmer and forget the syntax of the language you are working in. If you need to look up something as fundamental as switch statement in the internet, it's like a writer looking up words in the dictionary before writing them down in his novel.
- jcromartie 18y agoI think switch is a particularly bad example here. Honestly, I can't (accurately) tell you the last time I used one. It's not an every-day construct for a lot of people.
- eru 18y agoNeither Python nor Haskell have it - as far as I know. Perhaps you can create one out of monads though.
- lsb 18y agoActually, case is built into Haskell: it's the evaluation primitive in Haskell Core; see Don Stewart's blog post http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16 http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16 .
- eru 18y agoYes, there it is. Sorry, I did not research my claim. Actually pattern matching can also be described as something like a case-switch.
- jonknee 18y agoWriters very frequently use the dictionary. There is no problem with it, that's why we have dictionaries.
- eru 18y agoNot for scrabble disputes?
- raganwald 18y agoI never use Ruby's case or switch or whatever-it's-called. I could make up some mumbo-jumbo about case being a code smell and that it should actually be refactored to a method dispatch over polymorphic objects, but the truth is that I have no idea why I don't write case statements, I just don't.
- hugh 18y agoAdd me to the "never uses switch statements" list. I've never seen the point in learning the syntax in any of the languages I know, since a bunch of else ifs (or elseifs, or elsifs, or elifs, depending on the language) does the same thing. If I waste a few keystrokes, but save a few brain cells, I think it's a worthwhile bargain. Of course if I had to write that kind of construction often I'd probably learn the syntax of the case statement, but in the kind of work I do it hardly ever actually comes up.
- etal 18y agoIt's really just a performance optimization for C, in situations where the switching value can be hashed. In languages that make method dispatch easy, and the overhead of a function call is not something you're terribly concerned about, it makes sense to just roll your own as needed -- that's why Python never bothered with a switch statement.
- stcredzero 18y agoActually, if you never use switch, then that's a symptom of being good at OO.