// this is javascript!



  • Just come across the following in some javascript I'm going through - makes me worry for the sanity of the person who originally wrote it:
     
    if (begin != -1) // Note: != means "is not equal to"



  • You see this far too often, when people are learning a new language.

    I remember when most languages I dealt with used <> instead of !=

     

    Still though, I don't think anything compares with one of my favorites....
    Pascal meets C in ....

    The Secret to Better C



  • Either the writer is really new at programming (a self-made "webdesigner" trying it's hand at javascript ?) and wants to be sure to understand its own code, or a programmer worried about the next one that'll have to maintain his code...

    Personnaly, I prefer a good comment at the beginning : // If you don't understand the following code : DON'T TOUCH IT !!!



  • @r3jjs said:

    You see this far too often, when people are learning a new language.

    I remember when most languages I dealt with used <> instead of !=



    <> and != both seemed very natural ways to say not equals (greater than or less than,  or a representation of equals with a slash through
    it, which is common in math), the only problem was remembering which one applied to the language you were working with.



  • How can this be a problem? Don't tell me there are languages out there that will not loudly fail immidiately when you try to run code using one instead of another? O_o



  • @Kokuma said:

    Either the writer is really new at programming (a self-made "webdesigner" trying it's hand at javascript ?) and wants to be sure to understand its own code, or a programmer worried about the next one that'll have to maintain his code...

    Personnaly, I prefer a good comment at the beginning : // If you don't understand the following code : DON'T TOUCH IT !!!

    I've gotten in the habit of breaking any code that will be handled by lower-level developers into three sections:

    // Configuration Variables

    ... 

    // Don't touch anything below here unless you know what you're doing

    ...

    // Don't touch anything below here unless you really, really, really know what you're doing
     



  • @SuperousOxide said:

    @r3jjs said:

    You see this far too often, when people are learning a new language.

    I remember when most languages I dealt with used <> instead of !=



    <> and != both seemed very natural ways to say not equals (greater than or less than, or a representation of equals with a slash through
    it, which is common in math), the only problem was remembering which one applied to the language you were working with.

     What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)? though, you know VB would just use ≶ instead.



  • @Random832 said:

    What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

    Please, please tell us you're just trolling. 



  • @Zylon said:

    @Kokuma said:

    Either the writer is really new at programming (a self-made "webdesigner" trying it's hand at javascript ?) and wants to be sure to understand its own code, or a programmer worried about the next one that'll have to maintain his code...

    Personnaly, I prefer a good comment at the beginning : // If you don't understand the following code : DON'T TOUCH IT !!!

    I've gotten in the habit of breaking any code that will be handled by lower-level developers into three sections:

    // Configuration Variables

    ... 

    // Don't touch anything below here unless you know what you're doing

    ...

    // Don't touch anything below here unless you really, really, really know what you're doing
     

     

    You need one more section at the bottom: 

     
    // Don't even READ anything below here unless your last name is Ritchie or Kernighan



  • @Random832 said:

     What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)? though, you know VB would just use ≶ instead.

    Because the ≠ key is conveniently placed between Caps Lock and Ϡ



  • @Random832 said:

    @SuperousOxide said:
    @r3jjs said:

    You see this far too often, when people are learning a new language.

    I remember when most languages I dealt with used <> instead of !=



    <> and != both seemed very natural ways to say not equals (greater than or less than, or a representation of equals with a slash through
    it, which is common in math), the only problem was remembering which one applied to the language you were working with.

     What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)? though, you know VB would just use ≶ instead.

    APL has been available since 1964.

     



  • > Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

     

    Better yet:

     

    Algol had  ≠ in 1960

     CDC's scientific character set had all these in 1963:




     



  • @SuperousOxide said:

    @r3jjs said:

    You see this far too often, when people are learning a new language.

    I remember when most languages I dealt with used <> instead of !=

    >
    and != both seemed very natural ways to say not equals (greater than or
    less than, or a representation of equals with a slash through it, which
    is common in math),

      I always thought that was the same exclamation mark that stands for the 'not' operator! 

    @SuperousOxide said:

    the only problem was remembering which one applied to the language you were working with.

     
    What's even worse is VHDL, which has invented the '/=' operator to mean
    not-equal.  Some of my colleagues spend so much more of their time
    writing VHDL than C that they keep on writing it in C - they mean
    not-equal, but what they get is the assignment-by-division operator...
    ouch!  I ended up adding a new warning to the compiler to help us
    stay clear of that one.

     



  • @Zylon said:

    @Random832 said:

    What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

    Please, please tell us you're just trolling. 

    You will doubtlessly be distressed to know that AppleScript does indeed support proper operators as described. After all, you can type ≠ as easily as (IIRC) opt-=.



  • @Daniel Beardsmore said:

    @Zylon said:

    @Random832 said:

    What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

    Please, please tell us you're just trolling. 

    You will doubtlessly be distressed to know that AppleScript does indeed support proper operators as described. After all, you can type ≠ as easily as (IIRC) opt-=.

    I was writing ¬= in REXX over ten years ago, long before unicode support. You should see APL, where you can write things like  (∼R∈R∘.×R)/R←1↓⍳R, but need a second keyboard with different symbols on it.



  • @asuffield said:

    @Daniel Beardsmore said:
    @Zylon said:

    @Random832 said:

    What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

    Please, please tell us you're just trolling. 

    You will doubtlessly be distressed to know that AppleScript does indeed support proper operators as described. After all, you can type ≠ as easily as (IIRC) opt-=.

    I was writing ¬= in REXX over ten years ago, long before unicode support. You should see APL, where you can write things like  (∼R∈R∘.×R)/R←1↓⍳R, but need a second keyboard with different symbols on it.

    Last time I remember having to deal with such a keyboard, I was trying to play church organ. Some version of MS Word could replace smileys made of colon, dash and parenthesis by a smiley symbol. Is there any code editor that can do such stuff with "!=" ? I mean, change it to ≠ , not a smiley.
     



  • @Zylon said:

    @Random832 said:

    What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

    Please, please tell us you're just trolling. 

     I guess I forgot that ≤, ≥, and ≠ (also ≈, but that's not as useful for programming) aren't on windows keyboard layouts. (though, the "has existed since 1991" was meant as much to imply that they should get off their asses and support entry of these symbols as to say programming languages should use them)

    The other thing is, backslash was invented specifically for the purpose of having /\ AND and / OR. so why don't any modern languages use those?

    And, anyway, I wasn't saying <> or != shouldn't be supported (in fact, I don't see a reason they shouldn't both be supported), just that the proper symbols should be available as an alternative.

    And maybe I was trolling a little with the ≶ bit.
     



  • @DaveK said:

    What's even worse is VHDL, which has invented the '/=' operator to mean
    not-equal.  Some of my colleagues spend so much more of their time
    writing VHDL than C that they keep on writing it in C - they mean
    not-equal, but what they get is the assignment-by-division operator...
    ouch!  I ended up adding a new warning to the compiler to help us
    stay clear of that one.

     

    that's not just a VHDL thing.  it's been this way since at least fortran77, possibly earlier...

     

     



  • @Random832 said:

    @Zylon said:

    @Random832 said:

    What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

    Please, please tell us you're just trolling. 

     I guess I forgot that ≤, ≥, and ≠ (also ≈, but that's not as useful for programming) aren't on windows keyboard layouts. (though, the "has existed since 1991" was meant as much to imply that they should get off their asses and support entry of these symbols as to say programming languages should use them)

    I certainly wouldn't mind optional support for ≠, ≤, and ≥, considering that they are [i]easier[/i] (one less keystroke) to type on OS X than !=, >=, and <=.



  • @Kiss me I'm Polish said:

    @asuffield said:
    @Daniel Beardsmore said:
    @Zylon said:

    @Random832 said:

    What I don't get is... Unicode has existed since 1991. Isn't it time for if (begin ≠ -1)?

    Please, please tell us you're just trolling. 

    You will doubtlessly be distressed to know that AppleScript does indeed support proper operators as described. After all, you can type ≠ as easily as (IIRC) opt-=.

    I was writing ¬= in REXX over ten years ago, long before unicode support. You should see APL, where you can write things like  (∼R∈R∘.×R)/R←1↓⍳R, but need a second keyboard with different symbols on it.

    Last time I remember having to deal with such a keyboard, I was trying to play church organ. Some version of MS Word could replace smileys made of colon, dash and parenthesis by a smiley symbol. Is there any code editor that can do such stuff with "!=" ? I mean, change it to ≠ , not a smiley.
     

    I'm sure there's an emacs thing to handle that.  There are input modes for all sorts of stuff like that.  For example, one of the European composition modes lets you type :o to get ö and so on. 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.