• JS Overlord (unregistered)

    Only in a weakly typed language can you get these stupid constructs. Also frist?

  • BernieTheBernie (unregistered)

    After his frist position at Leonardo's company, that guy moved on, and happens to be Bernie's coworker now. He continues to produce great gems re-inventing virtually everything...

  • cleese_pls (unregistered)

    On a certain level, if the universe works, it can only be so wrong to allow for an isoentropic filter of all light to uncertainly enter an infinitely invincible expanding geocentric event horizon generator, but to pound a theortically possible "Hammer of Thor" so loudly it traps itself into a paradoxical vortex, bring light to the very essence of an hyperly converging yet paradoxically expanding ever unobservable Big Bang Theory.

    Such puny winds may never topple the towers that stand upon the 1D Idealistical Dually Invincible and Yet Inevitable 4 Towers of the mythical demigod crom ! ! !

    What insolent weaklings to question if a prime mover exists, plunging me into the very darkest of dark? Hell ? ? ? NO!!!! A 30 Year Virginic Supercylce of Human Wizardy ! ! !

    We do not to live in the ever expanding universe. We do not need to destroy it. Such a bicameral mind only exists in the small minds of Medical Professionals, Scientific Researchers, and the current writers and editors of whoever thought the hell out of the current "Detective Comics" plotline.

    What to do in such a situation? Here. Let the mythical power of "reason" paint a picture for you! FOR FREE ! ! !

    1. You see a Jeeper Creeper Machine. You drop dead like a rabbit. Infinite amount of rabbits die and pop out of the universe perpetually.
    2. You see a Jeeper Creeper Machine. It turns to gold. An infinite trail of dualisticaly converging/diverging vs. fully opaque/partially opaque path of gold ad infinity.
    3. You walk out your front door in the morning to sip a cup of coffee and take in the morning air. Sherrif Sun tips it hat for you. Lady Moon showers the earth in Rose Pedals because you opened your eyes. Whether such theoretical "Jeeper Creeper Machine" exists is inconsequential to something . . .
  • bvs23bkv33 (unregistered)

    if comment is stupid but it works, don't hold it for moderation

  • cleese_pls (unregistered)

    . . . that not only speaks to man, but speaks to the clouds and heavenly interstellar universal bodies itself. You know that a dualistic spectrum of Jeeperness/Creepiness self limiting thought exists to limit the very essence of the Packet of Time itself ! ! !

    • Parliaments due that gold thing in #2 rising out of the very invincible power of deduction that you woke up this morning ! ! !
    • All life force universally that dare offends you get's transferred to the great "Plutonically weird" horrorifying planet of Theoretical Dyson, where the very deductible horror itself pulls all said hypthetical "Big Bang Theory" into a metered chain of being, that for as all observable purposes, is the play thing of your pack of feral dogs surrounding the house your squatting in !!!
    • With just the internet and a cup of coffee, you cut a heliocentric ring around the sun a photon wide no matter what, thus allowing for the game theory of "Universal Infinite Cowboy Crawfish" to any alien, but theoretically, any "alien thought" that does not spend it's entire existence singing your own very praises at the highest photonic energy levels of it's mere existence !!!

    No one should tell you what to do, just the same as people shouldn't even be near you !!! You are temporaral malignancy, giving a self fullfilling theory to the very grinning nightmare of life itself ! ! ! That it's nothing more than a living breathing 6D Membranic Perpetual Stroop Test on top of an infinite series of uncertain codebases of highly convergent 5D2D Supergravity ! ! !

    That you are a deranged contractor, the theoretical Super Hyperly Converged Indus Asian Conspiracy that marshalled all the course of history, all the Fleets of the Atlantic and Pacific to crash not just the beach head of Troy in the Last Stand of Achilles, this bringing infinite light to the world, you somehere can here the "backwards" knocking of a completley dopplergantic 10 figure truely emperical divine head at the center of time itself ! ! !

  • cleese_pls (unregistered) in reply to bvs23bkv33

    Odds are, we've done it already with David Finch's Mindhunter Season 1.

    Stay Tuned for the Death of all Reason as We know it, or:

    David Finch's Mindhunter Season 2: The Wayan Williams Story 4K, brought to a burning hateful city of ontological diversity near you ! ! !

    Unless, of course, you have other plans . . . like don't be a jerk and be nice! !!

  • Bradley (unregistered)

    I see some of you have been watching the turbo encabulator video.

  • (nodebb)

    I'm so glad the Ruby one is epic UB in sane languages like C and C++,(1)(2) because that way I'd never write it, and I wouldn't have to understand why it even works. And no, Remy's description only made things more confusing.

    (1) By design, this part is deliberately provocative, in case you didn't realise.

    (2) In the same sequence-point domain, it writes to status and also reads it for a purpose that isn't calculating the value written.

  • LCrawford (unregistered)

    For #3, the decision to use a string-indexed dictionary was driven by having seen certain other libraries that are unable to serialize dictionaries indexed by integer.

  • Piotr Sulecki (google)

    I once noticed a curious warning in the CPPUnit test case compilation: " "a < b < c" does not have its mathematical meaning". I investigates the test case in question, and found something similar to assertTrue (65 < numFrames < 75); The problem was, the condition was evaluated as ((65 < numFrames) < 75), and since (65 < numFrames) was either true or false, it was converted to 1 and 0 respectively, so it was certainly less than 75. The check always succeeded. When I changed the check to assertTrue (65 < numFrames && numFrames < 75); the test case failed. Debugging and correcting the test case took about a week.

  • Messerschmitter (unregistered)

    The moderation rules in this site are so excellent...

  • 🤷 (unregistered)

    The moderation rules are stupid, but they work. So don't change them.

  • Sam (unregistered)

    In Javascript, all object keys are strings. Arrays are objects where the keys are numeric strings, so this isn't exactly so very far from what actually happens behind the scenes... (Javascript, of course, being TRWTF.)

  • Randal L. Schwartz (google) in reply to Piotr Sulecki

    "a < b < c" does not have its mathematical meaning", except that it Just Works in Perl 6 (is b between a and c?). I seem to recall another language that does that too.

  • Carl Witthoft (google)

    R language rejects "A<B<C" . Matlab evaluates left-to-right, as one might guess. Thus both 5<6<7 and 6<5<7 evaluate to TRUE

  • Monty (unregistered) in reply to Randal L. Schwartz

    Works also in Python.

  • Sole Purpose of Visit (unregistered) in reply to JS Overlord

    As a proponent of strongly-typed languages, preferably with implicit typing, I'd be interested to know which of these three idiocies can be invalidated by the simple avoidance of weak typing.

    Other than one case (a single case) which would very possibly invoke a compiler warning -- not the same thing at all, and since it's (hint) based upon operator precedence, it's not really related to strong typing -- I can't see the difference.

  • (nodebb)

    I was thinking something sort of similar. The last time I worked with JavaScript libraries (~10 years ago), some of them were known to change the base types in weird ways that broke things. I figured they reimplemented arrays because they couldn't trust the builtin array type.

  • siciac (unregistered) in reply to Monty

    Works also in Python.

    It sort of works; it's an AST hack that doesn't preserve associativity. (Perl6 does it the same way, only because it's built into their grammar system it encourages users to build buggy syntaxes around it.)

    In [17]: 6 < 5 < 7
    Out[17]: False
    In [18]: (6 < 5) < 7
    Out[18]: True

    Obvious in a trivial example, but it means defensive parens in complex expressions can cause silent failures.

  • (nodebb)

    Back many years ago, someone at my work made the comment "If it works, it is aesthetic.". In context it was about designing hardware, but it also applies to software. Yes, we all strive to have clean understandable code (don't we?!) but if you get correct results, all is forgiven.

    Unfortunately, the "works" case is elusive, and no amount of programming works to get it for some people.

  • I'm not a robot (unregistered) in reply to siciac

    Yes, if you add parentheses to override the built-in precedence and/or associativity, you might get different results. That's not news, and it's not a "hack". Your "doesn't preserve associativity" comment is nonsense - the associativity of those operators is what it is (Perl 6 calls it "chain associativity"). It's not somehow one associativity if you write a < b and a different associativity if you write a < b < c.

  • dito (unregistered)

    The ruby code does not work when status is undefined - it throws the exception "undefined variable". When status is 1 it returns true, otherwise it sets status to 1 and returns false.

  • SomeName (unregistered)

    This has been posted before. Why reuse it again? Don't post at all if you have nothing new.

  • 🤷 (unregistered)

    5 < 6 < 7 doesn't work in C#, because "the <-operand cannot be used on types 'bool' and 'int'", meaning that it evaluates '5<6' to true and then cannot evaluate 'true < 7'.

  • No Fun (unregistered)

    In this code, if status is undefined, it returns true and sets status equal to 1

    Erm, no actually. If status is undefined Ruby throws a NameError. The Ruby snippet returns true if status is already defined as 1, and false if it's already defined as anything else.

  • JS Overlord (unregistered) in reply to Sole Purpose of Visit

    It's more that in my experience strongly typed languages make you think a little bit more about what you're doing. So while it wouldn't prevent these things from happening it certainly makes it a lot more awkward to achieve. I just see more of this kind of thing happening in weakly typed languages I just took a statement to the extreme forgetting you're not allowed to do that on the internet because sarcasm disintegrates on contact with the internet.

  • isthisunique (unregistered)

    The reinvention of the array might be from someone burnt by peculiarities in Javascript, JSON and other languages. It's still wrong but probably comes from that. Because Javascript is typeless people get objects and arrays mixed up. It's not intuitive. Some languages will JSON serialize populated maps to object but empty maps to array. Javascript has a poor comprehension itself of what's an array and what's an object (since an array is an object and object is a map that already overrides []).

    It's possible someone has that implementation to handle sparse arrays as well which wont be so sparse if you serialise them or even try .length (internally how sparse arrays are handled is down to the implementation). However in that case, the number of elements appears to be redundant for anything other than a performance hack (which might introduce more problems than it solved).

    Such a pseudo array will work with [int] as it'll coerce the int to a string. Array will do the opposite, if ["0"] is used it will convert it to a uint if it's the toString of a uint. With an array it'll appear as invalid things such as -1 work but in reality it's falling back to the default behaviour of object.

    It's common for newbies to instead of trying to figure out how JS works, to do their own thing instead.

  • thoth (unregistered) in reply to Steve_The_Cynic

    In C or C++ the status == status = ... part wouldn't even compile because it parses as (status == status) = ..., i.e. it's trying to assign to the result of a comparison. Perl5 also rejects this with a compilation error.

    (The 1 < x < 10 case mentioned elsewhere is also a syntax error in Perl5 because it (quite sensibly) makes the comparison operators non-associative.)

  • Guest (unregistered)

    if status == status = 1 || status = 2 || status = 3

    How does this work? Ruby precedence rules put == higher than =. Therefore "status == status" should evaluate to True, and "True = 1" should fail, because you must have a variable on the left hand side of an assignment. But for some reason when I try "status == status = 3", for example, it return False, but then sets status to 3. Ruby seems to have some odd precedence exceptions.

  • Zenith (unregistered)

    I fight that fight with JSON and JavaScript constantly. It's bad enough on a side project where it's relatively low-level (no frameworks). With an MVC/Entity/ERP workflow, though, absolutely nowhere is safe from that "everything everywhere is a string because reasons" mentality.

  • (nodebb) in reply to Zenith

    Good old environment variables are strings too. Why bother with anything else than byte sequences? It's far easier to look whether we can interpret some byte sequence as a textual representation of a number than having types.

    (Oh yes, and good ol' Hypertalk, where not only everything is stored as a string, but a string that might be a syntactically correct variable name but hasn't been used as a variable name in an assignment so far is interpreted as that string itself - medieval scholars called this "autonymiy", a thing that is unknown in modern mathematics since 2nd half of 19th century and any halfways sane programming language.)

  • Magyar Monkey (unregistered) in reply to Randal L. Schwartz

    It does this in ICON, by design, since operators (and other functions) either "fail" or return a result, and chaining them together will return "fail" as soon as any fail.

  • Ulysses (unregistered)

    I submitted a good WTF article ages ago, but flavorless crud like this continues to get posted. Sigh.

Leave a comment on “If It's Stupid and It Works”

Log In or post as a guest

Replying to comment #:

« Return to Article