• Englebart (unregistered)

    In hetergenous world of browsers and javascript, the variants are maddening. I can see loading the sample page in a bunch of different browsers just to make sure you are building on a known foundation.

    It probably took this guy a few minutes to write the tests. It may have saved hours of frustration with some crazy browser that a customer just must use.

    I was almost burned a few times with vendor (binary) libraries.

    We had a small issue with a J2EE container at version x.x.x.6. Basic API behaviors changed dramatically between that version and ...7, ...8, ...9 until things settled down around x.x.x.10.

    Of course by that time we had written our own layer to sit atop the changing parts of the vendor's J2EE layer to ensure consistent behavior. The J2EE spec did not cover some of these areas in enough detail to ensure a deterministic behavior, but this is supposedly a sub-sub-patch level. I would have expected changes like this at x.y.0.0 or y.0.0.0 but not big changes for a sub-sub patch.

    My guess is that they had 2 different clients battling for releases with different interpretations of the spec.

    The 2 big ones I remember were

    1. They removed the ability for a Servlet to get first grab at the raw input stream. This is very necessary to support things like uploading of images! They seemed to assume that every post must be some form data! (Not sure how that change made it past QA)
    2. If you forward an item or include an item in the servlet APIs, what happens to the query string? They could not make up their mind whether to include the query string or not. This is where the spec was a little foggy and where we added our own wrapper.
  • (cs) in reply to The Nerve
    The Nerve:
    A Javascript compiler is a BIG WTF.

    QFT. Subsequent posts have proven that JavaScript compilers exist, but have not refuted the fact that they are in fact a BIG WTF.

  • noland (unregistered) in reply to IceBrain

    On JS as a modern scripting language: JavaScript is compiled to speed code just in time with lazy variable resolving. (P.E.: If you've a look at the Rhino code, tokens are converted to integer codes; All modern JS engines are making use of code optimization. Maybe it's the principle of fail-as-late-as-possible that let's you take it for a straight interpreted language?)

    The TWTF: If this code is meant to test the implementation of .contains() and .indexOf() there's quite some extra prose, since the JS engine would just fail at compile time as ist hits the first useage of these methods in the code.

    If you would want to check the availability of native functions you'ld do some as the following:

    function isImplemented() {
      return ((Array.indexOf || Array.prototype.indexOf) && (Array.contains || Array.prototype.contains));
    }
    

    (Akismet: No I'm not a bot trying to submit evil code.)

  • TommyTuTone (unregistered) in reply to Chris

    I agree.

    High horse anyone?

  • noland (unregistered) in reply to The Nerve
    The Nerve:
    Seriously? Ok, maybe they don't teach this in college anymore.

    A compiler takes code written in a computer language and converts it into machine code. JavaScript (see it's right there in the name) is an INTERPRETED language, which means that an interpreter reads the code and executes actions. I doubt that a JavaScript compiler would have any use in a web browser, and you wouldn't want to use it anyway, because then you would have to compile separately for Windows, Linux, Mac, BSD, AIX. The only use for a JavaScript compiler would be so you could write standalone programs that ran faster. If you think the Javascript language has any merits that warrant you creating standalone applications using the language, then check into the psych ward at your local mental hospital. I would rather write lolcode.

    Really? From ECMA 262 2nd ed. (Aug. 1998):

    16 Errors This specification specifies the last possible moment an error occurs. A given implementation may generate errors sooner (e.g., at compile-time). Doing so may cause differences in behaviour among implementations. Notably, if runtime errors become catchable in future versions, a given error would not be catchable if an implementation generates the error at compile-time rather than runtime.

    An ECMAScript compiler should detect errors at compile time in all code presented to it, even code that detailed analysis might prove to be “dead” (never executed). A programmer should not rely on the trick of placing code within an if (false) statement, for example, to try to suppress compile-time error detection.

    In general, if a compiler can prove that a construct cannot execute without error under any circumstances, then it may issue a compile-time error even though the construct might never be executed at all.

    So there's a clear definition of progressive steps of lexical analysis, compilation, and runtime even in the 90s (Netscape 4 & co).

  • Dan (unregistered) in reply to jpers36
    jpers36:
    The Nerve:
    A Javascript compiler is a BIG WTF.

    QFT. Subsequent posts have proven that JavaScript compilers exist, but have not refuted the fact that they are in fact a BIG WTF.

    With JS in heavier use these days (FaceBook, for example), compilers for JS actually are in demand. Ever had your machine bogged down by all that live updating? I have.

  • taiki (unregistered) in reply to The Nerve
    The Nerve:
    If you think the Javascript language has any merits that warrant you creating standalone applications using the language, then check into the psych ward at your local mental hospital. I would rather write lolcode.

    Palm Pre's SDK is mostly JavaScript, or was before they caved into pressure.

    Even their text messaging handler was written in JS.

  • Nome de Plume (unregistered) in reply to me
    me:
    The Nerve:
    xxx:
    The Nerve:
    A Javascript compiler is a BIG WTF.

    And what do you think modern browsers contain? You know, the thingie you use to run JavaScript code? Hello?

    Seriously? Ok, maybe they don't teach this in college anymore.

    A compiler takes code written in a computer language and converts it into machine code. JavaScript (see it's right there in the name) is an INTERPRETED language, which means that an interpreter reads the code and executes actions. I doubt that a JavaScript compiler would have any use in a web browser, and you wouldn't want to use it anyway, because then you would have to compile separately for Windows, Linux, Mac, BSD, AIX. The only use for a JavaScript compiler would be so you could write standalone programs that ran faster. If you think the Javascript language has any merits that warrant you creating standalone applications using the language, then check into the psych ward at your local mental hospital. I would rather write lolcode.

    You should check out the games that come as default with recent Ubuntu desktop installations. At least one is written in JavaScript.

    The MongoDB Shell uses a built-in Javascript interpreter to query the database. This is a stand-alone application.

  • Ben (unregistered) in reply to The Nerve
    The Nerve:
    xxx:
    The Nerve:
    A Javascript compiler is a BIG WTF.

    And what do you think modern browsers contain? You know, the thingie you use to run JavaScript code? Hello?

    Seriously? Ok, maybe they don't teach this in college anymore.

    A compiler takes code written in a computer language and converts it into machine code. JavaScript (see it's right there in the name) is an INTERPRETED language, which means that an interpreter reads the code and executes actions.

    You need to ask for a refund of your tuition.

    There is no such thing as a compiled language or an interpreted language. You can interpret C just as you can compile bash. The language itself may make one more useful than the other, but there's no intrinsic property of the language forcing you to do that.

    And while many Javascript implementations are still interpreters, modern implementations are moving towards just-in-time compilers, that is they are hybrid interpreter / compilers that generate native machine code for frequently executed code. Examples: Firefox's TraceMonkey (named after its technique for JIT), Chrome's v8 (from the description, more of a straight compiler than a JIT hybrid).

    I doubt that a JavaScript compiler would have any use in a web browser, and you wouldn't want to use it anyway, because then you would have to compile separately for Windows, Linux, Mac, BSD, AIX.

    In the past, a common technique was to generate C code, now more people are moving towards LLVM.

  • Nome de Plume (unregistered) in reply to Dan
    Dan:
    jpers36:
    The Nerve:
    A Javascript compiler is a BIG WTF.

    QFT. Subsequent posts have proven that JavaScript compilers exist, but have not refuted the fact that they are in fact a BIG WTF.

    With JS in heavier use these days (FaceBook, for example), compilers for JS actually are in demand. Ever had your machine bogged down by all that live updating? I have.

    Javascript (ECMA Script standard) objects use a prototype rather than superclass based inheritance. This does not lend itself to compiled programs.

    Other languages, like Smalltalk and Python, also allow classes to change over the program's life-cycle. All such languages, I believe, must be interpreted.

  • b0b g0ats3 (unregistered)

    this gives me a bonar

  • (cs) in reply to Nome de Plume
    Nome de Plume:
    Other languages, like Smalltalk and Python, also allow classes to change over the program's life-cycle. All such languages, I believe, must be interpreted.
    Having written code in this area, I can safely say that you are wholly and utterly wrong. The trick is that you basically keep an epoch counter (which you snapshot every time you compile some code) and you advance the epoch every time you have a change that invalidates compiled code (which could theoretically be frequent, but practically isn't). That then turns the check to see if the code is valid into a compare of two numbers for equality; if the check fails, you recompile and run. It's cheap, it's pretty simple to get right, it works damn well, and most languages can be compiled extremely quickly. (C++ is the biggest single example otherwise.)

    It's also possible to use mixed mode systems that start by interpreting and switch in the compiled version once it's done (compilation being done in a separate thread). That's very good indeed, but much more complex. Simple JITting is typically good enough.

  • Shaftow (unregistered) in reply to IceBrain
    IceBrain:

    In fact, V8 already compiles to machine code: "V8 increases performance by compiling JavaScript to native machine code before executing it, rather than to a bytecode or interpreting it."

    And Mozilla is also working on a compiler to machine code called Jaegermonkey, which is slated to be included in Firefox in September.

    People, especially college boys & girls, should know that any language that can be interpreted can also be compiled.

    Similarly, any code that can be compiled can also be interpreted. CINT - interpreted C

    Not that I'd want to, but it is possible.

  • (cs) in reply to The Nerve

    I had a good snicker when I saw this:

    The Nerve:
    if (false != false) throw new Exception();

    The best part is that it is extensible (confusingly so, to boot):

    if (false != false != false) throw new Exception();
    
    if (false != false != false != false) throw new Exception();

    ...and etc.

  • Mr.'; Drop Database -- (unregistered) in reply to dkf
    dkf:
    Nome de Plume:
    Other languages, like Smalltalk and Python, also allow classes to change over the program's life-cycle. All such languages, I believe, must be interpreted.
    Having written code in this area, I can safely say that you are wholly and utterly wrong. The trick is that you basically keep an epoch counter (which you snapshot every time you compile some code) and you advance the epoch every time you have a change that invalidates compiled code (which could theoretically be frequent, but practically isn't). That then turns the check to see if the code is valid into a compare of two numbers for equality; if the check fails, you recompile and run.
    Common Lisp is a well-known language that does something like this, allowing any function or class to be redefined at runtime, even by calling eval. Some implementations of Common Lisp are interpreted, but SBCL is all compiled.
  • Daedalus (unregistered)

    V8 has been pointed out already, but I'll add some more:

    • Chrome uses V8 to run its Javascript. This is a web browser that compiles javascript to run it - and has been proven in benchmarks to be considerably faster than other browsers at running javascript.
    • Javascript is used for more than just web scripts - Google has been using them internally for some services (via V8), and recently, Node.JS has appeared which uses V8. My companies cloud framework is written in Node, to allow us to transition easily from Actionscript on client PCs to Javascript on cloud servers.
  • mos (unregistered) in reply to Drew
    Drew:
    We need to create the Academy for the Advancement of Amazing Code (AAAC) so we can give this an Academy award for most useful code ever.

    Why not call it Academy for Advancement of Amazing and Ridiculous Gargabe (AAARGH) ?

  • xxx (unregistered) in reply to The Nerve
    The Nerve:
    xxx:
    The Nerve:
    A Javascript compiler is a BIG WTF.
    And what do you think modern browsers contain? You know, the thingie you use to *run* JavaScript code? Hello?
    Seriously? Ok, maybe they don't teach this in college anymore.

    <snipped painful idiocy>

    Everyone Else On TDWTF:
    <snipped uproarious laughter>
    How does it feel to be laughed off the board junior? This is the wrong place to be making wild guesses about things you're clearly not familiar with but feel free to come back when you make it out of high school.
  • Skilldrick (unregistered) in reply to xxx
    xxx:
    The Nerve:
    xxx:
    The Nerve:
    A Javascript compiler is a BIG WTF.
    And what do you think modern browsers contain? You know, the thingie you use to *run* JavaScript code? Hello?
    Seriously? Ok, maybe they don't teach this in college anymore.

    <snipped painful idiocy>

    Everyone Else On TDWTF:
    <snipped uproarious laughter>
    How does it feel to be laughed off the board junior? This is the wrong place to be making wild guesses about things you're clearly not familiar with but feel free to come back when you make it out of high school.

    WINNER! (That'll teach anyone to think twice before calling JS a WTF)

  • Burpy (unregistered) in reply to Skilldrick
    Skilldrick:
    xxx:
    The Nerve:
    xxx:
    The Nerve:
    A Javascript compiler is a BIG WTF.
    And what do you think modern browsers contain? You know, the thingie you use to *run* JavaScript code? Hello?
    Seriously? Ok, maybe they don't teach this in college anymore.

    <snipped painful idiocy>

    Everyone Else On TDWTF:
    <snipped uproarious laughter>
    How does it feel to be laughed off the board junior? This is the wrong place to be making wild guesses about things you're clearly not familiar with but feel free to come back when you make it out of high school.

    WINNER! (That'll teach anyone to think twice before calling JS a WTF)

    JS is definitely a WTF. It's even worse than VB!

  • AndyC (unregistered)

    A rather mediocre WTF that was utterly saved by misguided comments about JavaScript compilation. Well done that man, I'm still chuckling at the thought.

  • Professor Shitston Piss Phd. (unregistered)

    Once again evidence abounds that the vast majority of TDWTF submitters and users are more clueless about programming than their 'victims'. The comments on this story are way more entertaining than the main article, which isn't actually a WTF at all.

    Oh, and The Nerve, please don't stop posting! Have you got a blog? If not, you definately need one, I'd looooove to have somewhere I could keep up to date with your insightful thoughts about programming, and I'm sure I'm not alone!

  • (cs) in reply to Matt
    Matt:
    Mmmh... He forgot to have a "return true;" at the end of the function.
    Doesn't need one. JavaScript implicitly returns true from every function unless told otherwise. It's nice to have it for completion's sake for those who don't know that...

    Addendum (2010-07-22 09:16): Addendum: Testing a.contains(new Object()) most definitely is a WTF as it can never be true. Type: var X = new Object();[X, 3].indexOf(new Object()) into Firebug and notice you get -1 (which means .contains, if implemented, returns false).

  • (cs)

    I certainly there's a <noscript> fail-safe on the HTML page!

  • Design Pattern (unregistered) in reply to MrBester
    MrBester:
    Testing a.contains(new Object()) most definitely is a WTF as it can never be true. Type: var X = new Object();[X, 3].indexOf(new Object()) into Firebug and notice you get -1 (which means .contains, if implemented, returns false).
    And who guarantees that the JavaScript implementation of new does not add the created Object to every Array in sight?

    It clearly would be a broken implementation, but the whole point of these tests is to check if there are errors in the Javascript implementation!

    CAPTCHA: ludus A script language for playing around.

  • Leo (unregistered)

    Whether it's compiled or not, Javascript is still TRWTF.

  • noland (unregistered) in reply to xxx
    xxx:
    The Nerve:
    xxx:
    The Nerve:
    A Javascript compiler is a BIG WTF.
    And what do you think modern browsers contain? You know, the thingie you use to *run* JavaScript code? Hello?
    Seriously? Ok, maybe they don't teach this in college anymore.

    <snipped painful idiocy>

    Everyone Else On TDWTF:
    <snipped uproarious laughter>
    How does it feel to be laughed off the board junior? This is the wrong place to be making wild guesses about things you're clearly not familiar with but feel free to come back when you make it out of high school.

    Don't be so rude. The Nerve is probably working with Microsoft, veteran JScript developer! (This would at least explain some issues with IE3.)

  • The Bytemaster (unregistered) in reply to Nome de Plume
    Nome de Plume:
    Javascript (ECMA Script standard) objects use a prototype rather than superclass based inheritance. This does not lend itself to compiled programs.

    Other languages, like Smalltalk and Python, also allow classes to change over the program's life-cycle. All such languages, I believe, must be interpreted.

    Tell that to Microsoft, who has implemented prototype behavior into their .Net Framework, and the multiple languages for it. They found a way to do it without it being interpreted.

  • ÃÆââ (unregistered)

    JScript!!! Now there's TRWTF.

  • Neil (unregistered) in reply to Englebart
    Englebart:
    They removed the ability for a Servlet to get first grab at the raw input stream. This is very necessary to support things like uploading of images! They seemed to assume that every post must be some form data!
    Ever heard of multipart form data, used to support things like uploading of images?
  • vereor (unregistered) in reply to The Bytemaster
    Tell that to Microsoft, who has implemented prototype behavior into their .Net Framework, and the multiple languages for it. They found a way to do it without it being interpreted.

    Simple, if you cripple the language by removing some of its most defining features, keeping most of the name but little of the spirit...

  • (cs) in reply to SeySayux
    SeySayux:
    Actually, that seems logical to me. He/she creates a new object and checks if it's not in the list. contains() should return true if and only if there existan element X is in the array, such that the object Y passed to contains() has the property that X == Y. Or at least, that's how I learned it. So, if for none of the elements X in the array holds that X == Y, in other words, the element X is not in the array, contains(Y) has to return false. That's what's tested here.

    Anyways, I'm back to writing unit tests for (C++) containers.

    Hopefully you only write tests and not code.

  • Jonathan (unregistered) in reply to The Nerve
    The Nerve:
    The only use for a JavaScript compiler would be so you could write standalone programs that ran faster. If you think the Javascript language has any merits that warrant you creating standalone applications using the language, then check into the psych ward at your local mental hospital. I would rather write lolcode.

    You should take a look at Node.JS, Appcelerator Titanium, Adobe AIR and JSDB. Lots of psychs out there.

  • Jonathan (unregistered) in reply to Matt
    Matt:
    Mmmh... He forgot to have a "return true;" at the end of the function.

    That would be actually required in strict mode according to the ECMAScript Harmony spec.

  • College Freshman (unregistered) in reply to The Nerve

    Sadly, it doesn't even take a college student to google before posting stupid stuff.

Leave a comment on “Testing Fundamentals ”

Log In or post as a guest

Replying to comment #315193:

« Return to Article