JavaScript: The Good Parts
HTML-код
- Опубликовано: 26 фев 2009
- Google Tech Talks
Web Exponents
presented by Doug Crockford
February 27, 2009
blog post: google-code-updates.blogspot.c...
JavaScript is a language with more than its share of bad parts. It went from non-existence to global adoption in an alarmingly short period of time. It never had an interval in the lab when it could be tried out and polished. JavaScript has some extraordinarily good parts. In JavaScript there is a beautiful, highly expressive language that is buried under a steaming pile of good intentions and blunders. The best nature of JavaScript was so effectively hidden that for many years the prevailing opinion of JavaScript was that it was an unsightly, incompetent abomination. This session will expose the goodness in JavaScript, an outstanding dynamic programming language. Within the language is an elegant subset that is vastly superior to the language as a whole, being more reliable, readable and maintainable.
Speaker: Douglas Crockford
Douglas Crockford is a product of our public education system. A registered voter, he owns his own car. He has developed office automation systems. He did research in games and music at Atari. He was Director of Technology at Lucasfilm. He was Director of New Media at Paramount. He was the founder and CEO of Electric Communities/Communities.com. He was founder and CTO of State Software, where he discovered JSON. He is interested in Blissymbolics, a graphical, symbolic language. He is developing a secure programming language. He is now an architect at Yahoo! and the world's foremost living authority on JavaScript. Наука
Still after years, best of and on JS is Douglas Crockford
Its been 5yrs since this video was released!, im learning to code and teaching myself and im so happy that people like Douglas Crockford are guiding people in the right direction when coding with best practices.
It's now been 11 years since this video was released!
@@horacinis 14 years and counting!
How's the coding going?
Great presentation by Doug . He was clear about what he wanted to say, honest enough to accept that JS has some unnecessary *bad parts* in it and sometimes *bold* enough to defend JS from inaccurate and impartial accusation of it being a bad language.
This is the first RUclips video that I watched on one sitting . :D
Even after so many years, most of these are still relevant!
A great lecture on the JavaScript language! The most enlightening part for me was the discussion at 28:08 about the Module Pattern and - following immediately - Power Constructors.
His constructor pattern at 28:19 blew my mind a little. Crap, I need to go refactor all the JavaScipt I've ever written.
The beginning was great. One of the largest languages where people don't try to understand before using it. That's hilarious, and I definitely fell into that category. Great video Mr. Crockford.
I've watched this talk four times, and get something new out of it every time. This should be required viewing for anyone writing JavaScript.
"When a compiler gets an error it backs up, looks for a line feed, inserts a semicolon and tries again." jesus christ... there's a special level of hell for people with ideas like this...
;
Great great talk.... Looking forward to more...
This is one of my favorite youtube videos ever. It's kind of funny too because the speaker sounds so much like Bob Newhart and has a similarly dry sense of humor I really appreciate. But the content is what really makes it so great.
@Kam3k
You missed the () at the very end of the declaration of digit_name: notice that it ends in "}();" not "};", which calls that closure immediately and stores the result in digit_name.
Just to ask a quick question to anyone who may know. Does the prototype chain compile the function to memory and leave it in memory until the window closes?
@Kam3k in the closure version there is a pair of parentheses after the function definition, which immediately executes the outer function and assigns the result to the variable. you probably missed them when you were typing it up.
You can either have your closure return an internal reference (singleton pattern), or you can just set a breakpoint within the closure (via firebug/dev tools, or by putting in the "debugger;" keyword above the code of interest), which will pause the execution within the context you're interested in.
Absolutely correct Dave. I'll stick to my beautiful Allman style code and take a few precautions when returning an object literal.
This is my favorite . This is great talk. Though I dont know what Javascript is at all.
Excellent talk!
Love this book!
It should be obligatory reading for everyone who studies webdevelopment.
This was an eye opening speech.
Great talk...Great book...Rock On!
At 14:00 the thing about eval(), webpack heavily relies on the use of eval(). Is eval() still as bad as it was?
I love javascript but I realize I just know how to use it but not really program with it, which is why I am going to really learn this language.
Very nice... I've bought the book while watching.
Garrett Wills Even though this is 5 years old, it still has good insights into JS.
Cool, thanks for the info! I got the book but haven't read it yet. I'm gonna start reading it after this video :)
this is a great talk even though I am new to Javascript
Crockford says that Scheme has "loose typing." This is incorrect. Scheme is a _dynamically_-typed language. It is also a *strongly*-typed language. JavaScript is dynamically-typed, but it's also *weakly*-typed. This is what I would describe as "loose typing" and this is one of the main things that cause a lot of problems with the language: medium.com/javascript-non-grata/javascript-is-a-dysfunctional-programming-language-a1f4866e186f.
Dynamic typing is actually quite nice and powerful. Languages like Scheme and Smalltalk are great for this reason. But JavaScript's loose typing and freewheeling coercions introduce many semantical inconsistencies, which are the source of so many WATs and WTFs that make JavaScript the butt of many jokes.
Minute 15 and you already put names to the things that completely baffle/infuritate me about my first run in with Javascript (Geogebra). And the GOOD. Loose typing. Finally. Yes, I want to operate on that. Just, let me say what I mean. The first time I tried to *broop* pass an object that I KNEW could be operated on if only.... and it PASSED... I was so happy I had to stand up and walk around. Finally. I hate being a prisoner of another person's mind.
Hahaha transitivity table.
Thank you.
I love GoogleTalks. Thanks for posting this. I'm one of those people who learned PHP and though JavaScript would be way too easy to bother. Its not!
The closure version of digit_name doesn't work for me, calling digit_name(3) just returns a function which Is what I'd expect looking at that code. To get the name you'd have to do digit_name()(3) i.e. call the returned function. Can anyone explain how that is supposed to work?
I have just started learning javascript from common programming languages and this video make me easier to learn it =)
ROFL! Was anyone else kicking themselves hard when he spoke about how JS is the only language people start using without actually learning it? He fucking nailed me on the head right there! Brilliant.
@incompatibleTypes Same with me, mate. I studied C# (didn't really dive too deep in the language though) for about 6 months at the most. When you get into javascript, the language can be very confusing if you're coming from a strongly typed language like C#. What really confused me with the javascript language, is the use of functions, prototype, prototypal inheritance, and object literals. I guess because java and C# supports classical inheritance, but javascript doesn't have any classes in it.
really helpful
hi so i been listening to this for 11mins and all i want to know can it make games, apps, android apps, computer games, and software what can it make.
I love how he dismissed the first question :)
What about optional strong typing? In one of my projects I was using JSDoc a lot to 'tag' parameters or other values as of being a certain object type. With an IDE like Webstorm I could then get compile time type checking. Just think that people should have the option to type something, so they don't get completely lost in the code.
Try TypeScript for JavaScript with typing [sic]
Does typescript work in a web browser?
If I'm not working in a browser I might as well just avoid both of those.
Very nice. Interestingly every feature he mentions as "good" is also a feature in python.
No. He is right.
The outerfunction is being executed immediately or self-executed. So we do not need to use digit_name()(3). Instead, we us digit_name(3) directly. Actually, the outer function can be considered as a model that is able to be used in other place of the application
Lambda comes from Alonso Church (Lambda Calculus) and LISP, not actor model.
Apart of that, the talk is very interesting. The module constructor pattern seems much like functors specialized on runtime.
Who would have thought that JavaScript was going to become the language we all know and love today. Love it or hate it, but the amount of stuff you can do with it nowadays is just mind-boggling.
34:21 I love Javascript and I completely understand how Douglas feels in this part.
If you just watch 2 minutes of this video start here 34:21
damn, he nailed it when referring to GWT at around 4:09! and it looks like Google is still using GWT in 2017
It doesn't matter if they can see what you're trying to accomplish, because the cross-domain restrictions on .js files keep others from executing code cross-domain. I don't understand what you see as insecure. You're right in that server-side validation should be performed on any user-supplied data in addition to client-side validation, but generally JavaScript/jQuery code is more concerned with GUI than it is with heavy data manipulation (of course, there are many exceptions).
true, what do you use
Great!
Um.. whats with the 'floating Crockford' that starts at 3:45?
I don't see/hear anything like that at 3:45. was this video modified since you commented?
As for IDEs: try Netbeans, works like a charm for me!
really great talk - Crockford has also done a great series of javascript tutorials on video.yahoo.com - also mp4 for download on kiwi.kz :) - his book with the same title as this talk is well worth getting ahold of whatever level u'r at coding-wise.
Your second point isn't true -- Visual Studio 2010 does a great job at JavaScript code completion. For libraries that it doesn't parse well, you can make a special reference JavaScript (that doesn't get published) and use a reference tag.
As far as closures go -- you can name the function in a closure ie: (function myClosure() { /* my code */ })(closureArgument); so I wonder if this might help your issue..
@aromanstuff: That single statement made we watch the hole presentation ;)
Good!
Any language that interests the learner enough and minimizes pitfalls to help with the development process is not a bad example for game development. Just because its not the industry standard does not mean that valuable concepts cannot be realized from making games in Java. If someone wants to learn to program games in Java, there is absolutely nothing wrong with that, and as long as they get a firm grasp on the 'why' things work, the transition to C++ will be relatively easy.
50:34 Is he referring to Dart here?
i fukken love google tech talks.
I feel your pain, but you have to keep in mind that this was posted in 2009. Much has evolved since then, and much in the favor of HTML5 and JavaScript. The question I have now is what JS framework(s) to use. There's about a bajillion out there (look up TodoMVC on google).
webworkers were not around during the time of the talk?
no HD?
thanks
3:19 "In the JavaScript community, there is no love."
Call Paul Irish!
The speaker's book: Javascript: The Good Parts
30m39s. This is only relevant for the return statement, and is easy to solve!
1) Pre-declare your object literal and return the variable
2) Wrap the return expression in parenthesis
3) Place the opening curly brace on the same line.
Saying "placing block-opening braces on a new line is wrong" is wrong.
The only language where months are labeled from 0 to 11 and days from 1 to 31. The problem with Javascript is whoever thought about all the little details in the first time was nuts.
francescomm lmao
It's not the only language. This is adopted from the C Standard Library time.h tm structure: www.cplusplus.com/reference/ctime/tm/
@@ValentinBaca Thanks for this. I guess the reasoning here (month enums?) is too far fetched for the kids who upvoted this because they think they understand everything immediately with their "common sense" ;-)
Bookmark: 11:45
You certainly can build enterprise apps in Lisp-and in JavaScript, which is _not_ just a front-end language for the browser. If you're a JVM shop, there's Clojure and Rhino on the JVM. There are implementations of both on .NET. There are also Node.js, CouchDB and Lotus Domino XPages (and it doesn't get much more enterprisy than that, unless you actually want to use J2EE). It's hard to find code monkeys for 'em, but let's hope you don't really want them around anyway.
As I know, null is considered to be an empty object reference so there no issue to typeof!
OOP is fine if you are just getting a Minor in CS or tinkering in the subject but if you want to master Computer Science (Major level or beyond), you should really start with the fundamentals of procedural programming (in particular pointers). Only once you this should build on top of this foundation with OOP.
0:27:30 Closure
alert(digit_name()(3)); // 'three'
i like the G0:00D Parts!!!
There are many other protection possibilities, and they all help to some extent.
Why's he saying compile time error?
nice video
But the speech itself is on youtube, ken?
Ok, so I'm a 12 yr old kid, I have a real interest in computers and I am top in my grade at school. Would you say me trying to learn JS is aiming too high??
OK ... we need to learn Javascript ... BUT ... what is a good book to learn Javascript that does not push you off to some programming environment or library system that is just a layer on top of Javascript? Where is the best most complicated stuff out there to learn Javascript?
this guy rulz :)
Yes. actually there not a light weight but smart IDE for javascript.
How many times did he smack his microphone? 6? 7?
In the 'bad' list, he forgot:
- Debugging closures. A call stack full of anonymous functions is a nightmare.
- IDEs all suck because intelligent code completion is impossible.
I love the video, its amusing and entertaining and informative.. and Doug is a great narrator. BUT, I think after 5 years of front-end dev and maybe 2 or 3 of these really trying to get into JS, I just realize, the initial simplicity of the language is a trap. Its actually quite complicated, and, unfortunately, it just doesn't make sense. For example the weak typed variables and the fact you need to put a function in a function in order to make your variables private... Sorry but that doesn't make sense.
I haven't done lots of development, but I bet there are many other languages which are simpler to get.
You will feel spoiled when you use Python or Ruby.
You should give TypeScript and ES6 functionality like "let" keyword a try!
...except it isn't supported in any web browsers yet.
JavaScript is not misunderstood. We understand it very well: medium.com/javascript-non-grata/samson-and-javascript-3ff39a4f836d
The Good Parts don't make up for how dangerous it is to use this language, esp. for software engineering at scale: medium.com/javascript-non-grata/javascript-s-sword-of-damocles-47256cf17b5a
What does JavaScript "get right?" What makes it so "expressive?" Functional programming capability? This is not unique to JavaScript, and many other FP languages do it better.
Object prototypes are the building blocks for class-based OOP. They are a low-level facility. As such, they make it much more difficult to refactor your code. For example, how can you examine the object relationships in your code, the inheritance hierarchy? You'd have to follow every line of source in every function looking for instances of object instantiation, whether done through object literals, constructors, delegation, or concatenation. This is awkward beyond imagination.
With class-based OOP, you simply look at the _class definitions_, typically via a "class browser" in your IDE (eg, Visual Studio, IntelliJ, *Smalltalk*) which is able to easily extract the inheritance hierarchy from the code.
This difference from classical inheritance is what makes JavaScript impossible to _scale_ in size, making your code much harder to maintain. It makes it much harder to _understand_ your codebase. In the end, this is what compromises your application's _reliability_.
Yes we understand it but many obviously don't aka jquery and angular etc etc are around and don't give me that browser support crap, we all know if anyone really wants to access a page to view it properly they will use the roght browser, also since the flash player days many have ditched internet explorer.
so lucky we are to have es6 and node.js in our days
+Mandar Ponkshe I'am a full stack js developer building realtime app distribution servers, video servers, other kinds of servers, mobile apps, websites, desktop apps, different daemons, and all this stuff using only js. thought i have some php background, php is a far more worse language than js to build servers, and ofcourse you don't need any php if you are only building spa client apps. Thought some basic knowledge of php would always be nice in the modern web world
+Danila Plee : I'm just entering the advance concepts of JS. What are the things I should aware to get in deep with Full stack JS developer?
+Danila Plee are you saying PHP is not worth learning? and its better to focus on JS and node.js?
That just makes the use of === more preferable
ES5 (2009) vs ES9 (2019)
There are IDEs for Lisp and Scheme too, everybody still uses emacs
I think after 11 years this deserves at least 1 thumbs up 😎👍
Umm, now I know where Resig, umm, learned his speaking style.
This is the father of all fathers when it comes to javascript.
In regards to code protection, no language is safe unless the hardware is controlled. JavaScript is just far less safe than others. Your best bet for protection is provisioning obfuscated files to clients based on authorization status.
If you're arguing that Java is good for the designers who don't have a team of their own (hobbyists), then I can only agree with you. As a software engineer though, my primary choices would be C, Go, and Python (mainly for prototyping).
DAYUMN
1:03:47
DAYUUUUMN
Besides loose typing, that short list of good parts would only accommodate more experienced programmers. Never the less I will continue to learn this language as my first language but it is not a good beginners language overall.
It is really hard for me to start coding in JavaScript after 5 months with C#.
Whats your point? So what if its a feature in Python, that doesn't negate the assertion that its a good feature.
yep, just use the cracks :)
Actually, Java would be the beginner's language. Saving memory management/pointers and their associated gotchas for later is much better for a beginner just trying to grasp how variables, methods/functions, constructors/destructors, etc work
Have you tried googling it?
When he said: "And finally from Perl we get a really horrendus regular expression syntax." I can sense he lost the audience and they were all dying to scream at him to tell him 'YOURE WRONG DOUG!!'
i see the discussion more of a beat around the bush than the relevancy
0 == '0' should be false right?
and false == '0' why the hack is that true ?
and that last one with the string how ?
are strings '\0' terminated? and it evals the last element in the array of strings?
aaahh my head hurts.
These are the result of it converting types to try and find equality. 0 == '0' because it realises both are zero, kinda. false == '0' for the same reason, '0' is interpreted as 0 which is false when used as a boolean. Nothing to do with null terminators, there's an explicit table of conversions that it is willing to make. And this is why people recommend avoiding it and just using ===.
54min into the video he claims HTML5 and JavaScript are going in a bad direction? I have spend months trying to find the right programming language to learn and a book to go with it. I came up with Head First HTML5 Programming. Now after hearing this I am not sure If I should continue reading this book. I dont want to go in a bad direction with this.
block { } at 30:42