JavaScript WTF



  • @djork said:

    That's why the folks developing, using, and advocating them prefer the term "dynamic language."

    Can't force themselves to just call it an "interpreted language", eh? 



  • @djork said:

    @bstorer said:

    Just remember, "scripting language" is an iffy term.  If you read that a language is a scripting language and preconceive that it is somehow weaker or only for odds-and-ends programming, you're cheating yourself.  Treat them the same way you do C++ and C#: as Real Languages for Real Programmers.

    That's why the folks developing, using, and advocating them prefer the term "dynamic language."  They are far more dynamic than their compiled counterparts when it comes to exactly what you can do at run-time.  But that leaves me wondering, then: what does make something a scripting language?  Lua, AppleScript?

    I dislike using the term dynamic in this context, because it has other meanings.  For example, Objective-C is a fairly dynamic, but is also compiled.  BASIC, on the other hand, is anything but dynamic.

    @Zylon said:

    Can't force themselves to just call it an "interpreted language", eh?

    But what qualifies as interpreted?  Is it interpreted if it's JIT-compiled?  If it uses bytecode?  What about things that can change the preceeding answers like Ch, gcj, Rhino and Parrot?  There are shades of gray that nobody seems to agree upon.



  • @bstorer said:

    Just remember, "scripting language" is an iffy term.  If you read that a language is a scripting language and preconceive that it is somehow weaker or only for odds-and-ends programming, you're cheating yourself.  Treat them the same way you do C++ and C#: as Real Languages for Real Programmers.

    Careful! Some of them really are. People who treat all languages as Real Languages end up doing it to something like Bourne shell, and then they go and create shoop.

    Another favourite abuse of people who have been at the crack pipe too long is Prolog. Do not attempt to write normal software in Prolog!



  • @bstorer said:

    @djork said:
    @bstorer said:

    Just remember, "scripting language" is an iffy term.  If you read that a language is a scripting language and preconceive that it is somehow weaker or only for odds-and-ends programming, you're cheating yourself.  Treat them the same way you do C++ and C#: as Real Languages for Real Programmers.

    That's why the folks developing, using, and advocating them prefer the term "dynamic language."  They are far more dynamic than their compiled counterparts when it comes to exactly what you can do at run-time.  But that leaves me wondering, then: what does make something a scripting language?  Lua, AppleScript?

    I dislike using the term dynamic in this context, because it has other meanings.  For example, Objective-C is a fairly dynamic, but is also compiled.  BASIC, on the other hand, is anything but dynamic.

    It's pretty much a null term. Whenever you see somebody talk about a language being "dynamic", just substitute "yellow". What they said will still be about as meaningful and it'll be easier to understand.

    The common feature of the languages to which it is typically applied is a lack of compile-time correctness checks, nothing more. It's the old "oh, the checks in language X are very cumbersome. Let's make language Y not have them at all" fallacy. This may be misinterpreted as allowing you to "do more", but it really doesn't.

    @Zylon said:
    Can't force themselves to just call it an "interpreted language", eh?

    But what qualifies as interpreted?  Is it interpreted if it's JIT-compiled?  If it uses bytecode?  What about things that can change the preceeding answers like Ch, gcj, Rhino and Parrot?  There are shades of gray that nobody seems to agree upon.

    There is no such thing as an interpreted language. Implementations are interpreted, not languages. This is one of the most fundamental points behind the Church-Turing thesis: compilation, interpretation, and any other ways of executing a Turing-complete language are indistinguishable. You simply cannot create a Turing-complete language that has any impact on the method of execution used. Any method that works for one language, works for all of them.

    The question is therefore meaningless, so it's no surprise that nobody can agree on an answer. 



  • @asuffield said:

    @bstorer said:

    Just remember, "scripting language" is an iffy term.  If you read that a language is a scripting language and preconceive that it is somehow weaker or only for odds-and-ends programming, you're cheating yourself.  Treat them the same way you do C++ and C#: as Real Languages for Real Programmers.

    Careful! Some of them really are. People who treat all languages as Real Languages end up doing it to something like Bourne shell, and then they go and create shoop.

    Another favourite abuse of people who have been at the crack pipe too long is Prolog. Do not attempt to write normal software in Prolog!

    But thanks to InterProlog you can combine Prolog and Java!  I can't think of a more promising combination...



  • @asuffield said:

    There is no such thing as an interpreted language. Implementations are interpreted, not languages.

    See, this is what's defined as being a "pedantic douchebag".



  • @aib said:

    Heck, Notepad even has a bug which will occasionally destroy some of your text and scramble the rest!

    This isn't simply the bug where after a Save, Notepad redoes all the word-wrapping, moves the insertion point to another character, and doesn't refresh the window?

    I've never had it actually damage a file, but the above confusion can lead to you altering text incorrectly.

    Isn't Notepad just a Windows multi-line text box wrapped up in a window? You may well find that this prevents you from reading/writing line numbers with word-wrap enabled, since it may well return and accept virtual line numbers in wrapped mode. I know of a certain *ahem* package where this is precisely how multi-line text boxes work: the insertion point position is virtual based on the current rendering.



  • @Zylon said:

    @asuffield said:

    There is no such thing as an interpreted language. Implementations are interpreted, not languages.

    See, this is what's defined as being a "pedantic douchebag".

    To formulate it less, um, directly: I think we all know this. Otherwise, Basic wouldn't have been able to turn from interpreted to compiled between two versions.
    But there are languages where the most commonly used implementation is an interpreter and others where it is a compiler. Strictly speaking, C isn't a "compiled language" because somewhere someone could have written an interpreter for it. But that doesn't matter because everyone uses compiler implementations for it.

    Thus I think "Language where the major implementation is an interpreter (compiler)" is a good definition for the term "interpreted (compiled) language" how it's used 80% of the time. But because like mentioned above, today there exist other forms of implementation than just 100% static compiler and 100% in place interpreter, the criteria starts to blur and to become useless. So it's a useless question to ask, but if you use a practical definition and not the academic one, it's still a "valid" question.

    There is one language which is still 100% interpreted and probably will stay that way for quite some time: Machine code ;)



  • @PSWorx said:

    @Zylon said:

    @asuffield said:

    There is no such thing as an interpreted language. Implementations are interpreted, not languages.

    See, this is what's defined as being a "pedantic douchebag".

    To formulate it less, um, directly: I think we all know this. Otherwise, Basic wouldn't have been able to turn from interpreted to compiled between two versions.
    But there are languages where the most commonly used implementation is an interpreter and others where it is a compiler. Strictly speaking, C isn't a "compiled language" because somewhere someone could have written an interpreter for it. But that doesn't matter because everyone uses compiler implementations for it.

    Thus I think "Language where the major implementation is an interpreter (compiler)" is a good definition for the term "interpreted (compiled) language" how it's used 80% of the time. But because like mentioned above, today there exist other forms of implementation than just 100% static compiler and 100% in place interpreter, the criteria starts to blur and to become useless. So it's a useless question to ask, but if you use a practical definition and not the academic one, it's still a "valid" question.

    There is one language which is still 100% interpreted and probably will stay that way for quite some time: Machine code ;)

    I'd say the only actually useful distinction is one of usage. Do you, in the process of preparing to use the software, translate the source code (i.e. the form you actually open in a text editor and compose the program in) into some other format, which can then be (whether or not it is) distributed separately for other people to use? Or is the source code the only format in which it is possible to distribute a working copy of a program written in the language) 



  • @PSWorx said:

    Thus I think "Language where the major implementation is an interpreter (compiler)" is a good definition for the term "interpreted (compiled) language" how it's used 80% of the time. But because like mentioned above, today there exist other forms of implementation than just 100% static compiler and 100% in place interpreter, the criteria starts to blur and to become useless. So it's a useless question to ask, but if you use a practical definition and not the academic one, it's still a "valid" question.

    This kind of thinking is deeply flawed. You cannot define "the major implementation" using anything other than a personal opinion, and it is irrelevant when making any decision. If you start by asking that question, you will always come to the conclusion "follow the herd".

    Questions which are based on bogus assumptions will always lead you to invalid conclusions. Playing word games will not change this.

     

    There is one language which is still 100% interpreted and probably will stay that way for quite some time: Machine code ;)

    Actually, many CPUs have been JITting it for over a decade now (and IBM have been doing it since the 1980s, on System 3x0). Nobody builds a CPU that executes x86 machine code directly, because that's actually more complicated and a heck of a lot slower. Only the VLIW and MIPS/ARM embedded CPUs directly execute their code (and a lot of the not-quite-so-embedded chips are moving away from it).



  • @Random832 said:

    @PSWorx said:
    @Zylon said:

    @asuffield said:

    There is no such thing as an interpreted language. Implementations are interpreted, not languages.

    See, this is what's defined as being a "pedantic douchebag".

    To formulate it less, um, directly: I think we all know this. Otherwise, Basic wouldn't have been able to turn from interpreted to compiled between two versions.
    But there are languages where the most commonly used implementation is an interpreter and others where it is a compiler. Strictly speaking, C isn't a "compiled language" because somewhere someone could have written an interpreter for it. But that doesn't matter because everyone uses compiler implementations for it.

    Thus I think "Language where the major implementation is an interpreter (compiler)" is a good definition for the term "interpreted (compiled) language" how it's used 80% of the time. But because like mentioned above, today there exist other forms of implementation than just 100% static compiler and 100% in place interpreter, the criteria starts to blur and to become useless. So it's a useless question to ask, but if you use a practical definition and not the academic one, it's still a "valid" question.

    There is one language which is still 100% interpreted and probably will stay that way for quite some time: Machine code ;)

    I'd say the only actually useful distinction is one of usage. Do you, in the process of preparing to use the software, translate the source code (i.e. the form you actually open in a text editor and compose the program in) into some other format, which can then be (whether or not it is) distributed separately for other people to use? Or is the source code the only format in which it is possible to distribute a working copy of a program written in the language)

    Even with C source code is the only really useful way to distribute the program if it's cross-platform.  Okay, so that's nitpicking.  But what about Rhino's ability to compile Javascript into Java class files?  Or any of the other compilers for the so-called interpreted languages?  There's even a compiler for Brainfuck.  Back to the drawing board, eh?



  • @Daniel Beardsmore said:

    @aib said:
    Heck, Notepad even has a bug which will occasionally destroy some of your text and scramble the rest!

    This isn't simply the bug where after a Save, Notepad redoes all the word-wrapping, moves the insertion point to another character, and doesn't refresh the window?

    I've never had it actually damage a file, but the above confusion can lead to you altering text incorrectly.

    Isn't Notepad just a Windows multi-line text box wrapped up in a window? You may well find that this prevents you from reading/writing line numbers with word-wrap enabled, since it may well return and accept virtual line numbers in wrapped mode. I know of a certain *ahem* package where this is precisely how multi-line text boxes work: the insertion point position is virtual based on the current rendering.

    Might be. In that case, I helped it damage the data, but it's still a WTF. Hard to see 'unrepaints'  unless you select text.

    Also, it replaces word wraps with hard CRLFs, right? Now THAT's scrambling.

    And let's not even get started on the whole CR/LF thing. "[x] Preserve line ending format" FTW. 



  • @Daniel Beardsmore said:

    @aib said:
    Heck, Notepad even has a bug which will occasionally destroy some of your text and scramble the rest!

    This isn't simply the bug where after a Save, Notepad redoes all the word-wrapping, moves the insertion point to another character, and doesn't refresh the window?

    I've never had it actually damage a file, but the above confusion can lead to you altering text incorrectly.

    Isn't Notepad just a Windows multi-line text box wrapped up in a window? You may well find that this prevents you from reading/writing line numbers with word-wrap enabled, since it may well return and accept virtual line numbers in wrapped mode. I know of a certain *ahem* package where this is precisely how multi-line text boxes work: the insertion point position is virtual based on the current rendering.

    Where I work, we often distribute a script that the client will install on their website to facilitate integration with our CRM app. In one case, there were so many installation variables that we had to document the editing of the script file to tailor the behavior to their liking, which we did so as cleanly as possible (business logic variables sprinkled liberally with comments from us near the top of the script).

    At the time (2002), whenever we or a client edited anything in Notepad, it would *completely* fuck up the Unix line-endings, which the interpreter of course hated. We had to put out a moratorium on editing the file with Notepad, since as soon as you saved anything, LFs would come out, random CRLFs would sometimes come in and break up statements from comment lines onto execution lines, etc etc. Hopefully NP has improved since then but I've just gotten used to NP++ instead. We still have a notice in our knowledge base urging them to use Wordpad if available instead and a big "don't blame us if NP fucks up your script file" disclaimer.



  • A friend asked me once why Notepad was taking ages (and memory worth more than twice the size of the file) to open up a small (1-2MB) file. I could only give them the obvious answer...



  • wooow... wikipedia is suckage: http://en.wikipedia.org/wiki/Scripting_language

     

    The first line reads as: Scripting languages (commonly called script languages) are computer programming languages that are typically interpreted and can be typed directly from a keyboard.

    1) "commonly called script langauges", no... wow

    2) "typically interpreted" eh? How else do they run, gnomes?

    3)  I think you all can find the last one h0h0. Actually if you continue reading it almost gets worse.... perhaps a script kiddie wrote this? h0h0

     

     edit:

    Actually... wow, it lists JSP as a scripting language! u know cause uh, it's java scripting pages you know! Oh boy, check out the discussion page, some big arguements brewing over there... " . You can compile or interpret C, you can compile or interpret Basic."



  • @Vechni said:

    wooow... wikipedia is suckage: http://en.wikipedia.org/wiki/Scripting_language

    The article underscores several times that "scripting language' is not a formal definition and that there is no distinction between it and "other" languages.

    But I agree that the article then tries to define it anyway -- and fails. Personally I'd suggest reducing this article to a quarter of its size.



  • @Vechni said:

    wooow... wikipedia is suckage: http://en.wikipedia.org/wiki/Scripting_language

    This article is stunningly bad. It is obvious that large quantities of drugs were consumed, imbibed, inhaled, injected, or inserted while it was being written.

    If I cared enough, I'd put it up for deletion. There is nothing in there worth having.



  • @aib said:

    Might be. In that case, I helped it damage the data, but it's still a WTF. Hard to see 'unrepaints'  unless you select text.

    Minimise and restore the window. Selecting text, even ctrl-A, won't quite help you if the text was rendered on fewer lines as ctrl-A won't cause those to be painted out.

    @aib said:

    Also, it replaces word wraps with hard CRLFs, right? Now THAT's scrambling.

    That is one of the weirdest design flaws I've ever seen. Starting with opening a file or creating a new file, all text read and typed is soft-wrapped dynamically. The instant you hit ctrl-S, the text in the window is hard-wrapped to the current window width! Note that I said "text in the window": the file on disc does not have these extra line breaks. If you alter one of these hard-wrapped lines, and then save, the hard-wrapping is "removed" from the file (even though internally, they do not exist), the file is reflowed, written out, and then the window is not redrawn to show what's happened.

    How such a mess ever got spawned at Redmond, I do not know. I don't think I want to know ........ well, maybe I do ;-) Even if I'd laugh myself to the mortuary.

    @aib said:

    And let's not even get started on the whole CR/LF thing. "[x] Preserve line ending format" FTW. 

    "Preserve"? It won't even read files with UNIX/Mac line endings.



  • @djork said:

    Call it ECMAScript, treat it like a functional language, and use it to do really cool things.  Suddenly JavaScript doesn't suck!  I love the language.

     

    Ding! It's not really that bad of a language. It gets a pretty bad rep because it generally gets developed via cut and paste, and all the "how to" guides perpetuate
    abominable code practices. It does have some quirks: I have no love for the object-method binding model (I much prefer LUA's syntactic sugar), and I'm not so happy
    with the (perhaps incorrect) need to include the "with" clause in the language. It would also be nice if the DOM bindings were more consistent, but a nice library like Prototype remedies that.
     



  • @Maciej said:

    @djork said:
    Call it ECMAScript, treat it like a functional language, and use it to do really cool things.  Suddenly JavaScript doesn't suck!  I love the language.

    Ding! It's not really that bad of a language. It gets a pretty bad rep because it generally gets developed via cut and paste, and all the "how to" guides perpetuate abominable code practices. It does have some quirks: I have no love for the object-method binding model (I much prefer LUA's syntactic sugar), and I'm not so happy with the (perhaps incorrect) need to include the "with" clause in the language. It would also be nice if the DOM bindings were more consistent, but a nice library like Prototype remedies that.

    Yeah, I'd list some of the big issues that make people uncomfortable with the language as:
    1. Incompatible implementations in the different browsers.
    2. The flood of bad information on the web.
    3. The fact that it owes its syntax to C, but it's design to Self.



  • @tster said:

    @Mal1024 said:

    C:\Windows\system32>mv notepad.exe notepad_save.exe

    C:\Windows\system32>cp <insert text editor of choice> ./notepad.exe

     C:\Windows\system32>chmod 777 notepad.exe

     

    mv: command not found

    cp: command not found

    chmod: command not found

     

    Please remember that the Windoze command line uses DOS commands. 

    If you don't have cygwin, then I assume that you are intelligent enough to figure out what commands those map to.  Honestly, I was just offering a solution to their woes and you are hear complaining that my move and copy commands are not the same as yours.  Grow up. 

     OK, OK - I wasn't actually trying to replace notepad myself, btw.
     



  • @tster said:

    @Mal1024 said:

    C:\Windows\system32>mv notepad.exe notepad_save.exe

    C:\Windows\system32>cp <insert text editor of choice> ./notepad.exe

     C:\Windows\system32>chmod 777 notepad.exe

     

    mv: command not found

    cp: command not found

    chmod: command not found

     

    Please remember that the Windoze command line uses DOS commands. 

    If you don't have cygwin, then I assume that you are intelligent enough to figure out what commands those map to.  Honestly, I was just offering a solution to their woes and you are hear complaining that my move and copy commands are not the same as yours.  Grow up. 

    I'm just not sure in what universe you would need chmod or any equivalent. Even if this weren't on windows, one would expect that <insert text editor of choice> already is executable (and you wouldn't need it to be writable, or, technically, readable)


Log in to reply