• Michael Scarn (unregistered)

    throw new WTFException("frist")

  • Sole Purpose Of Visit (unregistered)

    Eh?

    YAML is perfectly cromulent. One could argue that XML, SGML, JSON and so on are equally cromulent. I have my preferences, and I don't like verbosity and start-end tags and so on, but I can work with all of them, given a decent parsing apparatus.

    I'm assuming that Remy has been bitten by a lousy project that happened to use YAML as a transfer/storage protocol, because otherwise I can't see why the WTF here is YAML.

  • Chatogaster (unregistered)
    • Countering an overridden Exception is a sign of a paranoid mind (based on the precaution of \Exception).
    • Using double quotes in PHP is evil (based on "'WTF" and "WTF ")
    • Magic values are evil (based on 'WTF')
    • Spotting merely one instance where a WTF applies is naïve.
    • Using "if" (control flow) rather than a conditional expression is naughty.

    Yet... I like this code and especially the style of the programmer responsible... I may self-reflect and do some soul-searching tonight (whilst sleeping). Most likely, I'll still like this WTF afterwards.

  • Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)

    YAML is sometimes nice to use, but then once you start to stumble onto bizarre things like the Norway problem, it makes you want to give up software engineering and go back to making furniture.

  • dusoft (unregistered)

    the true WTF is that this code if (! $message) { $message = "WTF!?"; } else { $message = "WTF!? " . $message; } can be rewritten as this:

    $message = $message ?? ''; $message = "WTF!? " . $message;

  • Randal L. Schwartz (google)

    The great secret about YAML is that it accepts loose JSON as well. So you can nearly completely ignore all the indentation rules and spell out your data structure as JSON, with comments and no need to quote most of your object keys!

  • (nodebb)

    TRWTF is this code is how to determine when a trailing space is needed for readability....

  • adhdeveloper (unregistered)

    If I had a dollar for every hour of my life that had been stolen trying to figure out bizzare and obscure edge cases in YAML documents that were causing failures I'd have enough money to convince everyone to use a decent data format.

  • (nodebb)

    I love this line:

    if ($contents === false)

    He didn't check for true and FILE_NOT_FOUND, and that's TRWTF.

  • ooOOooGa (unregistered) in reply to dusoft

    Nah, that's not PHP'ish enough.

    $messages = ['WTF!?'];

    if ($message !== null) $messages[] = $message;

    parent::__construct(implode(' ', $messages), $code);

  • Yikes (unregistered)

    If I hear "YAML Be There" one more time, YAML burn the building down.

  • tbo (unregistered) in reply to dusoft

    If you're looking to be concise, just...

    $message = 'WTF?!' . ($message ?? '');

  • Bill Sorensen (github)

    We've run into the Norway Problem with a vendor. It can vary based on the version of YAML in use (and what parser/validator people are using). See https://stackoverflow.com/questions/53648244/specifying-the-string-value-yes-in-a-yaml-property

  • MaxiTB (unregistered)

    YAML is really, really bad.

    I can't count the times that errors caused crazy effects in Kubes for Docker containers, simply because something was parsed as a value but was intended as a string or simply because indenting was wrong, messing up the whole file.

    And for all defending "indent as data" as a feature:

    The reason why most modern, professional formats scope their data or code explicitly is simply because it was one of the most common errors. Scope tags are there to separate visual document design from data, because scope is the context in which the data is hosted, and therefore data itself. If you remove tags for scoping (begin end tags, terminator tags, etc.), you remove the only weak error checking available to a parser and for humans as well to find the actual mismatch but cross referencing the document with it's indenting.

    So yeah, all formats that use visual layout as data are way more error prone and harder to maintain than formats separating data from design. Which makes YAML one of the worst out there.

  • (nodebb) in reply to MaxiTB

    So yeah, all formats that use visual layout as data are way more error prone and harder to maintain than formats separating data from design.

    Cries in Python

    Source code is ultimately also a data format. I wonder how well Python projects do with git merges...

    It sounds nice at first, but in most cases I'd prefer C style brace syntax and a code formatter over making the programmer into a code formatter. Indentation for the benefit of the programmer, explicit grouping, even if redundant with indentation, for expressing the actual structure TO the formatter.

    Brace syntax is especially nice, because it is more consistent for tooling than having to tell a tool which keywords start a block and which end it (compared to e.g. bash or Fortran).

    Addendum 2022-05-05 10:25: In Emacs Lisp I love how uniform the syntax is. Sadly, the use of parentheses for EVERYTHING can make it hard to see, if you're looking at an assignment or a condition :/

  • (nodebb) in reply to R3D3

    I wonder how well Python projects do with git merges...

    Mostly OK. You usually either aren't changing the structure of the program very much in the first place, or the change you're doing is obvious (even if it isn't to git).

  • (nodebb)

    YAML is to JSON what Python is to PHP. YAML / Python: Indent one thing wrong and it can all blow up in your face. (Never mind getting into tabs vs spaces.) JSON / PHP: Beginners can do some truly horrible things with them and give them a bad name. (And they really DGAF about tabs or spaces outside quotes.)

  • YouGuestIt (unregistered)
    Comment held for moderation.
  • khanaa (unregistered)
    Comment held for moderation.
  • VR LOOMINE (unregistered)
    Comment held for moderation.

Leave a comment on “Exceptionally TF”

Log In or post as a guest

Replying to comment #:

« Return to Article