tag:blogger.com,1999:blog-34454975.post9163034537527728194..comments2023-06-28T16:58:41.189+02:00Comments on Web Reflection: JavaScript Made Everyone CrazyAndrea Giammarchihttp://www.blogger.com/profile/16277820774810688474noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-34454975.post-74883575553106106482012-10-12T20:24:49.003+02:002012-10-12T20:24:49.003+02:00I'm impressed by the netiquette ... no insults...I'm impressed by the netiquette ... no insults so far but before it gets worst, I am closing comments here before you take this too seriously and start some religious fight ... OK?<br /><br />Here, <a href="http://webreflection.blogspot.com/2012/10/all-right-gentlemen.html" rel="nofollow">have some fun with this post summarized via comics</a> ;-)<br /><br />All the bestAndrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-64758980640165372462012-10-12T20:02:15.697+02:002012-10-12T20:02:15.697+02:00You seem to be championing JavaScript as this amaz...You seem to be championing JavaScript as this amazing language that we should all just learn properly, while at the same time criticising TypeScript for not fixing all the anomalies and inconsistencies that have plagued JavaScript for the last twenty-odd years. You can't have it both ways.Mark Rendlehttp://blog.markrendle.net/noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-5014607027713923822012-10-12T18:45:21.616+02:002012-10-12T18:45:21.616+02:00Javascript itself is just like C++: it gives you e...Javascript itself is just like C++: it gives you enough rope to hang yourself several times over.<br /><br />What is <i>really</i> needed is a language that compiles to Javascript, that is a <b>subset</b> of Javascript, that enforces good style, and doesn't allow the ugliest kinds of JS programming.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-54234877966064994112012-10-12T17:32:31.790+02:002012-10-12T17:32:31.790+02:00Compiling TypeScript to JavaScript is like C to As...Compiling TypeScript to JavaScript is like C to Assembly ,, typed C does not mean that your generated Assembly is a safe by itself ,, but it ensures that you will generate a safe "structure" of Assembly<br />it just gives you a strict rules not to get bad structure of codes.<br />I liked the way TypeScript works.Technologisthttps://www.blogger.com/profile/12262351058721674852noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-45315780318170327232012-10-12T17:18:30.582+02:002012-10-12T17:18:30.582+02:00Ahh...the old "you don't understand javas...Ahh...the old "you don't understand javascript, that's why you don't like it" argument.<br /><br />Let's make COBOL the assembly language of the web and see how people feel.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-82261014777510738282012-10-12T16:33:17.876+02:002012-10-12T16:33:17.876+02:00Well yeah, I listen. And I guess we have to put up...Well yeah, I listen. And I guess we have to put up with it. But I strongly disagree with the term "programming language". It is a scripting language. HowEVER, as we can rely on machine translation from programming languages, it becomes almost useful.<br /><br />So what's wrong with a scripting language. Just one thing... the most common bugs blow up in the user's face, and he/she is totally innocent. In a programming language (at least good ones), those families of bugs won't even compile.<br /><br />Also, I get an IDE that doesn't bring me back to the 80's like a text editor does... but again, with something compiling the real deal into javascript, I'm on board.<br /><br />But I will not like it. Ever. JS sucks. I mean... it was invented by Netscape... how scary isn't that?nightcoderhttps://www.blogger.com/profile/10709404486575221250noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-59445527265087746292012-10-12T15:29:53.491+02:002012-10-12T15:29:53.491+02:00amen brother, with my jQuery, JS I've been abl...amen brother, with my jQuery, JS I've been able to create some very useful code that work across all of the major browsers and it all works.<br /><br />learn the thing an be done with it. it's here to stay and no matter how much you cry, it'll still be thereAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-55598971686376235482012-10-12T14:28:27.395+02:002012-10-12T14:28:27.395+02:00Two of the best benefits of TypeScript not mention...Two of the best benefits of TypeScript not mentioned here: 1) Code is easier to read and follow, partly because it is more similar to other languages, and 2) It is easier for not-so-expert developers. A lot of articles like this online are written by top-notch developers that underestimate how important the above two facets of programming are.Shawn Lawsurenoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-7333812791128758442012-10-12T11:41:47.463+02:002012-10-12T11:41:47.463+02:00Interesting comments. I'm far more positive ab...Interesting comments. I'm far more positive about TS, I like a lot of what it's trying to do with structural typing and so on. <br /><br />Having said that I haven't yet had time to use it and it sounds like the devil is indeed in the detail (string versus String) and I fully agree that the bigger problems are the ones worth solving.<br /><br /><br />"Fake Security"<br /><br />Without getting into DBC I think what they are doing here is what I'd expect.<br /><br /><br />"Getting Worst On Security"<br /><br />I'm not as worried about that as I maybe should be, there is a potential confusion cost. Even in say C# you can use reflection to set private members.<br /><br /><br />"The funny thing about TypeScript, is that basically the only real and concrete advantage of typed languages, the cost free and great improvement performance speaking, is completely absent."<br /><br />This I do disagree with. I'm from a .NET background but have been working with JS a lot too and do love (most of) it.<br /><br />However what I miss with it is the self-documenting aspects you get with typing, and the ability to effectively use tool based refactoring. You can see a method expects an IFoo, you can directly navigate to it, and then you can directly rename one of the members on IFoo and know it'll ripple through the code. Thats definitely useful and can save time.<br /><br />That's where I think TS has a decent story, not least as it is not forcing you to use typing and uses structural typing which to me look like it could be a much nicer than the approach C#/Java etc took (though not sure if structural typing will mean we get less refactoring benefits).<br /><br /><br />"// setting the private property<br />cp[cp.color] = true;"<br /><br />Did you mean test here?Colin Jackhttps://www.blogger.com/profile/01403166737046938219noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-49589648124399395842012-10-12T10:35:01.206+02:002012-10-12T10:35:01.206+02:00The only reason everyone is targeting JavaScript i...The only reason everyone is targeting JavaScript is because it is the only language that runs in every browser. <br /><br />The language is in some senses remarkable - first class functions being the most significant of these, and use of prototypical inheritance (I'm familiar with Self, which introduced this, and does it much, much better). <br /><br />However, with the heavily documented flaws in the language - which even its designer Brendan Eich acknowledges, it is hard to see how you can be so blind you can't see them.<br /><br />OK, you can code around them, or avoid them. However, put them in the hand of inexperienced programmers and you get the mess you see on most site's JS.<br /><br />Rob Ghttps://www.blogger.com/profile/03479787549028858677noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-14510753164051130292012-10-12T10:05:09.138+02:002012-10-12T10:05:09.138+02:00When I first started using javascript I tried to d...When I first started using javascript I tried to do it the C#/C++ OO way - I got awful, awful code! I then learned to use javascript "properly" (I hope! ;-) and I've got less codr that's more efficient and hopefully makes sense.Deldeynhttps://www.blogger.com/profile/06418584685723277279noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-45282206427755646942012-10-12T03:22:16.687+02:002012-10-12T03:22:16.687+02:00No, those are all examples of libraries out there ...No, those are all examples of libraries out there that use methods in the prototype that get marked as private when they're not truly privates. It's private by convention only.<br /><br />I've been trying TypeScript a bit and I mostly like it as a ES6 to ES5 compiler. The annotations part I'm still not convinced I like. One one hand I recognize that when writing libraries I usually document stuff like privacy, types of parameters, return types, etc. I even write tests for them. So I'm attracted to the idea of putting that into code that gets automatically checked while I develop. Checking callback signatures is really cool.<br /><br />But on the other hand I've seen annotations abused in AS3, I can't stand class-focused development, and types sometimes get in my nerves when I want to reuse variables or do other things I'm used to do in JS.<br /><br />So I'm ambivalent for now.Anonymoushttps://www.blogger.com/profile/01313327172392857583noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-61213447035771435662012-10-12T01:19:45.241+02:002012-10-12T01:19:45.241+02:00@juandopazo apologies I might have misunderstood w...@juandopazo apologies I might have misunderstood what you were talkign about .. if that translate into private methods inside a closure that's perfectly fine ... properties are a different thing thought ... isn't it ... Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-33688360066559319902012-10-12T01:16:50.048+02:002012-10-12T01:16:50.048+02:00on "all developers know is Java which *sucks*...on "all developers know is Java which *sucks* big time" I don't mean the language, the fact developers cannot think differently than that .. I have programmed in Java too, as well as C#, it's OK ... I like both (C# more) but then I can write equivalent shit in JavaScript without moaning every day ... Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-82406410745615128672012-10-12T01:14:49.175+02:002012-10-12T01:14:49.175+02:00@juandopazo I am not a big fun of things that are ...@juandopazo I am not a big fun of things that are not what expected ... in your own thing you are polluting the prototype which means that `this.own('own', 123)` will screw the thing, right? That's not private in any case so don't call it private ... some developer might think is private for real and write weak code thinking it's safe.<br /><br />Anonymous: I like trains too ... actually that's what I've thought as soon as I have read about this TypeScript thing :D<br /><br />Anonymous 2 ... yes, my grammar is not perfect, so isn't JavaScript as well as any other programming language.<br /><br />We don't need necessarily to fix JavaScript ... surely it needs updates and that's why ES5.1 is out and ES6 is coming.<br /><br />We need to fix IT instruction if you want, 'cause JavaScript is still ignored at University level and all developers know is Java which *sucks* big time.<br /><br />As developer, you should be flexible enough to understand different paradigms rather than make everything as the only thing you know ... Java .. moreover, if that's what you want, why even bother with this hybrid thingy, just go GWT and be happy, am I wrong?<br /><br />Last, but not least, TypeScript is not fixing JavaScript ... at all! There is no fix, only an extra layer on top that might give you many undesired surprises ( and I find hilarious people are defending it at all costs even when private is broken at all levels ... is this improving or being blind? )Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-44492267976705774302012-10-12T00:59:31.882+02:002012-10-12T00:59:31.882+02:00Your grammer obviously has the same problems as yo...Your grammer obviously has the same problems as your argument: "Not All Wrong Neither," which is a double negative not to mention other understanability issues. Just like you saying "nobody seems to understand it" which indicates we need to fix it. Is it not good that people are trying to fix it?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-25444452241779549932012-10-12T00:16:12.048+02:002012-10-12T00:16:12.048+02:00I like trains.I like trains.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-45670427559904665452012-10-12T00:08:19.265+02:002012-10-12T00:08:19.265+02:00I think you're over-thinking the issue with pr...I think you're over-thinking the issue with private. We're already marking stuff as private/protected in APIs (ie: http://docs.sencha.com/ext-js/4-0/source/Base.html#Ext-Base-method-own, http://yuilibrary.com/yui/docs/api/files/event-custom_js_event-target.js.html#l36) when they're not true privates and it's still useful.Anonymoushttps://www.blogger.com/profile/01313327172392857583noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-44637179559998304612012-10-11T20:35:56.334+02:002012-10-11T20:35:56.334+02:00Jeremy my examples are created via TypeScript .. w...Jeremy my examples are created via TypeScript .. when you say private is private ... you are saying my examples should fail. These are not failing, private is not private, even in TypeScript. Use square brackets and try by your own ... not an issue, really ;)Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-42833548163317177572012-10-11T20:08:44.465+02:002012-10-11T20:08:44.465+02:00Andrea,
I'm aware of the difference between p...Andrea,<br /><br />I'm aware of the difference between primitive values and objects. My point is that we typically don't use wrapper objects. So while, yes, TypeScript does allow you to call String() as a constructor, are people really going to do that? No. It's a non-issue.<br /><br />Even if it was an issue, someone would have to use String throughout their entire code base in order for new String("foo") to not result in a compile-time error.<br /><br />My privacy statement was poorly worded. JavaScript does not have a true form of privacy, and we won't have true privacy until ES6. The best that we can emulate privacy incurs a performance hit.<br /><br />With saying that, TypeScript has true privacy; it's just that it doesn't translate into any tangible privacy in JavaScript. <br /><br />But is this really an issue? Private is private in TypeScript. A team developing an app in a TypeScript environment is bound to the language's rules. So what if it doesn't translate into privacy in JavaScript? They're not writing against the output, they're writing against the untranslated JavaScript.<br /><br />I didn't suggest rewriting a library in TypeScript. I merely meant that code written in TypeScript is more performant that code using a library. Like it or not, a good portion (perhaps the majority) of people using a library don't know or understand JavaScript. The output code from TypeScript will execute faster than code using a library. It's a statement that isn't necessarily poignant to the discussion, as libraries and languages like TypeScript target to different sets of people.Jeremy McPeakhttp://www.wdonline.comnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-74198675096768465482012-10-11T19:35:01.562+02:002012-10-11T19:35:01.562+02:00where exactly have I talked about ES6 in this post...where exactly have I talked about ES6 in this post? ... this post is about TypeScript ... Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-29393029008677958192012-10-11T19:31:07.898+02:002012-10-11T19:31:07.898+02:00I think the point about strongly typed language co...I think the point about strongly typed language contructs is missed here. You said that ES6 has "no concrete advantages over common JavaScript" imho the real advantages to ES6 are code completion, finding compile time errors and function calls running in scope of the object they belong to. The first can be somewhat achieved with self documenting code practices. I come from AS3. Code completion is based on the local scope and the inheritance chain, you can't pass a string value to something that syntactically expects another type and every call runs in the scope it belongs to. Nice intro, I agree, everything should be written in javascript.Shanimalhttps://www.blogger.com/profile/15199269668190354991noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-52888159342366592342012-10-11T19:10:42.534+02:002012-10-11T19:10:42.534+02:00Jeremy ... no, I am sorry.
Type Inconsistencies ....Jeremy ... no, I am sorry.<br /><br />Type Inconsistencies ... TypeScript *has* different behavior with string or String as well as JS *is* different when you chose wrappers instead of primitives.<br /><br />A wrapper can carry properties, as example, for string analysis is quite common, while a primitive cannot.<br />Wrappers are also greedier than primitives, memory speaking, so using new String rather than String *is* different, on performance too.<br /><br />On Security<br />you say: "JavaScript currently does not support privacy" ... then you say isn't true unless you impact performance ... so it does, because we know that, right?<br /><br />Dealing with a language and a syntax that let you feel there are private members is a disaster prone programming approach ... if we all know these cannot work, how can we trust them? How can we use them? What's the meaning of private then, and why!<br /><br />Performance is Worst<br /><br />I don't get your point ... you gonna end up rewriting entire libraries via TypeScript thinking now these libraries are anyhow better ... these libraries, rewritten in TypeScript, will be slower than original.<br /><br />About your last sentence, yeah ... probably me too, typescript at least is closer to what ES6 will be, maybe, one day .. so if I have to chose between those languages, TypeScript would probably be my choice as well.Andrea Giammarchihttps://www.blogger.com/profile/16277820774810688474noreply@blogger.comtag:blogger.com,1999:blog-34454975.post-55670860429619270662012-10-11T18:29:29.231+02:002012-10-11T18:29:29.231+02:00I originally stated your analysis is wrong. A bett...I originally stated your analysis is wrong. A better word would be petty, at least for your first few complaints.<br /><br />Type Inconsistencies<br /><br />TypeScript rightly ignores the line between primitive values and wrapper objects. The distinction between a primitive value and a wrapper object is typically only used to determine the level of someone’s technical knowledge of JavaScript. Except for extreme edge cases, the distinction doesn’t change how we write JavaScript code. Why should it matter for TypeScript?<br /><br />The String, Number, and Boolean data types in TypeScript are primitive data types, and they were named as such to replicate the data types found in JavaScript. Just like almost every other statically typed language, TypeScript provides the string, number, and bool alias keywords that map to their respective data type. Obviously, the difference in these data type/keyword pairs is Boolean and bool. However, there is nothing out of the ordinary in this pairing; the bool keyword is commonly used as an alias for Boolean.<br /><br />Fake Security<br /><br />TypeScript adds type safety. It ensures that the value or object you have is of the correct type. TypeScript, just like any other programming language, doesn’t save a programmer from bad logic.<br /><br />Getting Worst on Security<br /><br />JavaScript currently does not support privacy. One can somewhat emulate privacy by using local variables and closures, but it is impossible to create truly private members for a data type without incurring a performance hit until ES6.<br /><br />Translated Parent Accessor<br /><br />I cannot disagree.<br /><br />Performance is Worst<br /><br />I agree and disagree. Is it faster than just writing the JavaScript? No, but it will certainly be faster than using any library.<br /><br />To be clear, I love JavaScript. My first, knee-jerk reaction to TypeScript was (and still is) “just learn JavaScript”. But if it came down to TypeScript, CoffeeScript, GWT, Dart, SharpScript, or any other “compile-to-JavaScript” language, I would pick TypeScript in a heartbeat.<br />Jeremy McPeakhttp://www.wdonline.comnoreply@blogger.comtag:blogger.com,1999:blog-34454975.post-53983842063071398242012-10-11T16:01:17.787+02:002012-10-11T16:01:17.787+02:00Excellent points. Static typing is useful for perf...Excellent points. Static typing is useful for performance and API discovery, and if neither of those two can be achieved by adding static types do a dynamic language, then it is fairly useless to do so.ncloudhttps://www.blogger.com/profile/03358766632379198405noreply@blogger.com