gemot encubed  

Go Back   gemot encubed > Gemot > General Discussion

General Discussion Theres a Clannad of AIR-headed Kanon fodder being shot by the Little Busters After Tomoyo on a Planet-arian.

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 2005-06-03, 09:28
Haeleth's Avatar
Haeleth Haeleth is offline
Ex-boss
 
Join Date: Mar 2003
Location: England
Posts: 2,106
Default Not the Daily WTF...

...but Key's code never ceases to amuse me.

The following gem is part of Kanon Standard Edition's title menu, and it's too good not to share:
Code:
if (1 == 1) {
    SetSkipAnimations (0)
} else if (1 == 0) {
    SetSkipAnimations (1)
}
This exact snippet appears seven or eight times in the title menu.

Clearly it's the result of naive macro expansion, but come on, VisualArt's... if I, an amateur, can write a compiler that optimises out cases like that in my spare time, surely your professional programmers can manage something... -_-;;
  #2  
Old 2005-06-03, 11:15
curlyconnor
Guest
 
Posts: n/a
Default

Well, I don't exactly see what's so bad about that. But then again, I know NOTHING about programming code.
  #3  
Old 2005-06-03, 11:22
zalas zalas is offline
 
 
Join Date: Feb 2004
Location: fushigi misuterii
Posts: 1,831
Send a message via ICQ to zalas
Default Re: Not the Daily WTF...

Quote:
Originally Posted by Haeleth
...but Key's code never ceases to amuse me.

The following gem is part of Kanon Standard Edition's title menu, and it's too good not to share:
Code:
if (1 == 1) {
    SetSkipAnimations (0)
} else if (1 == 0) {
    SetSkipAnimations (1)
}
This exact snippet appears seven or eight times in the title menu.

Clearly it's the result of naive macro expansion, but come on, VisualArt's... if I, an amateur, can write a compiler that optimises out cases like that in my spare time, surely your professional programmers can manage something... -_-;;
I think it's more that the time spent on optimizing it out wouldn't achieve significant enough gains, since they expect people's computers to run fast enough that it wouldn't matter.
  #4  
Old 2005-06-03, 12:17
Haeleth's Avatar
Haeleth Haeleth is offline
Ex-boss
 
Join Date: Mar 2003
Location: England
Posts: 2,106
Default Re: Not the Daily WTF...

Quote:
Originally Posted by zalas
I think it's more that the time spent on optimizing it out wouldn't achieve significant enough gains, since they expect people's computers to run fast enough that it wouldn't matter.
Well, ye-ess... but if efficiency is not a concern, you have to ask yourself why they bother compiling to bytecode in the first place, when other systems manage perfectly well executing from (compressed and encrypted) text.

(If they were worried about people being able to read their scripts, all they have to do is use Perl... :p)

Not to mention that if their compiler was written with an eye to saving programmer time, and therefore uses a simple lex/yacc setup instead of something complex and custom-built, it would probably take all of half an hour to add constant folding and compile-time evaluation of constant conditions. You'd think they'd do it out of pride if nothing else... ^^;
  #5  
Old 2005-06-03, 12:20
Shii's Avatar
Shii Shii is offline
Obsessive
 
Join Date: Jun 2005
Location: Cloudy Water
Posts: 497
Send a message via ICQ to Shii
Default

Quote:
Originally Posted by curlyconnor
Well, I don't exactly see what's so bad about that. But then again, I know NOTHING about programming code.
If 1 + 1 = 2, do this.
On the other hand, if 1 + 1 = 3, do this instead.



(yup, I'm registering on this forum too... I want to register on all visual-story related forums :v)
  #6  
Old 2005-06-03, 14:23
emperor emperor is offline
Regular
 
Join Date: Jun 2004
Location: Germany
Posts: 96
Default

Quote:
Originally Posted by Shii
Quote:
Originally Posted by curlyconnor
Well, I don't exactly see what's so bad about that. But then again, I know NOTHING about programming code.
If 1 + 1 = 2, do this.
On the other hand, if 1 + 1 = 3, do this instead.
(yup, I'm registering on this forum too... I want to register on all visual-story related forums :v)
Did you really understand this? Basically the problem here is that there is no need for the if after the else, since else already means that what this asks for HAS to be true. The flag can only be true or not. Basically it's like: If [the number that can only be 1 or 0] is 0 then do something[0]. Else look if the number is 1 and if that is the case do something[1]. Obviously this can be shortened to if the number is 0 then do something[0], else do something[1].
If the problem is what I interpreted it as then I hope this can now be understood by...everybody.
  #7  
Old 2005-06-03, 15:02
Haeleth's Avatar
Haeleth Haeleth is offline
Ex-boss
 
Join Date: Mar 2003
Location: England
Posts: 2,106
Default

Look closer, emperor. I wouldn't describe 1 as something that can be either 1 or 0. ;)
  #8  
Old 2005-06-03, 15:14
emperor emperor is offline
Regular
 
Join Date: Jun 2004
Location: Germany
Posts: 96
Default

Why did I read it as an l....
  #9  
Old 2005-06-03, 15:15
JudicatorOmega JudicatorOmega is offline
Local
 
Join Date: Jan 2004
Location: San Jose, CA
Posts: 100
Default

Your right, this was too good not to share with everyone.

Code:
if (1 == 1) {SetSkipAnimations (0)}
 else {SetSkipAnimations (1)}
That is what I would write, but if I was a real programmer, I would have used something even shorter than that and placed it elsewhere. I really believe you don't need to have that same thing going on 8 times when it only needs to be used once.

Maybe they did it like that, so that in case the number is -1, SetSkipAnimations() is not used at all. Hehehehehe... J/K

Oh and BTW, isn't 1 always going to equal 1?
__________________
"Its hard not to be jaded by the time your my age." - Kitsune, Love Hina TV Series
"I wonder if we'll meet again someday, on that hill..." - Precious Memories, Kimi Ga Nozomu Eien OP Single
  #10  
Old 2005-06-03, 15:18
emperor emperor is offline
Regular
 
Join Date: Jun 2004
Location: Germany
Posts: 96
Default

It is...this is what makes it even more stupid. Anyways...correctly this whole thing is supposed to be only
SetSkipAnimations (0)
  #11  
Old 2005-06-03, 15:25
JudicatorOmega JudicatorOmega is offline
Local
 
Join Date: Jan 2004
Location: San Jose, CA
Posts: 100
Default

Well hey, I guess thats the big joke, and why I mentioned "1 is always going to be 1". Nonetheless, if the first 1 was actually a variable, then the statement could still be shortened. I believe they left it in because they were indecisive over wether they would include animations or not.
__________________
"Its hard not to be jaded by the time your my age." - Kitsune, Love Hina TV Series
"I wonder if we'll meet again someday, on that hill..." - Precious Memories, Kimi Ga Nozomu Eien OP Single
  #12  
Old 2005-06-04, 01:57