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
rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

TRex EaterofCars posted:

Yes but you'd run out of matter eventually. I feel dirty for how pedantic this is getting :(

Heh. That's clearly a limitation on a practical Turing machine, too — in fact, I seem to remember one of the fundamental papers addressing exactly this problem for Turing machines, although I can't find that section now.

There are models of computations requiring infinite simultaneous space, but I don't know much about them. Lenore Blum's work on real-number computability uses abstract operations on abstractly-represented numbers.

Adbot
ADBOT LOVES YOU

pseudopresence
Mar 3, 2005

I want to get online...
I need a computer!
http://www.codeproject.com/KB/dotnet/OptLocking_PrefixTable.aspx

code:
public object DeepCopy(object value)
{
    try
    {
        return value;
    }
    catch (Exception ex)
    {
        throw ex;
    }
}
Hmm.

Zombywuf
Mar 29, 2008

Fib posted:

code:
public object DeepCopy(object value)
{
    try
    {
        return value;
    }
    catch (Exception ex)
    {
        throw ex;
    }
}
Hmm.

code:
// FIXME: Implement DeepCopy

Ferg
May 6, 2007

Lipstick Apathy

Fib posted:

http://www.codeproject.com/KB/dotnet/OptLocking_PrefixTable.aspx

code:
public object DeepCopy(object value)
{
    try
    {
        return value;
    }
    catch (Exception ex)
    {
        throw ex;
    }
}
Hmm.

I seriously just came into this thread to post exactly this. A particularly in-your-face-cocky contractor we are hiring right now had about 8 or 9 catches that would just throw the exception right back up to the function that would handle it anyways. I deleted roughly 75 lines of code washing through the file I discovered it in.

SiCk
Jul 4, 2003

My name's SiCk, and I'm the Biggest Idiot Ever!
a night or two ago at 2am when i was extremely tired, i wrote this:

code:
<?php
$something = somefunction();
$count = count($something);

if($count > 0){
   print "($count)";
}else{
   print "(0)";
}

?>
sigh. :smith: i realised what i did in the morning.. though, in my defense, at least it worked.

mister_gosh
May 24, 2002

Triple Tech posted:

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.

Forgive me, some of my code may belong in here because I'm having trouble figuring out what is wrong with this code. There's an array of raw elements, they need to be post-processed (whatever do_something_to is) and then put into a new array.

Is it that the elements could have been taken care of (do_something_to) within the original array? Or am I on the wrong path?

slipped
Jul 12, 2001

mister_gosh posted:

Forgive me, some of my code may belong in here because I'm having trouble figuring out what is wrong with this code. There's an array of raw elements, they need to be post-processed (whatever do_something_to is) and then put into a new array.

Is it that the elements could have been taken care of (do_something_to) within the original array? Or am I on the wrong path?
Looking at the code screams of someone who is writing perl that does not know perl, but just enough to 'get by', which in turn leads to really lovely perl code. Guessing the person has a c/java background.

for instance, the above could have been rewritten as :
my @stack = map do_something_to, @elements;

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!

POKEMAN SAM
Jul 8, 2004

Triple Tech posted:

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!

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

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... :(

Munkeymon
Aug 14, 2003

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



Ugg boots posted:

You really like the word frobnicate, don't you?

At least it's something other than foo(bar).

gold brick
Jun 19, 2001

no he isn't
I just watched someone put hungarian notation on a public member of a class. :gonk:

Rapportus
Oct 31, 2004
The 4th Blue Man
I found this in some of my legacy code and couldn't help but laugh.

code:
## Lowercase these files just in case
# -- Let's not, perforce will hate us

PrBacterio
Jul 19, 2000

Mick posted:

I just watched someone put hungarian notation on a public member of a class. :gonk:

... I don't really see how that makes it any more or less bad than any other case of using hungarian notation? :confused:

mr_jim
Oct 30, 2006

OUT OF THE DARK

PrBacterio posted:

... I don't really see how that makes it any more or less bad than any other case of using hungarian notation? :confused:

If you use it privately, you're only hurting yourself, I guess.

gold brick
Jun 19, 2001

no he isn't

PrBacterio posted:

... I don't really see how that makes it any more or less bad than any other case of using hungarian notation? :confused:
Maybe it's just me. In any case, the intellisense over the events on that component looks like this now:

DataBinding
DataBound
Disposed
evtMyFooEvent
Init
Load
PageIndexChanged
PageIndexChanging
[etc.]

Vinterstum
Jul 30, 2003

Mick posted:

Maybe it's just me. In any case, the intellisense over the events on that component looks like this now:

DataBinding
DataBound
Disposed
evtMyFooEvent
Init
Load
PageIndexChanged
PageIndexChanging
[etc.]

Breaking with the existing code standard of the class is bad form, sure, but a coding horror?

Captain Cool
Oct 23, 2004

This is a song about messin' with people who've been messin' with you
I'm working with a variant of the Xerces XML library. After some analysis, I found that the program was spending 70% of its time getting the length of a list. Finally, I dug up the source code.
code:
// revisit
//   this implementation is too stupid - needs a cache of some kind.
//

XMLSize_t DOMNodeListImpl::getLength() const{
    XMLSize_t count = 0;
    if (fNode) {
        DOMNode *node = fNode->fFirstChild;
        while(node != 0){
            ++count;
            node = castToChildImpl(node)->nextSibling;
        }
    }

    return count;
}
It's been like that for at least ten years.

Maybe I should have expected something like that. But the only way I know of to get a NodeList is to call a function that returns it and, hey, getLength, that means they must store the length somewhere.

PrBacterio posted:

... I don't really see how that makes it any more or less bad than any other case of using hungarian notation? :confused:
Well, it means you're using public class members
half joke, don't fight

Captain Cool fucked around with this message at 20:51 on Apr 24, 2009

Zakalwe
May 12, 2002

Wanted For:
  • Terrorism
  • Kidnapping
  • Poor Taste
  • Unlawful Carnal Gopher Knowledge

Captain Cool posted:

Well, it means you're using public class members

Not necessarily a coding horror. Full encapsulation doesn't always make sense in the context of the problem.

I once had a friend who returned non-const references in getters argue against public class members. :psyduck:

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?

mr_jim posted:

If you use it privately, you're only hurting yourself, I guess.

It's one of those coding practices so stupid that we keep shooting its inventor into space.

dancavallaro
Sep 10, 2006
My title sucks
This speaks for itself:

http://stackoverflow.com/questions/791808/determining-whether-a-number-is-a-prime-number

HIERARCHY OF WEEDZ
Aug 1, 2005

Interviewed at a place, wanted to get a grip on the current website code. Found this in java script:

code:
function Login()
{
    if ('' == '')
    {
        SetAuthUrl('/foo');
        Show(); 
        return false;
    }
    else
    {
        document.location = '/foo';
    }
}
Whaaaaaaaaaaaaaaaaaaaaaa

ih8ualot
May 20, 2004
I like turkey and ham sandwiches

It's like he just kept adding constructs until he couldn't figure it out.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

A question so bad, even StackOverflow shits on it. :pwn:

j4cbo
Nov 1, 2004
huh?
λf. (λx. f (x x)) (λx. f (x x))

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

j4cbo posted:

λf. (λx. f (x x)) (λx. f (x x))

What's the problem here?

Vinterstum
Jul 30, 2003

Janin posted:

What's the problem here?

Lambda calculus is a horror in itself.

shrughes
Oct 11, 2008

(call/cc call/cc)

Vinterstum posted:

Lambda calculus is a horror in itself.

If you think lambda calculus is bad, try adding continuations.

code:
((call/cc call/cc) (lambda (f) (display "butt!") (newline) (f f)))

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Vinterstum posted:

Lambda calculus is a horror in itself.

Math :ohdear:

TheSpook
Aug 21, 2007
Spooky!

j4cb0 posted:

λf. (λx. f (x x)) (λx. f (x x))

After five minutes of trying to remember lambda calculus . . . can you explain this?

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

TheSpook posted:

After five minutes of trying to remember lambda calculus . . . can you explain this?

It's the fixed point function, also called the Y-Combinator.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

TheSpook posted:

After five minutes of trying to remember lambda calculus . . . can you explain this?

It's the Y combinator, it can be used to declare anonymous recursive functions.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

shrughes posted:

If you think lambda calculus is bad, try adding continuations.

code:
((call/cc call/cc) (lambda (f) (display "butt!") (newline) (f f)))

A cool thing is that call/cc is its own fixpoint. Gory details here

Mikey-San
Nov 3, 2005

I'm Edith Head!

Avenging Dentist posted:

A question so bad, even StackOverflow shits on it. :pwn:

Idea: Post code to Stack Overflow that was pulled from highly rated answers previously found on Stack Overflow, pretending it's yours. Ask for feedback.

"Is it possible for a turd to eat itself?"

The Evan
Nov 29, 2004

Apple ][ Cash Money

"I've set up a massive switch statement that consists of all the prime numbers up to 271"

He hard-coded a LUT for primes. Mother of god. Somewhere in my deep dark past, I recall reading an optimization suggestion that checking prime-ness is so easy computationally that making a table is a complete waste of memory, even ROM.

What made him stop at 271, anyway?

:psyboom:

Mikey-San
Nov 3, 2005

I'm Edith Head!
Everybody needs to vote that up.

Zombywuf
Mar 29, 2008

Advertisers, as we are all aware, are the abolute scum of the earth. I have to write code to talk to their web affiliate synergy leveraging networks. Basically this means sending users of our site to "URL"s like this:
code:
http://www.scumsuckingadvertiser.com/track?p1(DEADBEEF)p2(12345)url=http://www.example.com/some+other+url?with=a&bunch=of&other=params
Note the way they use param(value) instead of param=value, note that the passed through URL is only escaped once. Pay special attention to the way most browsers will try to fix this broken heap of poo poo so I have to write lovely code to stop them. For example:
code:
http://www.fuckwits.com/?DEADBEEF&url=http://www.example.com/?some=poo poo&goes=here
Given the chance, browsers may "correct" this to:
code:
http://www.fuckwits.com/?DEADBEEF=&url=http://www.example.com/%3Fsome=poo poo&goes=here
This will not work.

And each network is different, each with it's own lovely idea of what a URL is. Every time you have to guess what they intend you to do with this poo poo, and try to guess what they'll send use next week so the whole thing doesn't fall over when they send it.

Zombywuf fucked around with this message at 17:28 on Apr 28, 2009

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

The Evan posted:

"I've set up a massive switch statement that consists of all the prime numbers up to 271"

He hard-coded a LUT for primes. Mother of god. Somewhere in my deep dark past, I recall reading an optimization suggestion that checking prime-ness is so easy computationally that making a table is a complete waste of memory, even ROM.

What made him stop at 271, anyway?

:psyboom:

Whoooosh

oldkike
Jan 10, 2003

hey

www.pleasegimmeadollar.com
Saw a comment like this today:

code:
I know this violates the coding standards, but who cares anymore
Sad part is, this was new code in a new project, not some maintenance on existing garbage

Adbot
ADBOT LOVES YOU

awesmoe
Nov 30, 2005

Pillbug

oldkike posted:

Saw a comment like this today:

code:
I know this violates the coding standards, but who cares anymore
Sad part is, this was new code in a new project, not some maintenance on existing garbage

I feel for that guy. I found this in our c++ coding standards the other day

quote:

Class Data members are prefixed by \ ie (\foobarsStringDataMember)

just shows the attention and care that's been lavished upon that document.

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