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
Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Often, the source of these horrors is someone trying to do something brilliant, even proper, but not knowing or having a succint/correct way of expressing it.

Adbot
ADBOT LOVES YOU

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
These things, as Perl programmer, piss me off:
code:
@stack = ();
for ($i = 0; $i < scalar @elements; $i++) {
  $temporary = do_something_to $elements[$i];

  push @stack, $temporary;
}
It's abundantly clear this person doesn't know about scope, the context-sensitive return value of an array, foreach loops, and map. God drat.
code:
print HANDLE "This one also demonstrates something else.";
print HANDLE "This programmer doesn't know how to use select.";
print HANDLE "Nor does he know what a heredoc is.";
print HANDLE "You get paragraphs of text that look like this.";
print HANDLE "For no reason, really.";
Point is, for you non-Perl folk, is that this poo poo could have been written in a more concise, more native-to-Perl fashion.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Kidane posted:

code:
my $parse_mail = Email::Simple -> new( $email );
my $sender = $parse_mail -> header( "From" );
my $jira_summary = $parse_mail -> header( "Subject" );
my $jira_description = $parse_mail -> body;
I know of the more Perl-like way to write that, I just don't care.

Then you're no friend of mine. :colbert: There's a difference between being concise and golfing (which Perl folk love to do) and this isn't golfing. The entire field of computer science has been about a power versus concision payoff. And if you can't see that, then you're hopeless.
code:
my $parse_mail       = new Email::Simple($email);
my $sender           = $parse_mail->header('From');
my $jira_summary     = $parse_mail->header('Subject');
my $jira_description = $parse_mail->body;

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
As written, that is an improper use of map, philosophically.
code:
# reassignment
munge_and_set($_) for @elements;

# side-effect free
my @new_elements = map { munge($_) } @elements;

# side-effect free in void context
map { munge($_) } @elements;

# works but is bad form, equivalent to first example
map { munge_and_set($_) } @elements;
Edit: The philosophical part here is... When you use for, you're addressing a copy of each element and doing something with it in an iterative context. When you use map, you're multiplying each element functionally. The return value could be more than one element, the same element, a different element, or an empty list, for each element. And that gets returned. Traditionally inside of a map or a for, you don't want to be reassigning values. If you want, you can assign the list the value of the same list mapped over.
code:
# be reborn, list!
@list = map { transform($_) } @list;

Triple Tech fucked around with this message at 14:58 on Apr 4, 2008

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
If this_returns_an_array contains no side effects to the variables submitted, then both of those do nothing. They're void context. In the first one, the fact that it returns something doesn't even matter. You can't capture the output of a loop when it's written like that. In the second scenario, you're just missing the left side of the assignment. my @array = that expression. It's returning an array for each element in the elements list, and then jamming all of that into one long array, and then that array isn't going anywhere. Again, void context.

For loops never get assigned to something. Maps should always be either assigned to something or chained to another process, like a function's input, or the list input to a sort or grep.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
It pisses me off that people don't audit their poo poo and stuff like this comes up.

90% of all the bugs I've had to deal with regarding inherited/maintained code is lack of auditing.

Code that makes me cry is code without an audit history/trail.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

rotor posted:

I am very, very sorry


(for posting this scandalous pic of tripletech, lol)

hott, $temp->rising

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Chain Chomp posted:

I wonder how many NULLs are in that table. That is probably one of the most sparse tables ever created.

IS_FLAG, IS_NOT_FLAG

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Here's a coding horror, buttbot! :rimshot: (:glomp:)

Zakalwe posted:

there's nothing wrong with using the occasional goto

Zakalwe posted:

the occasional goto

Zakalwe posted:

occasional goto

Zakalwe posted:

BOOK DEPOSITORY

:siren: You heard it here first, folks, liberal use of goto endorsed by professional programmers!

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Why does it wind you up? Because some_variable evaluates to true?

Aren't there programming languages that only accept the boolean data type instead of a free form expression? If it was a language like that then that sort of construction would be necessary.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Ample worry (self awareness?) is step one on your journey to not being here. If at any time you thought "my code looks like this" or "that looks like a good idea", then you should be really worried.

Why not quote a post you don't understand and ask for clarification? I'm sure at least one goon won't be able to restrain himself and will wow us with his knowledge of The Right Way.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Lone_Strider posted:

"well I'm just making sure"

aka "I can't be bothered to learn something new or correct my gross misunderstanding of something."

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
svn blame these gems and tell us more about who wrote them.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
At first I was with you. But I can count at least three strikes against Perl. The function, the param, and the echo. And no my, how dare they.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Decipher with blame logs.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Degrees don't mean poo poo! I wonder what their thought process was that using regexp validation, which is infinitely more robust, was somehow worth less than "multiplying something by one"? Geniuses at work, people.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
There could be more genders, like null or pirate.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

DaTroof posted:

In an application for a county's department of animal control, there was a table for pets' genders that contained Male, Female, Spayed, and Neutered. It seemed reasonable enough until they started using it for the owner's gender, too.

Coding horror, shoe-horning a semantically different concept into an existing framework that isn't properly built to address it. Classic.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

shrughes posted:

Codepadded into #cobol:

code:
  for (int b=a; a>0; a--)
  {
    cout << a << "\n";
    myfile << a << "\n";

  } while (a > 0);

I don't get it, what exactly am I looking at? Is it a for loop or a while loop?

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Munkeymon posted:

Can't figure out whay that popped into my head - I certianly don't like PERL that much.

Perl. Perl. Do you go around saying poo poo like JAVA or RUBY? <:mad:>

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
my function is more optimized than your function, good thing we namespaced them, use mine

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
code:
my @originals = ...;

# copied
my @modified_duplicates = map { frobnicate($_) } @originals;

# "in-place"
@originals = map { frobnicate($_) } @originals;

# in-place (ugly)
$_ = frobnicate($_) for @originals;
It's terse, perlish, parallelizable, and makes great julienned fries!

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Ugg boots posted:

You really like the word frobnicate, don't you? Also I liked your old avatar better.

Frobnicate is some old geezer word I got used to. What other word would you use in examples?

I liked it better also... :(

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
So, what's it trying to do? It's too verbose...

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Some "developers" don't know of platform agnostic interfaces to system commands...

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Get bent, use a REAL editor with indented wrapping...

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Zombywuf posted:

What you need is Perl 6.

He asked for a real language. :smug:

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Janin posted:

What is it about REST that gets people so confused? It doesn't seem like a difficult concept, but then I see "RESTful" APIs designed like this:


Is it too much to ask that a user of some architecture actually *read* the paper in which that architecture was defined?

Could you repost those examples on how it should be done? I'm curious and I don't quite understand REST.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

TSDK posted:

I'm doWhat'ing fine,s con thankcurreyou for asking.ncy?

Oh hilarity. :neckbeard:

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I can't really think of a good way to select multiple objects by ID in SQL. Granted, it looks a little funny because there are lots of IDs in that particular query... But really, what else are you supposed to do? I figure, maybe insert the IDs into an indexed temporary table of one column and then run a join against that? How much faster could that be.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Ehh, that's just a debug function. But if you look real close, you'll see that there's also a wierdness function. Even the subject line of the mail message takes that as the canonical spelling...

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I sympathize with some (not really) of them. Sometimes I write a simple interface and document what's missing. Then I change the interface but ignore the nearby comments. Now the comments sound crazy, referring to things that don't exist but are sort of kind of related.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I'm thinking it's not an actual job posting, just an elaborate troll. How could anyone take themselves seriously after asking for all that?

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

tripwire posted:

I was looking through some of those "fail"s and couldn't figure out how one of them was getting this text it operates on:

That's interesting. Is it reading its own prompt?

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
That's awesome, did you do that yourself or use a program?

Adbot
ADBOT LOVES YOU

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Maybe it was code in transition. Better than before, but still clearly not the best. Mini commits, mini gains...

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