r/ProgrammerHumor • • Jun 21 '18

Thanks Brendan for giving us the Javascript

Post image
3.1k Upvotes

302 comments sorted by

View all comments

Show parent comment

2

u/Code_star Jun 25 '18

it has very easy to use anonymous functions where you can easily change the binding scope with a slight change in syntax.

5

u/senntenial Jun 25 '18

that's a mechanic in virtually any modern language. i don't consider that a reason.

1

u/Code_star Jun 25 '18

that's not true, can't do it in python and you can't do it in C++.

7

u/senntenial Jun 25 '18

javascript is good because it can do things that u cant do in ANSI COBOL

1

u/Code_star Jun 25 '18

.... python and c++ are modern and popular and they can't do the thing I said. You asked for an example and having been proven wrong you have just been insulting me

2

u/senntenial Jun 26 '18

python is still stuck on a version from 2010 and C++ is anything from a modern language. And to clarify, I'm making fun of JavaScript, not you.

1

u/drjeats Jun 25 '18

JavaScript bringin' back the crappy parts of Lisp 😎 👍

1

u/Code_star Jun 25 '18

anonymous functions are useful though ... plus the shitty parts for lisp are the parenthesis

1

u/drjeats Jun 25 '18

Anonymous functions are great. I'm talking about being able to rebind this and other scope weirdness.

1

u/Code_star Jun 26 '18

that is also pretty darn useful in practice and is very popular

https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/

2

u/drjeats Jun 26 '18

I'm saying the fat arrow function binding semantics is how anonymous functions should have worked from the beginning.

1

u/Code_star Jun 26 '18

So you hate old JavaScript ... So you have an argument 2 1/2 years ago?

2

u/drjeats Jun 26 '18 edited Jun 26 '18

And it's a net negative to introduce differing semantics after bad ones have already been established.

Why do you feel the need to run interference for a language that we all have to know and work in regardless of how we feel about it?

1

u/Code_star Jun 26 '18

because I'm tired of blanket stupid memes and complaints in these sub. Its stupid and most of the complaints aren't even specific to the language

1

u/junrrein Jun 25 '18

you can easily change the binding scope with a slight change in syntax.

Can you say more about what this means? I'm not familiar enough with Javascript and a quick Google search didn't seem to turn up anything directly relevant.

1

u/Code_star Jun 26 '18

scope might have been the wrong way to phrase it. basically arrow functions vs anonymous functions

this could explain better than I could

https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/

1

u/junrrein Jun 26 '18

Thanks for the article.

So, previously, you were talking about "You can use function expressions if you need a dynamic this and arrow functions for a lexical this"?

1

u/Code_star Jun 26 '18

yes, and that it is an easy and readable syntax

1

u/junrrein Jun 26 '18

I've heard that "dynamic this" was one of the big mistakes in Javascript, and that it was corrected by introducing arrow functions in ES6, which always use "lexical this". Do you think that's a fair assesment?

1

u/Code_star Jun 27 '18

I honestly haven't had to do a lot of javascript pre 2016 so I don't know if I can weigh in much. I would say I use the normal (non arrow) syntax more in my own code, but the ability to switch between them easily is nice

2

u/junrrein Jun 27 '18

The thing is, I can foresee that using dynamic this makes stuff confusing and difficult to follow, so why use it at all? I'm not talking about the syntax differences between "classic" anonymous functions and arrow functions, but about the differences in scoping for this.

1

u/Code_star Jun 27 '18

I am talking about this I use the dynamic this often. It really just depends man. What is cool I think is you don't have to have one or the other, or right any strange closures like var This = this to use the one you want anymore

1

u/junrrein Jun 27 '18

I guess that in the context of Javascript, having dynamic this makes sense. It would be completely fucked in other languages that have OOP, where instance variables have public/private access modifiers.