6 ms·
Why do people keep on trying to fuck up Javascript? I don't want your shit OOP and classes, take them back. Do you even get javascript? And the beauty and ease
by jsmadthrow 12y ago
Why do people keep on trying to fuck up Javascript? I don't want your shit OOP and classes, take them back.
Do you even get javascript? And the beauty and ease of coding in it?
JS is amazing because of two things:
1. VAR - yes var. it's 2015 and yet you want me to waste my time typing in useless int, float, char. Really?
But wait! now that you have wasted hours adding useless types to your code, you can benefit from our IDE that will tell you where you missed one! So you see, we actually saved your ass!
2. JSON, and everything is an object. Instead of creating 20 functions, a single function(x) can handle multiple cases with flow enhancement.
x is an array. x[0] is a number, x[1] is an optional object, x[2] is a freaking function. all dynamically changeable.
f([1]), f([2, {}]), f([3, {}, callback]). you want to add another flow? no problem, extend your array or just set a property on the object, js serves you, you are the master.
--
instead what we get? 'too few arguments throws'; typeof D < {new(x:T):D, s(x:T):U, ...C’s...}. WTF is that? Does that look like sound coherent code to you?
- pornel 12y agoIt looks like you didn't fully understand what the presentation is about. • `var` is replaced by `let`, but it works mostly the same in sane situations. It's merely a bugfix for warts in `var`. It has nothing to do with static type declarations. • Types are optional. JSON is still allowed. For a bag of properties `Map` is suggested, since it doesn't have some of the quirks of using `Object` as a map. And the WTF is not a suggested syntax but an explanation of the type system in a more formal notation.
- tacos 12y agoNot even C++ requires you to type a "useless float or char" ahead of a variable any more. But declaring something before using it offers a number of benefits with a JIT compiler in a VM. If you choose to use it, it's available. In this case, you can have it both ways.
- _random_ 12y agoHow can you f..k up something that is screwed up from the start? Oh, the beauty: http://wtfjs.com http://wtfjs.com
- jack9 12y ago> I don't want your shit OOP and classes, take them back. Most programmers disagree. Get over the fact that you are in the minority and JS has succeeded DESPITE the massive barrier to entry (beyond the simplest of tasks) and the monumentally messy spaghetti code that javascript (as a prototypical language) inevitably becomes, in larger projects.
- seanmcdirmid 12y agoPrototypes are also OOP by the 1988 Treaty of Orlando, so we are just arguing about one kind of OOP vs. another.
- seasoup 12y agoYes. This. The ideas in the article are terrible. It does not look remotely interesting. I read these slides and think, this is someone that doesn't like JavaScript and is trying to make it more like languages they enjoy, like Java. Trying to eek out every performance improvement possible by removing developer friendly features is not a good idea. "let" scoping is a terrible idea, it is not at all sane. Functional scoping is clean and simple, there is only one thing that scopes variables, functions. Thats it. Easy. Block level scoping will introduce coding nightmares trying to figure out what scope your variable is in. I can just imagine the nightmare code people are going to write interspersed with both var and let, and having to figure out how the variable was declared to know its scoping rules. GAH. Not having to tell the compiler what kind of variable you are trying to use makes coding so much simpler. Not having to cast variables manually is a godsend. And this is considered a good thing to take away? Reading further into this presentation, it's clear that the developer wants JavaScript to be Java. any<T>...? No no no no no no no. Keep classes away from JS, unneeded complexity. Classes are inherently complex compared to the simplicity of prototypes. Classes sound like such a good idea, until you are knee deep in the inheritance chain trying to figure out where some method or attribute is defined and/or overwritten. They are one of the biggest reasons people need to use an IDE to write code. Just learn JavaScript, guys. It'a a really simple language, just not like the ones you learned in university.
- olavk 12y ago> Block level scoping will introduce coding nightmares trying to figure out what scope your variable is in. I almost suspect you are trolling here. The variable is in scope inside the block in which it is declared. What could be simpler? With JavaScripts function-scoping, you can declare a variable inside a nested block, but it is still in scope outside and even before it is declared! And if you forget the "var" it is suddenly a global variable.
- seasoup 12y agoSure, forgetting the var causing a global variable is a problem, and I'd have no problem with removing variable hoisting and requiring all vars to be declared at the top of the function, it's what I do anyway. But adding a block level variable declaration just adds to the complexity of the language and doesn't add any real additional capabilities. It adds some nice fluff around loops and asynch operations, but that is all easily done using current scoping rules once you understand closures. var is still going to be around, but now we've added let. you might like let's scoping rules better then var's scoping rules, but now we'll have both. the interaction between the two is going to have some amazingly confusing and complex edge cases. If you think that hoisting and closures are confusing now, just wait until let is thrown into the mix as well. Even if let is simpler, var isn't going away. So we're just adding complexity to the system.
- ahoge 12y agoThis function is fully typed: http://i.imgur.com/xHWlJVn.png http://i.imgur.com/xHWlJVn.png Types are optional and they can be also inferred.