So the first thing I did here is look up the docs and see how variables are declared. Aaarghh.. "let" and "const" again :)
So the first thing I did here is look up the docs and see how variables are declared. Aaarghh.. "let" and "const" again :)
"const" seems clearer to me. "con" seems very open to misinterpretation: could mean many things.
Are there any advantages to "con" over "const"?
con name = 'Brad'
I can't help but feel that it's somewhat jarring though.If I had my druthers, I think I would choose "var" and "def" to declare mutable and immutable variables, respectively.
def PI = 3.1
def degreesToRadians = degrees => degrees * (PI / 180)
var degrees = 180
var radians = degreesToRadians(degrees)
Edit: After thinking about it some more, I think I prefer "const" over "con", but "def" over both.I have programmed in a couple languages where every single keyword was in Spanish: Logo and some flavours of Visual Basic.
Either everything is in English, or everything is in Spanish. There's no middle ground with mixed keywords.
'Var' and 'def' both sound good to me.
Triple even! In French it's the equivalent of "cunt".
Hey BTW, is a JS "const" really constant, or can it (like in some other languages) be changed after all? Because if it can, then it isn't really const but more of a con...
It's constant for things like numbers, but if you declare an array const, the only const things is the reference, the array can still mutate. con might be a good name for that.
The more often a construct is used in a language, the shorter I like it to be.
It groups variable definitions mentally by having them all the same length if they are "var", "let" and "con".
It would often make the code look more uniform which is more beautiful in my eyes. Example:
https://github.com/facebook/react/blob/cae635054e17a6f107a39...
I would prefer the lines 226 and 227 to start with "con" and "let". It would make the code visually more appealing to me.
I’m sympathetic to wanting code to have good aesthetics. If I was writing those lines I probably would have daydreamed for 5 minutes thinking of new names for map and record so that the equal signs would line up.
con map = ...
let rec = ...The 'const' nomenclature is an abomination before science and human progress. However, given the prior art, I don't think we can hold it against a new/emerging language.
Anders, help us! Do the right thing. You are the only one who can.
(Of course, 'const' could be grandfathered and still work forever. Right-minded people, please upvote this obviously-right person at least back to a neutral #000.)
I'm no particular JS fan, but 'const' is much clearer, it's a complete syllable, just like 'var' or 'func'. Yes 'fun' is used, but I think that's awkward for the same reason.
If js was made with types then the syntax `any x` (yeah lose the colon too, who gives a shit) is suficient to express that x is a variable, then `number x` could mean variable of type number, and `const number x` could mean constant of type number.