News for hackers. Stuff that matters.
Re:A Soccer Con Man Who Couldn't Play the Game by the_cat_kittles on Monday August 22, 2016 @05:00PM (#12339400)
former js coworker: "i cant populate that dropdown with the results of an ajax request because everything is 'async' in javascript"
Re:A Soccer Con Man Who Couldn't Play the Game by ctvo on Monday August 22, 2016 @06:07PM (#12339805)
Current co-worker, a contractor, on a remote project wrote 1000+ lines of JS to load a JSON file in Node (he didn't realize he could just require it).
Re:A Soccer Con Man Who Couldn't Play the Game by syntheticnature on Monday August 22, 2016 @06:12PM (#12339835)
While playing with Node as someone new to JS at the time, I wrote some code to load a JSON file due to not knowing I could require it... and it was vastly less than 1000+ lines.

On a similar basis, I once worked on a codebase where someone had implemented strftime, poorly, a few different ways, and also come up with several replacements for strptime, all of which had subtle bugs and none of which worked the same.

Re:A Soccer Con Man Who Couldn't Play the Game by jeffdavis on Tuesday August 23, 2016 @02:59AM (#12341893)
Both of your examples describe people who can code.

Given only the information you provided, I would hesitate to mock them, for fear they might make something really cool.

Re:A Soccer Con Man Who Couldn't Play the Game by kazinator on Monday August 22, 2016 @07:14PM (#12340108)
Though strftime is in ISO C, so there is little excuse, strptime is a POSIX function, so there is at least the possibility of a credible portability argument there. (Though this probably doesn't stretch far enough to justify the lack of an #ifdef to select the system's strptime if it is provided.)
Re:A Soccer Con Man Who Couldn't Play the Game by syntheticnature on Monday August 22, 2016 @09:19PM (#12340653)
In this particular case the application was already quite POSIX-dependent in other ways, but it's a good point to make -- I did hesitate before deciding on it for that reason, now that you remind me.

To add additional details, for those who might draw amusement and/or wisdom: In all cases the input/output date/time strings had the same format. Further, a number of the bugs were due to half-implemented reinventions of atoi being involved -- and atoi was definitely available, as one of the reinventions used it! Finally, in at least one case there was a Y2100 problem.

Re:A Soccer Con Man Who Couldn't Play the Game by MaulingMonkey on Tuesday August 23, 2016 @04:25AM (#12342189)
To be fair, I'd reroll atoi too - but only once, with "sufficient" unit tests (e.g. round trip unit tests for INT_MIN..INT_MAX), and only because atoi has no proper error checking nor wchar_t* variants.
Re:A Soccer Con Man Who Couldn't Play the Game by kazinator on Tuesday August 23, 2016 @06:32PM (#12348312)
Indeed; atoi in fact invokes undefined behavior in out of range situations; you can only safely use it when the input has been lexically analyzed to be a valid integer of only so many digits as not to overflow.

I'd tend to make this re-rolled atoi a wrapper around strtol/wcstol.

Re:A Soccer Con Man Who Couldn't Play the Game by MaulingMonkey on Wednesday August 24, 2016 @02:26AM (#12350117)
> atoi in fact invokes undefined behavior in out of range situations

Ouch! TIL. You'd think by now I wouldn't be surprised by such things, and yet, somehow I was...

Re:A Soccer Con Man Who Couldn't Play the Game by twblalock on Tuesday August 23, 2016 @02:20AM (#12341768)
On the other hand, if it worked, he could write a JSON parser, which most programmers cannot do.
Re:A Soccer Con Man Who Couldn't Play the Game by geon on Tuesday August 23, 2016 @10:09AM (#12343824)
I could forgive anyone for not knowing about requiring json files in node. It is kind of arcane.

But 1000 lines?

    var x = JSON.parse(fs.readFileSync('filename.json'));
Re:A Soccer Con Man Who Couldn't Play the Game by Mystrl on Monday August 22, 2016 @06:48PM (#12340005)
Huh neat I actually didn't know that.
Re:A Soccer Con Man Who Couldn't Play the Game by meowface on Tuesday August 23, 2016 @12:50AM (#12341477)
There must be something missing to that story. Even the most asinine way I can imagine doing that would be 50 lines max.

Did he try to write a complete JSON parser from scratch?