logoalt Hacker News

TheOtherHobbestoday at 2:54 PM4 repliesview on HN

C syntax was never that great. It's basically mnemonic PDP-11 assembler with a few added data structures.

js is mutant C with dementia - hacked together over over a fortnight, full of inconsistencies and weird corners.

    console.log(1 + "2"); // "12"
    console.log(1 - "2"); // -1
    console.log(NaN === NaN); // false
    console.log(+0 === -0); // true

    const obj = {};
    console.log(obj.foo); // undefined, not an error

Replies

Dwedittoday at 10:18 PM

C syntax dropped the ball badly on operator precedence. Left Shift <<, Right Shift >>, and Bitwise And & should have been at the same priority as multiplication or division, while Bitwise Or (|) should have been at the same priority as addition.

bryanrasmussentoday at 3:39 PM

NaN is a standardized dynamic languages datatype governed by IEEE 754, this is not something to complain about as its behavior is part of the official standard and for good reason, as outlined in the standard.

show 1 reply
flufluflufluffytoday at 6:41 PM

None of those examples are showing something you find wrong with the syntax

lezojedatoday at 3:38 PM

[dead]