• Rich (unregistered)

    At least no 'ON ERROR RESUME NEXT' I suppose.

  • SolePurposeOfVisit (unregistered)

    Paracetamol! I need paracetamol!

  • Hugo (unregistered)

    I wanted to post FRIST with the letters sorted in alphabetical order, but I guess the joke would be lost on most people.

  • Melnorme (unregistered)

    If the contents of the tree are fixed, why would it ever be unsorted?

  • Ron Fox (google)

    When the HTML comments are more interesting than the article ...

  • Remy Porter (google) in reply to Melnorme

    The contents aren't fixed, they're just not displayed on the UI. The submitter wasn't clear, but I believe the user can add and remove additives from a drug formulation, triggering a new sort each time.

  • Kaewberg (unregistered)

    "Fervens Canis (aquaeous)"?

  • Simon Clarkstone (unregistered) in reply to Kaewberg

    "Fervens Canis (aquaeous)" = hotdog water, in bad Latin.

    Also, "Lipids (3-In-1)" is missing from the comment block.

  • Ron Fox (google)

    All the 'good drugs' are missing from the list.

  • (nodebb)

    "VB claims that DIM is short for DIMENSION, but I'm convinced that VB is insulting your intelligence"

    Interesting, I just always thought it was an insult, it never did occur to me there could be an (alleged) alternative meaning.

  • Scott Christian Simmons (unregistered)

    "Prior to .NET, VisualBasic was a terrible language ..."

    Just to satisfy our curiosity, how would you describe VisualBasic subsequent to .NET?

  • DigitalSkyline (unregistered)

    OH My... ASP, how much do I miss thee...

  • Just this guy, you know? (unregistered) in reply to Scott Christian Simmons

    Just to satisfy our curiosity, how would you describe VisualBasic subsequent to .NET?

    C# with different syntax, so a pretty good language

  • (nodebb) in reply to SolePurposeOfVisit

    The only painkillers that kind of work here are morphines and stronger. Or encephalectomy.

  • (nodebb) in reply to Just this guy, you know?

    Just wanted to write the same.

    But it seems to me that in Visual Studio, the code rearrangement works much faster and more reliably in VB than in C#. (I refuse to understand this.)

  • TenshiNo (unregistered) in reply to Just this guy, you know?

    A horrible, horrible hack of C#, trying to wedge OOP into a language that was never intended to be OOP. And, as someone who cut their teeth on BASIC (and later VB), as soon as I learned C++, I quickly grew to dislike the "verboseness" of VB. Simple scope enclosures, like braces, make the code look sooo much cleaner than "End Function". I do love C#. Definitely my language of choice these days.

  • Carl Witthoft (google)

    Must be some way to add a bubble-sort to that code.

  • airdrik (unregistered) in reply to Carl Witthoft

    They used bubble-sort to figure out the correct ordering, which is now preserved for eternity in the initial comment.

    Unrolling the sort algorithm, they can then get the runtime down to O(n).
    Unfortunately the data set is small enough that it doesn't matter what algorithm is used (so long as it isn't so bad that it takes a noticeable amount of time), they all reduce to O(1) being a constant factor of a constant (upper-bound) size.

  • Remy Porter (google) in reply to Scott Christian Simmons

    "Mostly Harmless". There's nothing particularly good about VB.NET, but there's nothing particularly terrible about it, either. The only real complaints people can have are "ugh, keywords instead of braces", but frankly I've been doing a lot of Python lately, and I'd be happy with either keywords OR braces at this point.

  • gws (unregistered)

    I feel the backstory is in need of more explanation of the 'hotdogwater' bit.

  • Jack (unregistered) in reply to Carl Witthoft
    Must be some way to add a bubble-sort to that code.
    *bogosort
  • Koen van Dratel (unregistered)

    ["Selenium > about five years"] --> ["Selenium > 5years"] ["Chromium","Chromium"] --> ["Chromium"] ["May contain nuts"] --> [] Brilliant! Not only does it sort, but it even normalizes terms, removes duplicates and ignores hypothetical additives as well. Given all the thought that apparently went into composing this algorithm, why is it not that ["Cysteine - NoAcetate"] --> ["Cysteine + Acetate"]?

  • Schol-R-LEA (unregistered)

    Presumably, the list of drugs in the comments are the ones that the developer took before coding this.

  • Drone (unregistered)

    W.T.F. I actually gasped out loud as I read this. And now my eyes are bleeding.

  • SolePurposeOfVisit (unregistered) in reply to Remy Porter

    Just about everything, in any language, outside of CARs and CDRs (on one side of the fence) or unit declarations (where units are a const, a variable, a function or a class) on the other side of the fence, comes down to syntactic sugar. This is a bold and obviously inaccurate statement. But I think it's a reasonable lemma for considering this problem you have with Python, or the problem that other programmers have with curly brace languages, or the problem that almost all of us would have with PL/1 ... not only stupid keyword terminators, but also you can redefine the idiot things at will ... Anyhow. Not sure why you're finding the Python equivalent of curly braces annoying (if I read you correctly). A decent IDE makes it next to trivial, and, dare I say it, very natural. More than I can say of some of the libraries, or indeed of the GIL. That last one ... ugh. No way round it. It's baked into Python at an annoyingly low level.

  • (nodebb) in reply to Rich

    Just tried it with VB in Visual Studio 2015.

    VB.NET still does know On Error Resume Next.

    Now I have to puke.

  • löchlein deluxe (unregistered)

    Two lines in, I got a Tom Lehrer earworm. :facepalm:

  • BW (unregistered)

    I usually have to work with VBA and have this lovely QuickSort that I got out of the interwebs. Since the array support in VBA is so bad it all works with Variants.

    What are they doing with the Hot Dog water?

  • (nodebb)

    So long as we do those inserts in reverse alphabetical order, the end result will be that items are added to the list in alphabetical order.

    That... that's not how insertion sort is supposed to work.

    Addendum 2016-08-16 01:26: Also, it's not hot dog water, it's hot dog in (aqueous) solution, i.e. dissolved in water. I don't know that that's any better.

  • (nodebb)

    Aha, it's a bucket sort. There are only a limited number of items to be sorted, so they are each put into their appropriate bucket, and then the buckets are emptied. O(1) FTW?

  • (nodebb) in reply to SolePurposeOfVisit

    This is a bold and obviously inaccurate statement.

    No, it just marks you out as someone from a Lisp heritage that has been blinded by the Blub effect. 😏 There are other reasonable sets of primitives you can build a language from as well; associative maps are pretty common (e.g., they're very much at the core of Javascript and PHP, much as I despise both of those languages). Yes, you can build associative maps out of Lisp primitives, but doing so efficiently is rather harder than it appears to be at first glance, at least on all current hardware.

  • Angela Anuszewski (google) in reply to löchlein deluxe

    Damn you, it isn't bad enough that you got it, you had to spread it?

    (FYI, before the new comment system, my registered user name was "The Great Lobachevsky" ;-)

  • VB6 Non-hater (unregistered)

    This isn't VB6 being a stupid WTF language - it's someone who doesn't know how to use the tools available to them.

    Pseudo code for writing the above into an invisible sorted listbox: Listbox.sorted = true Listbox.add "a drug 1" Listbox.add "d drug 4" Listbox.add "c drug 3" Listbox.add "b drug 2" ... The listbox automatically sorts into alpha sequence as items are added, because you told it you wanted the data to be sorted. Truly amazing. It just so happens that a listbox is a better control for sorting simple lists than a treeview, as anybody with any familiarity with the toolset would know.

    The code in this article is not so much representative of the language, but of the low barrier to entry that the language allowed - people with little gumption or aptitude could become google-search-based developers and hack something together that did the job, if not elegantly or quickly (or even adequately.)

    By contrast, a decent developer will write a decent application regardless of the language or environment.

  • ChaoticEd (unregistered) in reply to Remy Porter

    VB.Net has inherited some terrible treats from VB - apart from the developers that keep writting VB code in VB.Net - such as non-shortcircuiting And and Or. Why the hell did it have to be backwards compatible? Now VB.Net developers are stuck with And, Or, AndAlso and OrElse where the last two are proper && and ||, i.e. shortcircuiting. Combine that with VB developers propensity to write methods that return boolean success values and use them with And and Or causing unintended consequences on failure. Yuck!

    Another WTF is that they kept modules as some sort of static super class that is globaly accessible and therefore screws with namespaces and naming.

    On the other hand there are some pluses to VB.Net such as the possibility to write literal inline XML and other stuff.

  • Roelf (unregistered) in reply to TenshiNo

    If you like to write verbose code, try F# for a change!

Leave a comment on “Drugsort”

Log In or post as a guest

Replying to comment #:

« Return to Article