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
A very bad man
Mar 31, 2010

Zombywuf posted:

Are any of the views materialized?

Nope.

Adbot
ADBOT LOVES YOU

BigRedDot
Mar 6, 2008

A very bad man posted:

EDIT: I considered posting the code but it's will make you bleed from the eyes.
That's what we come here for....

Lurchington
Jan 2, 2003

Forums Dragoon
Not so much a coding horror, but after seeing it on the official (although internal) system visualization documentation/presentations, I'm shaking my head. I had nothing to do with it.

There's a daemon process that watches for events and does stuff. Not too complicated, but imagine a visio with a bunch of web servers here, a bunch of database there, the occasional cloud of things, and with arrows going to and from, THIS in glorious retarded glory:

Only registered members can see post attachments!

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Lurchington posted:

Not so much a coding horror, but after seeing it on the official (although internal) system visualization documentation/presentations, I'm shaking my head. I had nothing to do with it.

There's a daemon process that watches for events and does stuff. Not too complicated, but imagine a visio with a bunch of web servers here, a bunch of database there, the occasional cloud of things, and with arrows going to and from, THIS in glorious retarded glory:



I would love to work in such a zany place :D

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
At least you don't have to look at at that abomination combined with some anime quote every time you post.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

Mustach posted:

Maybe it's out of habit from calling ToString() on everything else. Who needs any other data type? Strings are simple and easy to understand!

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.

But you still have to explicitly declare your variables as strings JUST TO MAKE SURE.

NotShadowStar
Sep 20, 2000

Monkeyseesaw posted:

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.

But you still have to explicitly declare your variables as strings JUST TO MAKE SURE.

Sweet we're back to the Perl debate.

PhonyMcRingRing
Jun 6, 2002

Monkeyseesaw posted:

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.

But you still have to explicitly declare your variables as strings JUST TO MAKE SURE.

That should be easy enough to tack on to Javascript.

Opinion Haver
Apr 9, 2007

Lurchington posted:

Not so much a coding horror, but after seeing it on the official (although internal) system visualization documentation/presentations, I'm shaking my head. I had nothing to do with it.

There's a daemon process that watches for events and does stuff. Not too complicated, but imagine a visio with a bunch of web servers here, a bunch of database there, the occasional cloud of things, and with arrows going to and from, THIS in glorious retarded glory:



The true horror is that this is a jpg.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Monkeyseesaw posted:

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.
Let me tell you about bash…

Zhentar
Sep 28, 2003

Brilliant Master Genius

Monkeyseesaw posted:

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.

But you still have to explicitly declare your variables as strings JUST TO MAKE SURE.

Replace the new command with string and MUMPS is effectively there.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Monkeyseesaw posted:

We need a language where the only data type is a string and when you do non-string operations like arithmetic it converts it to some internal representation, does the bit shuffling, and returns the result as a string. All functions are simply extending the string type.

But you still have to explicitly declare your variables as strings JUST TO MAKE SURE.

I think this is how Tcl works

PhonyMcRingRing
Jun 6, 2002
BlogEngine.NET's javascript library is littered with this kind of crap. I'm sure glad they managed to parse that date three times.

code:
function formatJSONDate(jsonDate) {
   var date = new Date(parseInt(jsonDate.substr(6), 10));
   var parsedDate = Date.parse(date);
   var d = new Date(parsedDate);
   var m = d.getMonth() + 1;
   var s = m + "/" + d.getDate() + "/" + d.getFullYear();
  
   if(s == "1/1/1001") {
      return "";
   } else {
      return s;
   }
}

_aaron
Jul 24, 2007
The underscore is silent.

PhonyMcRingRing posted:

BlogEngine.NET's javascript library is littered with this kind of crap. I'm sure glad they managed to parse that date three times.

code:
function formatJSONDate(jsonDate) {
   var date = new Date(parseInt(jsonDate.substr(6), 10));
   var parsedDate = Date.parse(date);
   var d = new Date(parsedDate);
   var m = d.getMonth() + 1;
   var s = m + "/" + d.getDate() + "/" + d.getFullYear();
  
   if(s == "1/1/1001") {
      return "";
   } else {
      return s;
   }
}
jesus christ.

I don't really have a horror, but I'm tired of seeing SVN check-ins where the diff is nothing but extra blank lines. No, we didn't really need three blank lines between the end of the else statement and the end of the method.

ColdPie
Jun 9, 2006

_aaron posted:

I don't really have a horror, but I'm tired of seeing SVN check-ins where the diff is nothing but extra blank lines. No, we didn't really need three blank lines between the end of the else statement and the end of the method.

What's the commit message?

_aaron
Jul 24, 2007
The underscore is silent.

ColdPie posted:

What's the commit message?
It's typically part of a bug fix where they changed another file, so the message is for the file where the code actually changed. It's like when they commit a fix, they just commit any changed files without doing a diff beforehand (which is probably the real horror).

A very bad man
Mar 31, 2010

_aaron posted:

It's typically part of a bug fix where they changed another file, so the message is for the file where the code actually changed. It's like when they commit a fix, they just commit any changed files without doing a diff beforehand (which is probably the real horror).

For some reason all the commits made from branches when merged are blank on the trunk in the project I'm working on. So you end up with comments from the merge, but an commits on the branch will be empty. Sucks.

xarph
Jun 18, 2001


CPAN posted:

(38 subtests UNEXPECTEDLY SUCCEEDED), 1 test and 161 subtests skipped.

CPAN: greybeards with ailments running slackware 3.1

Edit: and now to punish us for using 'force' it is rebuilding and re-running all the tests

Thel
Apr 28, 2010

We have a login field stored in a CHAR(50) field (i.e. packed out with spaces), which needs to be compared to a different login stored in a VARCHAR(50) field.

Contractor's response: write a function in JavaScript as follows:

code:
Stuff.rtrim = function(s) {
  s = s.replace(/^\s+/, '');
  for (var i = s.length - 1; i >= 0; i--) {
    if (/\S/.test(s.charAt(i))) {
      s = s.substring(0, i + 1);
      break;
    }
  }
  return s;
}
Trivia quiz: What do you think this function does?

Double bonus: What was said contractor trying to do?

1: As far as I can tell, sweet gently caress all. Any string passed to it goes through it untouched - I don't get it either - unless my javascript is horribly broken. Looking at the code it should theoretically remove any non-space characters, then trim the last space off the string - but my regex-fu is weak.
2: gently caress knows. Since the only place he uses this string is right after he pulls the field from an SQL statement, calling RTRIM in that statement would've been far simpler.


Triple bonus: I write "JavaScript" + ":" and the forum puts a space between "Java" and "Script" and lowercases it, but not if I leave the colon off the end. Why? Never mind, I'm an idiot :downs:.

Thel fucked around with this message at 00:58 on Oct 14, 2010

ToxicFrog
Apr 26, 2008


^^ I haven't run it, but from a cursory reading it looks like it should work; here's an annotated version.

code:
// trim leading and trailing whitespace from a string
Stuff.rtrim = function(s) {
  s = s.replace(/^\s+/, ''); // trim leading whitespace
  for (var i = s.length - 1; i >= 0; i--) { // scan backwards through the string
    if (/\S/.test(s.charAt(i))) { // as soon as you hit a non-whitespace character...
      s = s.substring(0, i + 1); // slice off the rest of the string and break
      break;
    }
  }
  return s;
}
Granted, I'm not sure why you would do it this way when you can replace it with:
code:
function(s) { return s.replace(/^\s+/, '').replace(/\s+$/, '') }

Thel
Apr 28, 2010

Regex-fu status: downgraded from "weak" to "broken". :downs:

qntm
Jun 17, 2009

ToxicFrog posted:

code:
  s = s.replace(/^\s+/, ''); // trim leading whitespace

Except this doesn't work, because outside of a pair of square brackets, the ^ metacharacter isn't "negation", it matches the end of the string. So /^\s+/ will match nothing. I think what's needed is either /[^\s]+/ or /\S+/.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

qntm posted:

Except this doesn't work, because outside of a pair of square brackets, the ^ metacharacter isn't "negation", it matches the end of the string. So /^\s+/ will match nothing. I think what's needed is either /[^\s]+/ or /\S+/.

^ is the start, $ is the end

e: so it's "the start of the string, followed by 1 or more whitespace"

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



ToxicFrog posted:

^^ I haven't run it, but from a cursory reading it looks like it should work; here's an annotated version.

But it's called rtrim, so even though it actually does trim the string 'correctly'*, it trims from both sides and so is broken.

*http://www.squarefree.com/shell/shell.html is great for testing small chunks of JavaScript.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
This is why regexes themselves are the coding horror.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Monkeyseesaw posted:

This is why regexes themselves are the coding horror.

No way. Regular expressions are good tools. The coding horror is people using them to solve every problem relating to string processing they encounter.

NotShadowStar
Sep 20, 2000
Is this where we bring up parsing HTML with a regular expression again?

musclecoder
Oct 23, 2006

I'm all about meeting girls. I'm all about meeting guys.

NotShadowStar posted:

Is this where we bring up parsing HTML with a regular expression again?

Nope, it's where we post the link to that Perl regex for validating emails.

Lysandus
Jun 21, 2010
This isn't so much a horror, as it just bugs me.

code:
HttpHeaders.HEADER_ACCEPT_ENCODING
Isn't
code:
HttpHeaders.ACCEPT_ENCODING

enough? :confused:

Mr.Radar
Nov 5, 2005

You guys aren't going to believe this, but that guy is our games teacher.

Lysandus posted:

This isn't so much a horror, as it just bugs me.

code:
HttpHeaders.HEADER_ACCEPT_ENCODING
Isn't
code:
HttpHeaders.ACCEPT_ENCODING

enough? :confused:

If that code is from a library for a high-level language (e.g. Python) which is wrapping a C library it's probably named like that because that's what the C constant was named.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

TRex EaterofCars posted:

No way. Regular expressions are good tools. The coding horror is people using them to solve every problem relating to string processing they encounter.

I'm being facetious. Regexes are obviously extremely useful but it's remarkable how much trouble people have with them unless you're working with them literally every day. If you were trying to invent a syntax that was scientifically designed to be impossible to remember or keep in your head at once you couldn't do much worse than the standard regex syntax. It's like something invented by an evil robot.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Monkeyseesaw posted:

I'm being facetious. Regexes are obviously extremely useful but it's remarkable how much trouble people have with them unless you're working with them literally every day. If you were trying to invent a syntax that was scientifically designed to be impossible to remember or keep in your head at once you couldn't do much worse than the standard regex syntax. It's like something invented by an evil robot.

APL wins that particular award I think.

A very bad man
Mar 31, 2010

Monkeyseesaw posted:

I'm being facetious. Regexes are obviously extremely useful but it's remarkable how much trouble people have with them unless you're working with them literally every day. If you were trying to invent a syntax that was scientifically designed to be impossible to remember or keep in your head at once you couldn't do much worse than the standard regex syntax. It's like something invented by an evil robot.

No wonder Larry Wall gets hard over them.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

A very bad man posted:

No wonder Larry Wall gets hard over them.

What are you tolkien aboot http://dev.perl.org/perl6/doc/design/apo/A05.html

tef
May 30, 2004

-> some l-system crap ->

Monkeyseesaw posted:

I'm being facetious. Regexes are obviously extremely useful but it's remarkable how much trouble people have with them unless you're working with them literally every day. If you were trying to invent a syntax that was scientifically designed to be impossible to remember or keep in your head at once you couldn't do much worse than the standard regex syntax. It's like something invented by an evil robot.

but regular expressions only have disjunction (a|b) conjunction (ab) and the kleene star (a*) what is so hard about that -- besides I don't get how people talk about parsing html with regular expressions because html isn't regular :confused:

I mean how is a formal language a coding horror

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Larry's comment is strangely appropriate for your question. It's a horror because people don't bother to learn anything about it.

http://dev.perl.org/perl6/doc/design/apo/A05.html posted:

This is the Apocalypse on Pattern Matching, generally having to do with what we call "regular expressions", which are only marginally related to real regular expressions. Nevertheless, the term has grown with the capabilities of our pattern matching engines, so I'm not going to try to fight linguistic necessity here. I will, however, generally call them "regexes" (or "regexen", when I'm in an Anglo-Saxon mood).

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

Otto Skorzeny posted:

What are you tolkien aboot http://dev.perl.org/perl6/doc/design/apo/A05.html
It's things like this that remind me that Larry Wall actually has a good head on his shoulders.

tef
May 30, 2004

-> some l-system crap ->

Mustach posted:

It's things like this that remind me that Larry Wall actually has a good head on his shoulders.

if only he hadn't spent the last 10 years working on the second system perl

tef
May 30, 2004

-> some l-system crap ->

Monkeyseesaw posted:

It's like something invented by an evil robot.

http://en.wikipedia.org/wiki/Malbolge

Adbot
ADBOT LOVES YOU

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

tef posted:

if only he hadn't spent the last 10 years working on the second system perl
Touché.

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