Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

IF vs Switch

Name: Anonymous 2010-07-07 12:12

if (1==a){}else{} vs switch(a){case 1:}
Which one is faster? At which point of complexity switches are faster than ifs?

Name: Anonymous 2010-07-07 12:17

anus

Name: Anonymous 2010-07-07 12:21

Compile it and see.

Name: Anonymous 2010-07-07 12:29

>>3
It would become a benchmark of my compiler/cpu/os.

Name: Anonymous 2010-07-07 13:04

if

Name: Anonymous 2010-07-07 13:20

People always say that using if's is better than using a switch. But why?

Name: Anonymous 2010-07-07 13:29

>>4
No it wouldn't. Compile it to assembly and see how many instructions it is. Also that switch should have a default clause if it is to be equivalent to that if.

>>6
No they don't. Did you mean goto?

Name: Anonymous 2010-07-07 13:38

How comes that every serious question on /prog/ is from someone completely new to programming? Could it be that there actually aren't any professional programmers here anymore?

Name: Anonymous 2010-07-07 13:39

>>8
JEWS

Name: Anonymous 2010-07-07 13:41

>>8
Real programmers don't ask many questions, they already know the answers or know where to look it up.

Name: Anonymous 2010-07-07 13:51

>>8
Have you seen Jeff's Stack Overflow profile?

Name: Anonymous 2010-07-07 13:53

>>11
yeah i masturbate to it three times a day, everyday

Name: Anonymous 2010-07-07 14:32

>>10
Well, that's certainly true for simple questions, but there's a lot of questions that don't have a clear solution and call for a discussion and exploration by experienced users. Not to mention that questions aren't everything that this board could be used for, just discussing and sharing would be cool.

But no, I really don't think /prog/ has a significant number of seasoned programmers. I myself asked a broader question, about how should I structure my code, but no one was willing to seriously participate.

Name: Anonymous 2010-07-07 14:51

>>13
If you are >>1 I hope you are joking.

Name: Anonymous 2010-07-07 15:10

>>13
For specific advanced questions, I just direct them to the right place? If I have an advanced C-related question which the documentation and standard cannot answer, I can ask c.l.c or ##c, Lisp - #lisp or c.l.l. Algorithmic advice? If Knuth doesn't have it, I ask in the relevant place. I can't remember the last time I asked /prog/ a question, and I've probably been here for at least 2 years.

Name: Anonymous 2010-07-07 15:23

>>14
LOL, no. If you must know, 1278285050 is my post, and while it's not a pinnacle of advanced and thought provoking questions, I do believe it should have more airtime than posts about argument parsing, console text effect, or if-else vs. switch.

Name: Anonymous 2010-07-07 15:29

>>15
I guess, I see what your saying, and I wouldn't have a problem, if everyone had the same attitude. But you see, what makes /prog/ shitty is that the OP posted this question, while you haven't posted one in 2 years and that people answer questions like this, while ignore decent ones.

Name: Anonymous 2010-07-07 15:52

>>13
It's impossible to say for certain, but I get the feeling that most have left for the summer. I know I've been taking extended leaves of absence

Name: Anonymous 2010-07-07 17:05

>>17
People don't answer any questions. Idiots try to answer anything they think they understand, which is why bullshit like this gets replies while more advanced things don't.
If I had a serious question about programming and wanted to ask /prog/, I'd ask #sicp. That's where the knowledgeable regulars hang out.

Name: Anonymous 2010-07-07 17:17

>>18
I know I've been taking extended leaves of absence
Shit, same here and i dont even have a life.

How the fuck can that happen?

Name: FrozenVoid 2010-07-07 21:17

>>1 By time of execution:
ConstExpr<Variable retrieval(e.g. x&8)<Array access<Computed Goto<Switch<Ternary<If<Pattern Matching

Name: Anonymous 2010-07-08 0:32

on any modern compiler, if/else and switch are just different syntax for the same thing. they should be the same speed.

Name: Anonymous 2010-07-08 0:51

>>22
Most of the time they can't be different syntax for the same thing. That's why they're separate constructs in the first place.

Name: Anonymous 2010-12-17 1:32

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List