What is the most fucking retarded language and why is it javascript

What is the most fucking retarded language and why is it javascript
>object A = object B
>A is equal to A, which equals B, but also A equals object B individually
>B also equals A, which now equals B thereby not changing B
>write functions performed on A also apply to B, but read functions from A only apply to B
>write functions performed on B also apply to A WHICH EQUALS B, but read functions from B only apply to B
>for no intelligent reason, objects pass by reference to other objects, all the time
>but variables never ever ever pass by reference to another variable

it is scary to think how prevalent js is on the internet even though it is literally brainlet garbage.

int a = 0;
int b = 0;
for(int i=0; i < 4; i++){
a += i;
a = b;
if (i == 3){
print("a = " + a );
print("b = " + b );
}
}
//a = 0
//b = 0
>this makes sense

ArrayList c = new ArrayList();
ArrayList d = new ArrayList();
for(int i=0; i< 4; i++){
c.add(i);
c = d;
if (i == 3){
print("c length = " + c.size() );
print("d length = " + d.size() );
}
}
//c length = 3
//d length = 3
>mfw

this cant be real

...

That's not ever javascript code. I think it's related to Java thing where they had a pre-made object for all integers below 100, or something.

OP is a drooling retard. Say something nice about him.

I don't think I've ever written out of strict mode. In strict mode JS is retarded. Out of strict mode it is a drooling imbecile that just tries to fuck itself up

> a += i;
> does not alter the object; creates a new one and assigns it to a local variable

> c.add(i);
> alters existing object

You're dumb.

This is actually Java

the equivalent in js would be
var c = [ ];
var d = [ ];
for(i=0;i

And that's proper behavior. I don't see what you are so frustrated about.

how is this proper behaviour. if i wanted to add elements to d, i'd call d.push

both c and d start as their own instantiated variables. Setting c = d should empty c and leave d untouched.
what is this garbage.

Theres no intelligible use for setting one object equal to another.

>what are reference types
Pretty much every language does this senpai

You are confused. c and d are variables. They are not objects. They are variables and they hold either primitive type values or references to objects in them. Initially, c points to the first list you created, and d points to the second list you created. After c=d, they both point to the same list, the second one.

I swear js was made by a literal brainlet
> null true
> null>=0
> true
> null==0
> false
mfw
> 1 + "1"
> 2
> 1 - "1"
> NaN
I couldn't come up with this shit if I tried

It works rather well when you don't do things that don't make sense.

So...nothing?

No.

Give me one thing that makes sense in JS. Protip: you can't

Closures.

Yes, that is what happens.
But W H Y

that is destructive behaviour. It's destructively retarded actually.
after c=d, c list disappears and c.funcs apply to d list, while d list funcs also apply to d list.

you could do dumb shit like
a = b = c = d = e = f = g;
where a.push, b.push, c.push, d.push, e.push, f.push and g.push all do the same exact goddamned thing. how is this beneficial behaviour.

I mean, you are allowed to take a knife and stab yourself in a dick, and that's very much a destructive behavior, but that's not a reason to ban knives. This is how variables work, this is a core of a language.

PHP, definitely. The language is absolute trash, the stdlib has probably inspired several horror writers and the community is comprised almost entirely by complete morons.
I'll take JavaScript over PHP any day, thank you.

brainlet

...

I think he is surprised that c = d means d is assigned to c when the notation is usually the other way around.

But it is a good example of why verbosity is a good thing. You should be clear about what your code means.
But consistency in the language is a good place to start.

> c = d
> means
> d is assigned to c
> notation is usually the other way around

what

// c is 10
// d is 20
c = d
// the usual behavior is that both c and d should be 10 now


what

but its not how variables work.
integers, floats, strings, you can do
var a = 0.0;
var b = 2.9;
a += 2.3;
a = b;
//print a and b
>> a=2.9, b=2.9
a += 1.0;
b += 2.7;
//print a and b
>a=3.9, b=5.6
>a=b, but a and b both exist individually

this isn't destructive. It's pass by value.

you change those from variables to objects like lists, though, and instead of passing by value similarly, instead it passes by reference, which is retarded when everything else passes by value
a.push(i);
a=b;
//print a and b.size
>a=0, b=0
a.push(i);
b.push(i);
//print a and b.size
>a=2, b=2
>a=b, but a doesn't even exist and redirects to b

I explicitly wrote the answer fro you.
>They are variables and they hold either primitive type values or references to objects in them.

This _is_ how variables work. This is the case in a great amount of languages; of those I know, this is the case in Java, Javascript, C#, Perl, Python. This is also the case in C and C++, but in C++ you can also declare a variable to be a pointer to a primitive type as well as create a variable that holds a whole object itself and not just a reference to it - achieving whatever behavior you want.

>brainlet doesn't understand objects

a = 5
b = 10
a = b //a should be 5, b should be unchanged.

c = [1,2,3]
d = []
c = d // c should be []

If you didn't want a copy constructor, why use a language without pointers?

>a should be 5
you had one job

and I already told you that it's fuckin retarded and literally worthless.

this is how it should work:
var a = [ ];
var b = [ ];
for(i=0;iinstead it is:
>0 0
>0 0
>1 1
>1 1
>2 2
>2 2
>3 3
>3 3

D is assigned to c as in the value of d is assigned to c, as in c is given the value of d.

no it shouldn't, you're obviously a brainlet

I understand perfectly well that you are upset about how it works, but you don't have a case against any language because they all work like that. All you have is your opinion, and your opinion is worth literally nothing. I don't think that the behavior you're proposing makes any sense. It's my opinion. It's also not worth much. What's not an opinion, is the reality, where variables do work the way I described and where you are immensely upset by the fact that you are a a brainlet.

explain why the size of both ArrayList variables is 3 then faggot
>inb4 you can't

You add an item to an array 4 times: once to the first array you created, three times to the second array you created. When you do the first addition, c refers to the first array and d refers to the second array. When you do 3 remaining additions, both c and d refer to the second array.

>hur dur javascript works really well if you ignore basic rules of logic

People do elaborate on how basic rules of logic dictate what the result should be of a difference between a string and a number.

Yeah okay
you have explained multiple times that c = d makes c.actions the same as typing d.actions. this was never contested. This was the explicit issue brought to light. It's been said c = d is permanently destructive, and c.actions will no longer have an effect on anything onced attached to c, because c now redirects to d.

okay.

now you fuckin brainlet
Do you think you can explain why this would be an attractive or expected feature? can you describe an example where objects c = d would be useful?

I can, but that's not the tone you use when asking for something.

>oh dang hes right this is dumb and worthless, better just call him a meant and pretend that's more important than my 1 active neuron

My argument holds without me explaining anything. I'm not trying to show that it's good behavior (even though I think that it is, and have arguments in favor of that), but rather that you can't use it against any particular language, because they all share this property.

c is a global used by many methods and c = d switches the target for operations implemented by those methods, it's common sense

No they dont you mongreloid.

creating an int array in java
int[ ] A = new int[4];
int[ ] B = new int[]{9,0,0,0};
A = B;
for (int i = 1; i < 5; i++){
a[i] = i;
b[i] = i*2;
}

A is {9,1,2,3}
B is {9,2,4,6}
A was set equal to B
A {null, null, null, null} becomes
A {9,0,0,0}
Funcs performed on A and B have different results, because A = B did not destructively affect A, unlike the case with objects.

both objects and arrays are initialized via

TYPE name = new TYPE;

yet wildly different results when assigning. Pass by Value vs Pass by Reference.

ArrayOutOfBoundsException
:^)

i

This code won't even compile, you have lowercase and uppercase variable names mixed. Write it properly, output a and b somewhere, observe your results, and then you'll see how mistaken you are.

> itt: people who can't program
I mean, javascript is retarded and all - but you people just take it to another level

I wrote it off the top of my head nigger. You can rename the variables whatever you want but you'll still get the same predicted results.

I hope you're not admitting to being too mongoloid to rename the variables yourself

I suggest that you actually run the code and verify it works the way you think it does. Hint: it doesn't. Posting this snippet you wrote off the top of your nigger head does not achieve anything.

if you make the corrections, it works literally exactly as described.
a = b -> copies b to a, both a and b are functional
if these were objects rather than arrays
a = b -> destructively, permanently destroys a to force any actions made with a to be performed on b instead.

where the arrays results were
a{9,1,2,3}
b{9,2,4,6}

the objects results would be
a{9,2,4,6}
b{9,2,4,6}

Arrays results are 9,2,4,6 both, and both a and b point to same array in memory. You'd have seen that if you cared to actually run your program.

You people should be using Perl.

only satan could have convinced you to keep posting at this point.

Dude, learn some CS basics.

>write functions performed on A also apply to B, but read functions from A only apply to B
>write functions performed on B also apply to A WHICH EQUALS B, but read functions from B only apply to B

Which is 100% logical..
A and B both reference the same "adress", therefore if you change one "Object", you automatically change the reference. Of course you only need to read A and not B, because you would otherwise you would read the same thing twice.

In other words:
If you make 10 objects "A, B, C.." (which are only shallow references and not deep copies, that is!) you only need to write to A to change every "object value". But It would be stupid if you want to read A, but also read B, C...

Simple common sense.


>for no intelligent reason, objects pass by reference to other objects, all the time

The "all the time" is wrong, you can simply implement you own cloning method.

Also the reason is that a pass by value mean you copy every value of an object. Imagine you implement a sorting algorithm on a recursive array with 100,000 elements. Maybe something like Quicksort.
Now you really want to "pass by value" and create a new obejct, which means creating an array and copy 100,000 values FOR EACH ITERATION of quicksort?
Really?!?


>but variables never ever ever pass by reference to another variable


This is also a good idea.
Imagine you have a throwaway-variable "i" for calculations. Now you calculate something and set some init value to "i":

(This is only for illustration, not real code)
my_DB_type = "MySQL";
my_DB_name = "sytem xyz";
my_DB_maxUsers = i;

my_DB_Object = newDB(my_DB_type, my_DB_name, my_DB_maxUsers);

But a few lines of code later you do a simple for-loop:
for (i=0; i

I just want to understand where this confidence is coming from. You should by now realize that you don't understand shit, so why are you so sure that you know how Java will execute your program?

ArrayList A = new ArrayList();
ArrayList B = new ArrayList();

do you know what
I N I T I A L I Z A T I O N
is?

no?

cool conversation.

I'd still like to receive the answer to the question about your mental state.

ArrayList A = new ArrayList();
ArrayList B = new ArrayList();


Dude, I've programmed more lines of cose than you probably ever will.

I tried to help you expanding your freshman's year knowledge about programming why so condescending?

It doesn't help your point to nitpick ybout syntactical points. What you are suggesting is a standard behaviour of "call by value" of objects. I told you why this is a bad idea, nothing more, nothnig less..

>do you know what
I N I T I A L I Z A T I O N
is?


Yes, but you suggested that objects should clone (deep copy) themselves when used like this:
Object1 = Object2;


Now imagine you have a funtion operating on a huge data structure (maybe a database object). You are suggesting to copy the whole thing for each function that works on it? This makes no sense.


Basically "call by value" for objects is the only sane choice. "Call by reference" for variables is also a good idea in OOP, functional programming being a different story.

yeah that is not the actual result. The fuck java are you even compiling my dude.

Any Java. How about you show your code and we put it into any of freely available online java compilers and check the result?

Of course the last sentence should be :

>Basically "call by reference" for objects is the only sane choice. "Call by value" for variables is also a good idea in OOP, functional programming being a different story.

I think he is just baiting at this point.

Ignore this thread.

I don't know. He wrote too much to be baiting. I believe he is genuinely retarded and I desire to know more about how he thinks.

Why is the first one a problem? You set a to b after adding it so a should reset to 0 since you have nothing changing b

I've yet to see a single example of object1 = object2 where object1 permanently releasing anything it could do to simply act as a reference to object2, would be a good thing.

object1 = object2 properly compiles with nonretard effort(), to be that object1 copies object2.

this provides clear benefits. You can work with object1 and object 2 simultaneously, or modify one while leaving the other alone

object1 = object2 being a reference to object2 makes no worthwhile sense. Any function I could do with object1 could have just as easily been written as object2 instead. It is an absolute waste of existence to think in this reference manner by itself, but even more retarded to disregard the intialization process for each variable. they both started as seperate places in memory, and they should both stay as seperate places in memory. If what we were writing was
ArrayList A = new ArrayList
ArrayList B = A
as initialization, i could maybe, just maybe see how one could act as reference to the other - but still, defies logic as to why we would need multiple, various yet absolutely identical entry points for funcs on a single object.

>the user who doesn't understand basic Java is reasoning about how language can be made better

I'm probably more familiar with sun's java than you are. Oracle has fucked you retarded if you think there's supposed to be references like this in java, or that they have benefits.

Nvm I thought you were being sarcastic with "this made sense"

You didn't even know you were talking about Java at the beginning of the thread. Look at your post. Javascript. You demonstrated complete lack of knowledge in this thread.

ye, your confidence fails you a lot harder than assuming my confidence would fail me.

kill yourself, literal faggot.

So will you post the code that produces different a and b arrays after assigning a to b? I posted, in good faith, the code as you provided it, along with execution result. Now it's your turn.

objects were a mistake

wouldnt copy on write work fine instead of hard references?

As soon as you can provide a logical reason for two differently intialized objects with two different memory addresses permanently abandoning one address so both reference the same address after assigning one to the other.

The abandoning is not a thing. It's something you made up. You can still keep the reference to original object in another variable. It's all up to you whether you want to keep a reference to the object or not.

X = new int[4];
Y = new int[4];
A = X;
B = Y;
A = B; // nothing is abandoned

This all is unrelated to the fact that you were mistaken about how arrays work in java, and if you want to demonstrate otherwise, you gotta post that code.

Well?

everything other than lisp is a waste of time anyway

mark up languages like latex and html are acceptable

what am I missing out on?

> var c = [];
undefined
> var d= [];
undefined
> c.push(1)
1
> c.push(2)
2
> c.push(3)
3
> c
[ 1, 2, 3 ]
> d
[]
> c = d
[]
> c
[]
> d
[]

>this entire thread
i don't even know who is trolling who anymore

Let me explain what's happening, and you'll see how it's reproducible in languages with references.
First example copies by value. Primitive types are stored as values because it's more efficient. In the second example c and a are references, because objects in Java are always stored like that. If you use "new" for classes in sepples you'll see the same behavior, but otherwise you'll see the behavior like in the first example. Often this is not desirable, as copying a class is expensive. So here's the breakdown of the cycle:
>c size increases by one
>c assigned the address of d(the list it's pointing to has size 0)
>increase size by one
>assign
>increase size by one
>assign
>print
Hence the size 3. The list c was pointing to was modified only once. After that you were modifying the list d was pointing to. No magic is happening here, no copying, nothing. Value of d hasn't changed either. Imagine you have a shelf with boxes, and you refer to these boxes by number. c and d are storing such a number, and contents of the box would be your list. c and d are pointing to the same box and and the box c was orginally pointing to is kinda lost - it's still there but you don't know it's number. It will end up garbage collected.

>Clojure
>Lisp and Java

Checkmate, lambda faggot.

>>
>postulating an initial open ended question then changing the question to one that seeks validation for your own opinionated answer to the initial question disregarding that the initial question is open ended and has no definitive correct answer

how much of a retard do you have to be that your one criticism of javascript is that it handles value and reference types properly and consistently?