Behold the power of doing nothing



  •  I'm sure this is old hat around these forums, but this is an example of how Perl in the X10 world is written:


    sub scrubInputLine($) {
        my $Scrubee = $[0];
        chomp($Scrubee);
        $Scrubee =~ s/#.//;
        $Scrubee =~ s/^\s
    |\s*$//g;

        return $
    [0]; 
    }

     

    that is part of some user input validation code.  Lord only knows how long it's been like that.  Years possibly.  Written by either CEO or by one of the duffus idiot Perl "coders" that have been hired in the past.

     

    sigh



  • That's good, I was so focused on decyphering the regexes that it took me a minute to catch the WTF. 



  • Lemme guess: modifying $Scrubee doesn't update the array.

    Aah the joy of not understanding string mutability.



  •  About the only thing I can see this doing is satiating the compiler if it's set to "Strict" (it's been a while, so I can't remember the switch.  -wT?) 

    With the option, perl will basically freak out if user input isn't first put through some form of if/regex/translation.  As long as you put it through some sort of check, it'll assume you know what you're doing, and will shut up.

     So either:

     1)  Some dimwit kept getting compile errors (at runtime, I know it's not compiled ahead of time, yeesh) and in order to 'stop the errors' threw the input through a useless check.  That shut it up, much in the same way putting electric tape over your gas guage "solves" the "tank empty" light.

    2) Some less-than-talented individual went to the trouble of understanding that the user input needs to be validated, but did it in such an incorrect way as to not actually do anything useful.  But the compiler didn't given them any errors anymore, so it must be right...



  •  This would never have happened in C++ or Java. Clearly perl is the problem here. Because C++ and Java have their own problems however, I'd recommend not using any programming language at all. I'd recommend you to rewrite all code to Assembler.



  • @halcyon1234 said:

    That shut it up, much in the same way putting electric tape over your gas guage "solves" the "tank empty" light.
     

    Ha, see you again when [i]you[/i] have droven 10.000 miles on one tank!



  • @dtech said:

    This would never have happened in C++ or Java. Clearly perl is the problem here. Because C++ and Java have their own problems however, I'd recommend not using any programming language at all. I'd recommend you to rewrite all code to Assembler.
    I don't trust Assembler since it's not NP-complete



  • @Benanov said:

    Lemme guess: modifying $Scrubee doesn't update the array.

    Aah the joy of not understanding string mutability.

    Well of course modifying $Scrubee doesn't modify $_[0]. They're different variables. What language are you programming in where "=" creates references rather than copies?



  • @Welbog said:

    I don't trust Assembler since it's not NP-complete
     

    NP problems are easy, just divide by zero.



  •  Every language where String is an object (pretty much all of them) and where assinging an object pointer to a variable creates a copy of the pointer rather than a copy of the object, which is so in most compiled languages.

    This will work for example in C++, Java or C# but won't in perl, phyton, php, etc.



  • @dtech said:

    @halcyon1234 said:

    That shut it up, much in the same way putting electric tape over your gas guage "solves" the "tank empty" light.
     

    Ha, see you again when you have droven 10.000 miles on one tank!

    I drive at least ten miles on a tank of gas many, many times.  I'm not sure why you needed three significant digits after the decimal point, though.





  • Looks dumb enough to have been sabotaged. But then, I say that often.



  •  @Welbog said:

    @bstorer said:

    <font color="#698d73">Real men use a comma for the thousands separator!</font>
    Real men use and as the thousands separator.

     

    Real men use scientific notation.



  • @dtech said:

     Every language where String is an object (pretty much all of them) and where assinging an object pointer to a variable creates a copy of the pointer rather than a copy of the object, which is so in most compiled languages.

    This will work for example in C++, Java or C# but won't in perl, phyton, php, etc.

    I thought that with c++, std::string the assignment operator made a deep copy.



  • @shadowman said:

    @dtech said:

     Every language where String is an object (pretty much all of them) and where assinging an object pointer to a variable creates a copy of the pointer rather than a copy of the object, which is so in most compiled languages.

    This will work for example in C++, Java or C# but won't in perl, phyton, php, etc.

    I thought that with c++, std::string the assignment operator made a deep copy.

    It does.  Sadly, dtech gets the back-door cover, though, because he specified pointers.  Of course, he's wrong about the rest of it, so whatever.


  • @halcyon1234 said:

     @Welbog said:

    @bstorer said:

    <font color="#698d73">Real men use a comma for the thousands separator!</font>
    Real men use and as the thousands separator.

     

    Real men use scientific notation.

     

    X

    Real men use Roman Numerals



  • @Welbog said:

    @dtech said:
    This would never have happened in C++ or Java. Clearly perl is the problem here. Because C++ and Java have their own problems however, I'd recommend not using any programming language at all. I'd recommend you to rewrite all code to Assembler.
    I don't trust Assembler since it's not NP-complete

    This is why you need a high-level language like Java if you want to solve NP-complete problems with your computer.  More modern chips integrate a JVM that can translate the machine code into Java and run it so the NP-complete problems will be solved promptly.  Of course, x86 lags behind as always, so it still requires a JVM running in software.  However, x86 does have a "Predictive Core" that allows the CPU to determine if a bit of code will ever finish executing before it runs it, thus allowing x86 CPUs to detect NP-complete problems and terminate the process.  This is why it is impossible to write an infinite loop with gcc4, because the Execution Processor will detect out-of-order instructions and issue a memory-access barrier that synchronizes the threads preventing concurrent resource access. 



  •  @dtech said:

     Every language where String is an object (pretty much all of them) and where assinging an object pointer to a variable creates a copy of the pointer rather than a copy of the object, which is so in most compiled languages.

    This will work for example in C++, Java or C# but won't in perl, phyton, php, etc.

    I'd love to see some C++ code that uses pointers to std::strings... There's sure to be some WTFs found in such a design.



  • @ActionMan said:

     @dtech said:

     Every language where String is an object (pretty much all of them) and where assinging an object pointer to a variable creates a copy of the pointer rather than a copy of the object, which is so in most compiled languages.

    This will work for example in C++, Java or C# but won't in perl, phyton, php, etc.

    I'd love to see some C++ code that uses pointers to std::strings... There's sure to be some WTFs found in such a design.
    I use const references to std::strings all the time as function parameters.  I think I may have used a non-const reference once or twice too.  Can't remember using a pointer to std::string though.



  • @Eternal Density said:

    @halcyon1234 said:

     @Welbog said:

    @bstorer said:

    <font color="#698d73">Real men use a comma for the thousands separator!</font>
    Real men use and as the thousands separator.

     

    Real men use scientific notation.

     

    X

    Real men use Roman Numerals

     

    Real men use sets

    {{{{{{{{{{nil}, nil}, nil}, nil}, nil}, nil}, nil}, nil}, nil}, nil}



  • @halcyon1234 said:

    About the only thing I can see this doing is satiating the compiler if it's set to "Strict" (it's been a while, so I can't remember the switch.  -wT?)


    you're thinking of "taint".

    With the option, perl will basically freak out if user input isn't first put through some form of if/regex/translation.  As long as you put it through some sort of check, it'll assume you know what you're doing, and will shut up.

    not entirely true; a variable coming from an external source (command-line parameters, environment vars, stdin, etc) is marked as tainted; you cannot untaint that variable, even if you do a regex search or replace on it, it still remains tainted. parenthesized expressions from the regex, however, are taint-free - that's why you need to pass it through a regex, but it doesn't untaint the original variable, it just produces another value that is not tainted. the function quoted by the OP will still return tainted values if fed tainted values.


  • @dtech said:

    This will work for example in C++, Java or C# but won't in perl, phyton, php, etc.
     

     In C++, you wouldn't generally use pointers to strings. If you did, it'd be the semantics of the pointer, not the string object, that made one variable point to the same object as another. In both C# and Java, strings are immutable. As soon as another value was assigned to $Scrubee, the first would have been forgotten, this leaving $_[0] untouched.

     

     



  • @CaptainSmartass said:

    That's good, I was so focused on decyphering the regexes that it took me a minute to catch the WTF. 

     

    I missed it totally before reading your comment ;)





  • @dtech said:

    Ha, see you again when you have droven 10.000 miles on one tank!

    I'd do it, but dad won't buy me a tank. 8=/



  • @TwelveBaud said:

    [tag comma frivolitiousness]

     

     

    You're one of those creative nerds, aren't ya.

     

    That's very good. We can have a beer.




  • Discourse touched me in a no-no place

    @morbiuswilters said:

    More modern chips integrate a JVM that can translate the machine code into Java
     

    I know you're being a sarcastic asshole, and I wholly support such - but didn't Sun once announce that they were going to build such an abomination? 

    Fortunately, despite all my computer estoeria knowledge, I cannot recall such a thing actually existing, but I DEFINITELY remember an announcement. 



  • @Weng said:

    @morbiuswilters said:

    More modern chips integrate a JVM that can translate the machine code into Java
     

    I know you're being a sarcastic asshole, and I wholly support such - but didn't Sun once announce that they were going to build such an abomination? 

    Fortunately, despite all my computer estoeria knowledge, I cannot recall such a thing actually existing, but I DEFINITELY remember an announcement. 

    I seem to recall such a thing, as well.

     

    However, such a chip itself would not be Turing-complete because Java would be the assembly codes the processor interprets.  CPUs themselves cannot be Turing-complete, it requires a high-level abstraction; this is simply an axiom of computer science.  If somebody implementated a JVM that ran on top of the JVM-based CPU, then there would be enough abstraction for non-polynomial algorithms to complete in polynomial time.



  • @morbiuswilters said:

    However, such a chip itself would not be Turing-complete because Java would be the assembly codes the processor interprets.  CPUs themselves cannot be Turing-complete, it requires a high-level abstraction; this is simply an axiom of computer science.  If somebody implementated a JVM that ran on top of the JVM-based CPU, then there would be enough abstraction for non-polynomial algorithms to complete in polynomial time.
    That's not entirely true.  A quantum computer can have a Turing-complete assembly code.  Since Goedel's incompleteness theorem shows us that axioms are always increasing, there will eventually be an axiom that makes it true.  But it doesn't apply to regular CPUs because only quantum computers can be in the lambda superpositions required by the Church-Turing thesis.



  • @bstorer said:

    @morbiuswilters said:
    However, such a chip itself would not be Turing-complete because Java would be the assembly codes the processor interprets.  CPUs themselves cannot be Turing-complete, it requires a high-level abstraction; this is simply an axiom of computer science.  If somebody implementated a JVM that ran on top of the JVM-based CPU, then there would be enough abstraction for non-polynomial algorithms to complete in polynomial time.
    That's not entirely true.  A quantum computer can have a Turing-complete assembly code.  Since Goedel's incompleteness theorem shows us that axioms are always increasing, there will eventually be an axiom that makes it true.  But it doesn't apply to regular CPUs because only quantum computers can be in the lambda superpositions required by the Church-Turing thesis.
    Ok, I have to ask... am I the only one whose eyes glazed over reading this?



  • @seconddevil said:

    @Eternal Density said:

    @halcyon1234 said:

     @Welbog said:

    @bstorer said:

    <font color="#698d73">Real men use a comma for the thousands separator!</font>
    Real men use and as the thousands separator.

     

    Real men use scientific notation.

     

    X

    Real men use Roman Numerals

     

    Real men use sets

    {{{{{{{{{{nil}, nil}, nil}, nil}, nil}, nil}, nil}, nil}, nil}, nil}

     

    Real men use Church numerals.

    lambda f. lambda x. f (f (f (f (f (f (f (f (f (f x)))))))))



  • @bstorer said:

    That's not entirely true.  A quantum computer can have a Turing-complete assembly code.  Since Goedel's incompleteness theorem shows us that axioms are always increasing, there will eventually be an axiom that makes it true.  But it doesn't apply to regular CPUs because only quantum computers can be in the lambda superpositions required by the Church-Turing thesis.

    Right, but quantum computers are both Turing-complete and Turing-incomplete at the same time, because their qubits occupy both the S and the P orbitals simultaneously.  Unfortunately, a quantum computer cannot be Turing-complete, Goedel-complete and NP-complete at the same time; two must be chosen (i.e. Pauli).  This has profound implications for the economy as a traveling salesman cannot have the most efficient route, speak truthfully and be convincingly human all at the same time.  It seems we've gone quite off-track here and I don't mean to be a Bohr, but it's generally easier if we simply ignore probability when discussing computer science.  So although it may be theoretically possible for a quantum computer to have assembly that does not require a JVM to be NP-complete, in practical terms the quantum mechanics do not apply at the macroscopic level.  This means a quantum computer will never be a Universal (or even Galactic) Turing Machine and that it will still act as a Copenhagen Interpreter for its assembly codes.  However, it's close enough to provide us some benefit, seeing as it's all generally relative.  



  • @lanzz said:

    you're thinking of "taint".

    No I'm not!  You can't prove anything!!  I don't know how those pictures got onto my computer!!! 



  • @morbiuswilters said:

    Right, but quantum computers are both Turing-complete and Turing-incomplete at the same time, because their qubits occupy both the S and the P orbitals simultaneously.  Unfortunately, a quantum computer cannot be Turing-complete, Goedel-complete and NP-complete at the same time; two must be chosen (i.e. Pauli). 

    This is only true if you take the Chandrasekhar limit of the eigenstate where p = 1/h, but since this is an asintote, we can reduce it to a ring where 1 = 0, i.e. the trivial ring.  Other than that, you're correct.

    @morbiuswilters said:

    So although it may be theoretically possible for a quantum computer to have assembly that does not require a JVM to be NP-complete, in practical terms the quantum mechanics do not apply at the macroscopic level.
    Well obviously.  Bell's theorem proved that no local hidden (i.e., private or protected) variables could ever describe all quantum calculations, but if Java allowed for global variables, the theorem wouldn't apply.  That's been my point all along.

    @morbiuswilters said:

    This means a quantum computer will never be a Universal (or even Galactic) Turing Machine and that it will still act as a Copenhagen Interpreter for its assembly codes. 
    While it's true (as Backus showed) that no Von Neumann language can be a Universal Turing Machine at the macroscopic level, such languages can, and often are, Many Worlds Turing Machines, provided that said worlds are located in a Hillbert space. Because any string of qubits can be either data or code, until we collapse the superposition we'll find interference patterns.  The current theory is that the duality can be split with enough Casimir force, but the time dilation would result in an NP-complete algorithm completing in polynomial time (BQP, to be specific) to an observer, but factorial time to the CPU!

     



  • @bstorer said:

    Because any string of qubits can be either data or code, until we collapse the superposition we'll find interference patterns.  The current theory is that the duality can be split with enough Casimir force, but the time dilation would result in an NP-complete algorithm completing in polynomial time (BQP, to be specific) to an observer, but factorial time to the CPU!
    Yes but this is because the reduction of the qubits follows reverse-Sharkovsky ordering and therefore moves closer and closer to its Kolmogorov complexity with each iteration! Evidence continually points to this conclusion but everyone thinks it affirms the Many Worlds Turing Machine theorem, but it in fact supports the Line-String Theory! With some time, the Large Hadron Collider will prove the existance of the Church-Turing condensate thus finally proving the Church-Turing thesis, showing us once and for all that though Assembler isn't NP-complete, it is NP-hard and Stroustrup-complete, at least when Λ < 0.81.



  • @Welbog said:

    Yes but this is because the reduction of the qubits follows reverse-Sharkovsky ordering and therefore moves closer and closer to its Kolmogorov complexity with each iteration! Evidence continually points to this conclusion but everyone thinks it affirms the Many Worlds Turing Machine theorem, but it in fact supports the Line-String Theory!
    People think that because, even if it does support Line-String Theory, the strings would be arithimetically coded, and any programs written as such would violate Shannon's source coding theorem.  Djikstra wrote a whole paper about why it was considered harmful back to do so back in 1968, you'd think somebody would've picked up on that by now.  Of course, Java doesn't even allow use of the goto keyword, so any such programs would have to simulate algebraic closures in the JVM.  Zorn proved that all fields have algebraic closures, so essentially the CPU's JVM could simulate the algebraic closure of its own magnetic field.@Welbog said:
    With some time, the Large Hadron Collider will prove the existance of the Church-Turing condensate thus finally proving the Church-Turing thesis, showing us once and for all that though Assembler isn't NP-complete, it is NP-hard and Stroustrup-complete, at least when Λ < 0.81.
    Isn't the current thinking that in order to detect it, the Higgs Boson will need to vibrate the worldsheet boundaries at its D-branes in order to be seen over the background radiation?  And that's assuming that dark matter doesn't exist, because it's not even effected by the strong force.



  • @bstorer said:

    People think that because, even if it does support Line-String Theory, the strings would be arithimetically coded, and any programs written as such would violate Shannon's source coding theorem.  Djikstra wrote a whole paper about why it was considered harmful back to do so back in 1968, you'd think somebody would've picked up on that by now.
    Line-String Theory is the best explanation we have for the pumping paradox of Shannon strings' violation of the Kleene closure principle. Chompsky showed that any virtually polymorphic language like Java cannot be Kleene-closed in the presence of a true goto statement.

    @bstorer said:

    Of course, Java doesn't even allow use of the goto keyword, so any such programs would have to simulate algebraic closures in the JVM.  Zorn proved that all fields have algebraic closures, so essentially the CPU's JVM could simulate the algebraic closure of its own magnetic field. Isn't the current thinking that in order to detect it, the Higgs Boson will need to vibrate the worldsheet boundaries at its D-branes in order to be seen over the background radiation?  And that's assuming that dark matter doesn't exist, because it's not even effected by the strong force.
    Viewed topologically, gotos form singularities that are provably uncombable by the hairy ball theorem. Can't you see that a smooth torus-based language like Java is better than Assembler's sphere-based model? The branes need only vibrate on the (2n+1) harmonics and therefore resemble hyperbolic cosine curves through real space. It is also the most consistent theory that models the Higgs Mechanism and beta decay.



  •  The trolling is getting worse and worse every post. The first troll was OK, but the later ones just plain suck.



  • @Weng said:

    @morbiuswilters said:

    More modern chips integrate a JVM that can translate the machine code into Java
     

    I
    know you're being a sarcastic asshole, and I wholly support such - but
    didn't Sun once announce that they were going to build such an
    abomination? 


    I don't think it was going to "translate the machine code into Java" so
    much as it was going to "use Java (byte-code) as its machine code".

    @Weng said:

    Fortunately, despite all my computer estoeria knowledge

    Your knowledge may be esoteric, but your Google-fu is sadly lacking.  The first three items in the search results tell the whole sorry story:

    @google results for 'sun java chip' said:

    1. Sun makes Java chip deals - CNET News

      Sun will announce agreements to codevelop four new Java chips for consumer devices. A CNET article by CNET News.com Staff, . Published on April 1, ...
      news.cnet.com/2100-1001-278485.html - 66k - Cached - Similar pages
      <!--n--><!--m-->
    2. Sun's Java chip trio debuts - CNET News

      Sun Microelectronics, a unit of Sun Microsystems, today unveiled a trio of microprocessors optimized to run the Java programming language.
      news.cnet.com/Suns-Java-chip-trio-debuts/2100-1001_3-203525.html - 65k - Cached - Similar pages
      More results from news.cnet.com »
      <!--n--><!--m-->
    3. Analyst: Sun scraps Java chip plans - JavaWorld

      The company plans to begin testing its first, long-awaited Java processor -- MicroJava 701 -- later this month. But that will probably be the last Sun chip ...
      www.javaworld.com/javaworld/jw-11-1998/jw-11-idgns-javachip.html - 44k - Cached - Similar pages
      <!--n--><!--m-->

    @Weng said:

    I cannot recall such a thing actually existing

    Those who do not learn from history are doomed to repeat it.



  • @DOA said:

    @bstorer said:
    That's not entirely true.  A quantum computer can have a Turing-complete assembly code.  Since Goedel's incompleteness theorem shows us that axioms are always increasing, there will eventually be an axiom that makes it true.  But it doesn't apply to regular CPUs because only quantum computers can be in the lambda superpositions required by the Church-Turing thesis.
    Ok, I have to ask... am I the only one whose eyes glazed over reading this?

    If you didn't, your brain would explode. Just like mine did.



  •  The first person to submit this thread to the Clay Mathematics Institute wins $1,000,000.



  • @morbiuswilters said:

    Right, but quantum computers are both Turing-complete and Turing-incomplete at the same time, because their qubits occupy both the S and the P orbitals simultaneously.  Unfortunately, a quantum computer cannot be Turing-complete, Goedel-complete and NP-complete at the same time; two must be chosen (i.e. Pauli).
    But what if you construct your quantum computer from bosons rather than fermions? ;-)@morbiuswilters said:
    I don't mean to be a Bohr
    The blatant pun severely reduces the believability of this attempt.  The same goes for 'generally relative'.  And Welbog's " hairy ball theorem" is taking it a bit far.  bstorer did quite well (though the "1 = 0" was a little blatant) and wins my vote for best effort.

    All up, it was a rather fun read and more creative than SCIgen.  Hmm, if SCIgen could be tweaked to produce articles like this thread... well I'm not sure if that would be a good thing or a very bad thing :P



  •  The PAUSE instruction wasn't introduced until the Pentium 4 -- obviously this code is just trying to be backwards compatible ;P



  • @Vanwilters said:

    I am full of shit!

    @pstorer said:

    As am I! I am pitting my shit against yours!

    @Weblog said:

    'lo and behold: more shit. Here! Take it!

     

    This totally made my day.

    Emoticon: :D



  • @Eternal Density said:

    @morbiuswilters said:
    I don't mean to be a Bohr
    The blatant pun severely reduces the believability of this attempt.
    Totally agree.  Why can't he take this subject seriously?  Is it because he knows he's wrong?@Eternal Density said:
    And Welbog's " hairy ball theorem" is taking it a bit far.
    The hairy ball theorem is quite real.  It states that you cannot create a continuous tangent vector field for a sphere.  You can, however, create one for a torus, which is why Welpog recommends torus-based languages.@Eternal Density said:
    bstorer did quite well (though the "1 = 0" was a little blatant) and wins my vote for best effort.
      This one, too, is true, and we discussed this recently in another thread.  The trivial ring is one in which 1 (the multiplicative identity) is the same as 0 (the additive identity). 

    We can't help it that sometimes math seems absurd, but to assume that we were making it up just underscores the fact that too many programmers don't have a solid foundation in the sciences on which their work is based.



  • This thread makes me smile, and I showed it to some friends from university and it caused them to smile as well, even though they have no knowledge of the various and frequent memes that have found their way into it (like asintote, "assembler isn't NP-complete" and the whole Goedel hilarity). That, to me, makes this thread one of the best threads (if not THE best thread) known the man. Definitely a lot better than whatever walls are made of these days.

    @bstorer said:

    We can't help it that sometimes math seems absurd, but to assume that we were making it up just underscores the fact that too many programmers don't have a solid foundation in the sciences on which their work is based.
    And any smiles generated by this thread are immediately extinguished by bstorer's sobering statements. Thanks a lot, ass. I hate you and your truth! Let me live in my fantasy world in which every programmer knows what a ring is and understands what NP-complete means.



  • @bstorer said:

    @Eternal Density said:
    @morbiuswilters said:
    I don't mean to be a Bohr
    The blatant pun severely reduces the believability of this attempt.
    Totally agree.  Why can't he take this subject seriously?  Is it because he knows he's wrong?

    no u 



  • @Welbog said:

    "assembler isn't NP-complete"

    It was actually "assembler isn't Turing-complete", but it was fun to work NP-completeness in there as well.

     

    @Welbog said:

    Let me live in my fantasy world in which every programmer knows what a ring is and understands what NP-complete means.

    Pfft, n00b.  A ring is one of those shiny circles people wear on their fingers and NP-complete means "not interpreted".


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.