Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Fecotourist
Nov 1, 2008

ZorbaTHut posted:

You'd say "optimize it for 5 seconds!" and boy howdy it would optimize that sucker for exactly 5 realtime seconds. Regardless of how much CPU it was actually getting during that time. And to make things worse, it was buggy. So, depending on how much CPU it got . . . well, it might just spit out invalid assembly once in a while.

Simulated annealing? By any chance did the assembler documentation mention a "temperature schedule"?

Adbot
ADBOT LOVES YOU

BigRedDot
Mar 6, 2008

Fecotourist posted:

Simulated annealing? By any chance did the assembler documentation mention a "temperature schedule"?

I fail to believe anyone would have done this except perhaps out of spite or as an attempt at humor.

ZorbaTHut
May 5, 2005

wake me when the world is saved

Fecotourist posted:

Simulated annealing? By any chance did the assembler documentation mention a "temperature schedule"?

I pray to God that it did not, but honestly it was more blackboxy than that. You just said "optimize for X seconds!" and sometimes it did.

It would not entirely surprise me if, on the inside, it did exactly that.

RussianManiac
Dec 27, 2005

by Ozmaugh
code:
                   #ifdef _OPENMP
			 #pragma omp critical

			 {
			 next_word = structure->get_next_word(i+list->minlength);
			 }
			 #else

			next_word = structure->get_next_word( i + list->minlength );
			#endif
Many more horrors in an open source project I recently took up.

BigRedDot
Mar 6, 2008

spotted today:
code:
foo.cc:100: error: no matching function call to 'CalcWhatever(float*&, float*&, float, float&, int&, int&, int&, float&, 
float&, float&, float&, float&, float&, float&, float&, std::vector<float, std::allocator<float> >&, 
std::vector<float, std::allocator<float> >&, float&, float&, float&, float&, int&, float&, float&, int&, float&, 
float&, float&, float&, float&, unaigned int&, unsigned int&, float&, int&)'

RussianManiac
Dec 27, 2005

by Ozmaugh

BigRedDot posted:

spotted today:
code:
foo.cc:100: error: no matching function call to 'CalcWhatever(float*&, float*&, float, float&, int&, int&, int&, float&, 
float&, float&, float&, float&, float&, float&, float&, std::vector<float, std::allocator<float> >&, 
std::vector<float, std::allocator<float> >&, float&, float&, float&, float&, int&, float&, float&, int&, float&, 
float&, float&, float&, float&, unaigned int&, unsigned int&, float&, int&)'

what the gently caress is CalcWhatever? is there an actual signature for it? what is it supposed to do?

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

BigRedDot posted:

spotted today:
code:
foo.cc:100: error: no matching function call to 'CalcWhatever(float*&, float*&, float, float&, int&, int&, int&, float&, 
float&, float&, float&, float&, float&, float&, float&, std::vector<float, std::allocator<float> >&, 
std::vector<float, std::allocator<float> >&, float&, float&, float&, float&, int&, float&, float&, int&, float&, 
float&, float&, float&, float&, unaigned int&, unsigned int&, float&, int&)'

The biggest shock is that the couple of templates that are involved there are not the reason that error message is a horror.

deedee megadoodoo
Sep 28, 2000
Two roads diverged in a wood, and I, I took the one to Flavortown, and that has made all the difference.


I'm not going to post the code, but this description is painful enough:

We have a SOAP service that accepts one argument... strXML. Whoever wrote this thing didn't really understand why you would want to use a webservice. Instead of just connecting via a client of my choice and calling the method remotely with a few arguments, I have to go look up API documentation to remember what methods are exposed by this service and then generate an XML document to pass as my argument... which in turn gets encapsulated in XML. Good job, developer.

No Safe Word
Feb 26, 2005

BigRedDot posted:

spotted today:
code:
foo.cc:100: error: no matching function call to 'CalcWhatever(float*&, float*&, float, float&, int&, int&, int&, float&, 
float&, float&, float&, float&, float&, float&, float&, std::vector<float, std::allocator<float> >&, 
std::vector<float, std::allocator<float> >&, float&, float&, float&, float&, int&, float&, float&, int&, float&, 
float&, float&, float&, float&, unaigned int&, unsigned int&, float&, int&)'

What is an unaigned int ??

Presto
Nov 22, 2002

Keep calm and Harry on.

No Safe Word posted:

What is an unaigned int ??
An off-by-one error. :v:

king_kilr
May 25, 2007

Presto posted:

An off-by-one error. :v:

's' - 'a' != 1

csammis
Aug 26, 2003

Mental Institution

king_kilr posted:

's' - 'a' != 1

holy loving poo poo

Sneaking Mission
Nov 11, 2008

king_kilr posted:

's' - 'a' != 1

Look at this guy here

Mill Town
Apr 17, 2006

csammis posted:

holy loving poo poo

Perhaps king_kilr is German.

king_kilr
May 25, 2007
code:
#include <stdio.h>

int main() {
    printf("%d\n", 's' -  'a');
}
Hey screw you guys, it's legal C code.

Sapozhnik
Jan 2, 2005

Nap Ghost
Not so much code but the amount of people we see interviewing for our team who can't describe any sorting algorithms other than perhaps bubble sort and think that searching an ordered array takes O(sqrt(n)) time (or sometimes O(1/2 n) time) is pretty depressing

It's also quite frightening when most of these people have decades of experience on their CV. Obviously a cursory examination of the internet suggests that these people are pretty much the bottom of the barrel, so why aren't we getting anything better than this?

FWIW this is investment banking, so I assume the pay being offered is pretty competitive.

Opinion Haver
Apr 9, 2007

king_kilr posted:

code:
#include <stdio.h>

int main() {
    printf("%d\n", 's' -  'a');
}
Hey screw you guys, it's legal C code.

look at your keyboard

BigRedDot
Mar 6, 2008

Mr Dog posted:

O(1/2 n)
LOL Except those optimized versions that run in O(1/2) !

Also an unaigned int is what you get when you have to type that much crap by hand because the dev box is airgapped.

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug

BigRedDot posted:

LOL Except those optimized versions that run in O(1/2) !

Also an unaigned int is what you get when you have to type that much crap by hand because the dev box is airgapped.

I've seen someone use the term O(0). That must be a pretty drat efficient algorithm.

king_kilr
May 25, 2007

yaoi prophet posted:

look at your keyboard

oh...

I don't want to talk about it, mine's still sort of funny thought... right? :suicide:

FSMC
Apr 27, 2003
I love to live this lie

Mr Dog posted:

Not so much code but the amount of people we see interviewing for our team who can't describe any sorting algorithms other than perhaps bubble sort and think that searching an ordered array takes O(sqrt(n)) time (or sometimes O(1/2 n) time) is pretty depressing

It's also quite frightening when most of these people have decades of experience on their CV. Obviously a cursory examination of the internet suggests that these people are pretty much the bottom of the barrel, so why aren't we getting anything better than this?

FWIW this is investment banking, so I assume the pay being offered is pretty competitive.

I assume it's because HR screened everyone first. Ensuring team work and communication skills triumphs IT skills

FSMC fucked around with this message at 10:31 on Nov 7, 2009

Mikey-San
Nov 3, 2005

I'm Edith Head!

Mr Dog posted:

why aren't we getting anything better than this?

this is investment banking

blueberrypudding
Sep 3, 2009
I'm working on a tile-based project with someone else, and they were doing the code for calculating the coordinates of the tile the mouse is over when you press the button.

He had a huge series of if statements using the coordinates of the mouse to find the correct row and then column.

I don't think he was happy when I replaced 500 lines of his code with 5 of mine.

GROVER CURES HOUSE
Aug 26, 2007

Go on...

blueberrypudding posted:

I'm working on a tile-based project with someone else, and they were doing the code for calculating the coordinates of the tile the mouse is over when you press the button.

He had a huge series of if statements using the coordinates of the mouse to find the correct row and then column.

I don't think he was happy when I replaced 500 lines of his code with 5 of mine.

So what exactly did those 500 lines do? I don't think I could write 500 lines for something that simple even if I tried. :psyduck:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Broken Knees Club posted:

So what exactly did those 500 lines do? I don't think I could write 500 lines for something that simple even if I tried. :psyduck:

if(x<=10) tilex=0;
else if(x<=20) tilex=1;


And so on. It's not that hard.

blueberrypudding
Sep 3, 2009

Broken Knees Club posted:

So what exactly did those 500 lines do? I don't think I could write 500 lines for something that simple even if I tried. :psyduck:

code:
if (_xmouse>=0 && _xmouse<10) {
 col=0;
} else if (_xmouse>=10 && _xmouse<20) {
 col=1;
} else if (...
Looking back now I think I was exaggerating slightly (ok then, quite a lot). The whole thing he wrote was about 500 lines and this was one of the inefficiencies. So it's probably more like 60 lines to 5.

GROVER CURES HOUSE
Aug 26, 2007

Go on...

blueberrypudding posted:

code:
if (_xmouse>=0 && _xmouse<10) {
 col=0;
} else if (_xmouse>=10 && _xmouse<20) {
 col=1;
} else if (...
Looking back now I think I was exaggerating slightly (ok then, quite a lot). The whole thing he wrote was about 500 lines and this was one of the inefficiencies. So it's probably more like 60 lines to 5.

He hardcoded it?! :suicide:

Please tell me he used constants and did not actually write out _xmouse>=10.

blueberrypudding
Sep 3, 2009

Broken Knees Club posted:

He hardcoded it?! :suicide:

Please tell me he used constants and did not actually write out _xmouse>=10.

I just had a look and it's actually 200 lines, and he didn't quite write it out. It makes me cringe to see this!

code:
tw = 30;// tilewidth
	i = 30;
	if (_xmouse<i+xoffset) {
		who._x = xoffset+(i-tw);
		thiscol = 1;
	}
	// then we're near column 1  
	if (_ymouse<i+yoffset) {
		who._y = yoffset+(i-tw);
		thisrow = 1;
	}
	// then we're near row 2  
	i = 60;
	if (_xmouse<i+xoffset+1 && _xmouse>((i+xoffset)-tw)) {
		who._x = xoffset+(i-tw);
		thiscol = 2;
	}
	// then we're near column 2  
	// and this line equates to: if x < 81 and x > 20.. then go ahead and decide the position.
	if (_ymouse<i+yoffset+1 && _ymouse>((i+yoffset)-tw)) {
		who._y = yoffset+(i-tw);
		thisrow = 2;
	}
etc.
God I hope he's not a goon.

GROVER CURES HOUSE
Aug 26, 2007

Go on...
Oh my god it's actually worse. :psypop:

e: it just hit me that he's using a ton of if clauses and not if else. So every time this runs, everything has to be evaluated even if you already found your position. Also the variable i is freaking me out. And the fact that you have two variables called thiscol and thisrow.

You have to post the whole thing.

ErIog
Jul 11, 2001

:nsacloud:
Eh, if the guy isn't a hobbyist then it's a complete nightmare-level horror. I say cut the guy some slack. We all had to be that guy at some point in our learning of computer programming.

What makes a coding horror to me is really based on how many years of school the person who wrote the code had, how many years of prior experience, and how much he got paid to write said code. If all of those are close to 1 or zero, then c'mon, how much can you really expect? There's also bonus points if the code is already used in production somewhere, and double bonus if it could kill people due to a bug.

ErIog fucked around with this message at 23:33 on Nov 7, 2009

GROVER CURES HOUSE
Aug 26, 2007

Go on...

ErIog posted:

Eh, if the guy isn't a hobbyist then it's a complete nightmare-level horror. I say cut the guy some slack. We all had to be that guy at some point in our learning of computer programming.

What makes a coding horror to me is really based on how many years of school the person who wrote the code had, how many years of prior experience, and how much he got paid to write said code. If all of those are close to 1 or zero, then c'mon, how much can you really expect? There's also bonus points if the code is already used in production somewhere, and double bonus if it could kill people due to a bug.

Well blueberry did say that it's a tile-based project, so it's probably a hobby or possibly an assignment. But still, I'm a newbie, started programming from absolute zero about six months ago, have never written a line of C/C++ in my life and can still avoid writing that sort of code. I mean, if you see a ton of ifs like that and do not immediately think of a loop, then it's a logic problem, not a programming horror.

I completely agree with your second statement though.

markerstore
Dec 5, 2003
Canny!

Broken Knees Club posted:

Well blueberry did say that it's a tile-based project, so it's probably a hobby or possibly an assignment. But still, I'm a newbie, started programming from absolute zero about six months ago, have never written a line of C/C++ in my life and can still avoid writing that sort of code. I mean, if you see a ton of ifs like that and do not immediately think of a loop, then it's a logic problem, not a programming horror.

I completely agree with your second statement though.

Hahahaha a LOOP?

mr_jim
Oct 30, 2006

OUT OF THE DARK

markerstore posted:

Hahahaha a LOOP?

I don't get it either. A simple calculation would do.

GROVER CURES HOUSE
Aug 26, 2007

Go on...

markerstore posted:

Hahahaha a LOOP?

Yes? You can collapse all of those ifs into a loop and have it do the same thing. Obviously it's the Wrong Way but it should be obvious even for a total newbie.

As an aside, I also made a tile-based project. It did not have loops. :colbert:

mr_jim
Oct 30, 2006

OUT OF THE DARK

Broken Knees Club posted:

Yes? You can collapse all of those ifs into a loop and have it do the same thing. Obviously it's the Wrong Way but it should be obvious even for a total newbie.

As an aside, I also made a tile-based project. It did not have loops. :colbert:

If you see a ton of if statements like that, and your first impulse is to replace them with a loop, then you're fixing the wrong problem. And you're probably just making things even less clear than they were before.

Seth Turtle
May 6, 2007

by Tiny Fistpump

markerstore posted:

Hahahaha a LOOP?

http://thedailywtf.com/Articles/The_FOR-CASE_paradigm.aspx

GROVER CURES HOUSE
Aug 26, 2007

Go on...

mr_jim posted:

If you see a ton of if statements like that, and your first impulse is to replace them with a loop, then you're fixing the wrong problem. And you're probably just making things even less clear than they were before.

Yes, that is exactly what I said.

raminasi
Jan 25, 2005

a last drink with no ice

Broken Knees Club posted:

Yes, that is exactly what I said.

How are "It should occur to you to replace them with a loop" and "It should not occur to you to replace them with a loop" the "exact" same things?

Khorne
May 1, 2002

blueberrypudding posted:

I just had a look and it's actually 200 lines, and he didn't quite write it out. It makes me cringe to see this!

code:
tw = 30;// tilewidth
	i = 30;
	if (_xmouse<i+xoffset) {
		who._x = xoffset+(i-tw);
		thiscol = 1;
	}
	// then we're near column 1  
	if (_ymouse<i+yoffset) {
		who._y = yoffset+(i-tw);
		thisrow = 1;
	}
God I hope he's not a goon.
Wouldn't those ifs always evaluate to true because it's a check if something<i and then adding a number? I guess it depends on the language. I still have no idea how he didn't think of the obvious solution. Something like this, although I'm not sure how accurate it is because I didn't look past the first if set because I got tired of following the variable names and redundant stuff. For the record, I've never been paid or studied programming.

code:
tw=30;

x_col=_xmouse/tw;  //Depending on language/variable type you'd have to floor it
y_row=_ymouse/tw;

who._x=xoffset+x_col*tw;
who._y=yoffset+y_row*tw;

thiscol=x_col+1;
thisrow=y_row+1;

Adbot
ADBOT LOVES YOU

mr_jim
Oct 30, 2006

OUT OF THE DARK

GrumpyDoctor posted:

How are "It should occur to you to replace them with a loop" and "It should not occur to you to replace them with a loop" the "exact" same things?

I don't know. I give up.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply