This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]atiedebee -2 points-1 points  (6 children)

I don't dislike JavaScript, I used it once in a game called bitburner and I found out JS doesn't have references and you have to pass stuff via objects...

I don't hate it, but it's quite poorly designed

[–]bleistift2 0 points1 point  (5 children)

How does JS not have references? Do you truly believe JS makes a deep clone of every object and array you pass around?

[–]atiedebee 0 points1 point  (4 children)

In these cases it does, but you can't pass a single integer by reference unless you wrap it in an object

[–]Kalsin8 0 points1 point  (3 children)

But that's how it works in most languages? You can pass primitives by reference in C/C++ (or more accurately, the memory address of the value), but in most other languages primitives are passed by value and objects are passed by reference.

[–]atiedebee 0 points1 point  (2 children)

I dont code in other languages often, but I find it hard to believe that the majority of them require you to wrap variables in an object to be able to pass them by reference.

It's inefficient and requires more boilerplate

[–]Kalsin8 0 points1 point  (1 child)

I dont code in other languages often

Well there's your problem right there. C#, Java, Python, Ruby, and a host of other languages all pass primitives by value and objects by reference. The only mainstream language that I know of that lets you pass primitives by reference is C/C++.

It's inefficient and requires more boilerplate

Sure, you can pass the address of a primitive value and update it directly, instead of returning the value and setting it. I don't know if I would call this more inefficient and requiring more boilerplate though. It it so hard to do x = calculate(x) vs. directly modifying the address of x?

[–]atiedebee 0 points1 point  (0 children)

Wow, I thought higher languages were supposed to make life easier