News for hackers. Stuff that matters.
Re:Show HN: Imba – I have spent 7 years creating a programmi... by mg on Tuesday August 17, 2021 @06:07AM (#28208123)
One thing that irks me about Javascript is "const". I think it should have been called "con". "var", "let", "con".

So the first thing I did here is look up the docs and see how variables are declared. Aaarghh.. "let" and "const" again :)

Re:Show HN: Imba – I have spent 7 years creating a programmi... by lucideer on Tuesday August 17, 2021 @06:15AM (#28208177)
Why do you think this?

"const" seems clearer to me. "con" seems very open to misinterpretation: could mean many things.

Are there any advantages to "con" over "const"?

Re:Show HN: Imba – I have spent 7 years creating a programmi... by mstade on Tuesday August 17, 2021 @06:25AM (#28208253)
My guess is the OP dislikes the difference in keyword length.
Re:Show HN: Imba – I have spent 7 years creating a programmi... by cgag on Tuesday August 17, 2021 @09:31AM (#28209630)
I just always use let because it looks better. Const provides pretty much no value in js anyway.
Re:Show HN: Imba – I have spent 7 years creating a programmi... by jsf01 on Tuesday August 17, 2021 @09:50AM (#28209814)
It is useful for code readability. When you’re skimming and trying to understand a large chunk of code, if almost all the variables are declared with “const” and then you come across a “let”, you immediately know to look for where it will be mutated elsewhere.
Re:Show HN: Imba – I have spent 7 years creating a programmi... by __ryan__ on Tuesday August 17, 2021 @08:23AM (#28209083)
I've thought about this a lot. I considered "con" for constants. I don't hate it. It also works as a double entendre-- "con" in Spanish means "with". So the following code could be read as "with name equal to Brad".

  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.
Re:Show HN: Imba – I have spent 7 years creating a programmi... by Shorel on Tuesday August 17, 2021 @09:52PM (#28216942)
Spanish native here. I would never read it like that.

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.

Re:Show HN: Imba – I have spent 7 years creating a programmi... by Zababa on Tuesday August 17, 2021 @09:51AM (#28209831)
> It also works as a double entendre-- "con" in Spanish means "with".

Triple even! In French it's the equivalent of "cunt".

Re:Show HN: Imba – I have spent 7 years creating a programmi... by CRConrad on Wednesday August 18, 2021 @05:29PM (#28227423)
And in English, to go full circle, a con is what a con man pulls; a confidence trick.

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...

Re:Show HN: Imba – I have spent 7 years creating a programmi... by Zababa on Thursday August 19, 2021 @09:37AM (#28233655)
> 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.

Re:Show HN: Imba – I have spent 7 years creating a programmi... by amalantony06 on Tuesday August 17, 2021 @06:11AM (#28208154)
Why does const irk you? const sounds a lot clearer than con. Is that your primary criteria for picking a language? ;)
Re:Show HN: Imba – I have spent 7 years creating a programmi... by mg on Tuesday August 17, 2021 @06:24AM (#28208241)
I think it has three reasons:

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.

Re:Show HN: Imba – I have spent 7 years creating a programmi... by jazzyjackson on Tuesday August 17, 2021 @06:31AM (#28208299)
As far as code being visually appealing, for me those two lines are the least of that code’s troubles.

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.

Re:Show HN: Imba – I have spent 7 years creating a programmi... by CRConrad on Wednesday August 18, 2021 @05:47PM (#28227592)

   con map = ...

   let rec = ...
Re:Show HN: Imba – I have spent 7 years creating a programmi... by veidr on Tuesday August 17, 2021 @08:16AM (#28209035)
You are obviously right.

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.)

Re:Show HN: Imba – I have spent 7 years creating a programmi... by somebee on Tuesday August 17, 2021 @06:10AM (#28208145)
Tbh, var is actually deprecated since v1, so any mention of var in the docs is a mistake. Are there any other languages using 'con' for constants?
Re:Show HN: Imba – I have spent 7 years creating a programmi... by veidr on Tuesday August 17, 2021 @08:27AM (#28209101)
No, but there should be!!
Re:Show HN: Imba – I have spent 7 years creating a programmi... by OJFord on Tuesday August 17, 2021 @06:47AM (#28208419)
I've never used a language with a 'cons' keyword, but nevertheless that's what I'd assume your 'con' was, if you didn't tell me otherwise.

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.

Re:Show HN: Imba – I have spent 7 years creating a programmi... by scns on Tuesday August 17, 2021 @06:12AM (#28208163)
Good idea IMO. That feature should be pretty easy to add (famous last words).
Re:Show HN: Imba – I have spent 7 years creating a programmi... by nsonha on Tuesday August 17, 2021 @10:35AM (#28210300)
if we want to nitpick I hate the fact that many dynamic languages need keywords to express very little information.

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.

Re:Show HN: Imba – I have spent 7 years creating a programmi... by Zababa on Tuesday August 17, 2021 @06:16AM (#28208185)
Is the difference in length bothering you? In that case I find that let for immutable and var for mutable is pretty good, although for a language that's lose to JS that might not be a good idea. Maybe let for mutable like in JS, and val for immutable? (inspired by Scala).
Re:Show HN: Imba – I have spent 7 years creating a programmi... by jazzyjackson on Tuesday August 17, 2021 @06:25AM (#28208246)
Personally I don’t use any languages with reserved words
Re:Show HN: Imba – I have spent 7 years creating a programmi... by therufa on Tuesday August 17, 2021 @07:05AM (#28208533)
that limits the number of languages to a handful. like brainfuck and similar ones. doesn't it?
Re:Show HN: Imba – I have spent 7 years creating a programmi... by jhgb on Tuesday August 17, 2021 @08:06AM (#28208979)
Lisps don't have reserved words, generally.
Re:Show HN: Imba – I have spent 7 years creating a programmi... by jazzyjackson on Tuesday August 17, 2021 @08:12AM (#28209013)
Not even cons and defun?
Re:Show HN: Imba – I have spent 7 years creating a programmi... by jhgb on Tuesday August 17, 2021 @08:31AM (#28209129)
Depends on what you mean by "reserved word". In Common Lisp, you can define your own cons and defun, provided that you're not attempting to mutate the respective symbols from the COMMON-LISP package. That can be achieved by either defining your own cons and defun and shadowing the cons and defun from the COMMON-LISP package (typically for function or macro bindings), or just straight up using cons and defun from the COMMON-LISP package in "legal" ways - for example (let ((cons 1) (defun 2)) (list cons defun)) is legal and evaluates as '(1 2) since using those two symbols as names for lexical variables doesn't break the running Lisp in any way. In the former case (of defining your own functions/macros accessed as "unqualified" cons or defun from your own code) it's up to you if you consider cons and defun to be "reserved words" based on their package or not (packages for reserved words being something that languages explicitly recognizing the concept of a reserved word don't seem to have, so it's not clear how this should qualify). In Scheme, a Lisp-1, it's kind of free-for-all, especially in R5RS where you don't even have to bother with hiding standard bindings.
Re:Show HN: Imba – I have spent 7 years creating a programmi... by jazzyjackson on Tuesday August 17, 2021 @08:12AM (#28209007)
APL cheats by making everything a symbol.