Douglas Crockford: JavaScript Doesn’t Suck

Share this article

At the Web Directions South conference last week, SitePoint’s Kevin Yank had the opportunity to speak with Douglas Crockford, Yahoo architect and expert on all things JavaScript.

Douglas presented a talk entitled Web Forward! (formerly Ajax Security), in which he described the potential of – and problems with – JavaScript as a language, and how it would need to change for the Web to continue its evolution. He focused heavily on how the current process for developing web standards is failing us, and how the looming browser war could provide the solution.

Hi, this is Kevin Yank from sitepoint.com, and I’m here at Web Directions South, 2008 with Douglas Crockford from Yahoo. Hi Doug.

Hi.

So, I’ve heard you say several times just how much JavaScript sucks, and how many problems there are with it, and yet you seem to devote yourself to it with a lot of passion. Why is that?

I don’t think you’ve heard me say it sucks, because that’s not my position, except occasionally when I’m echoing the sentiment of the market.

Ah, that’s fair enough.

I am very clear about its shortcomings. But I believe that if you strip away its shortcomings, what you’re left with is actually an elegant, beautiful little language. And it’s not only a beautiful little language, but it’s also a powerful one, and one that is more widely deployed than any other language in the world.

Yeah. And it’s continually surprising to me just how capable a language it is, given where it came from. I mean, one day in the 1990s, Netscape said, “We need a little language to run in our browser.” And what we ended up with was very close to the JavaScript that we have today. How did Netscape end up with it as a language, answering that need at the time?

They were really lucky. Given the process that created the language, we should have gotten something much, much worse, because they didn’t do a careful design of requirements. They certainly didn’t give enough time for its design or its implementation. They took a prototype, which was intended just as a proof of concept, and that’s what they shipped. And it had all the problems that you would expect such an implementation to have. And it was partly on the basis of that implementation that the language got the terrible reputation that it had. And a lot of those defects are still in the language.

But beyond all of that, there were a couple of extremely clever ideas that were also in there, which have since been revealed, which give the language amazing, expressive power. But at the same time, it’s extremely accessible for beginners. And since, for most web developers, JavaScript is their first programming language, that’s an extremely valuable feature to have. A lot of JavaScript’s critics want to go back in the other direction, and make it more Java-like, but I think that would be a bad thing because it would alienate most web developers.

So, I’d rather go in the other direction and train our web developers how to be programmers, how to be computer scientists, because you can in this language. It’s possible to write good programs in this language, which is something we didn’t know before. And beyond that, I’m now insisting it’s necessary to write good programs, because if the programs are not good, they’re not going to scale, and they’re not going to be secure. The language is good enough to support that mission, so it works.

You recently wrote the book, JavaScript: The Good Parts, and I recently wrote a book about JavaScript myself. And what I found a lot of the time as I was writing it was, as you say, you have to try to train people what not to use in JavaScript.

For me, the strength of the Web is its accessibility, not just for people reading it, but for those publishing new content. I’m interested, as JavaScript moves forward and we try to correct these problems with it, whether we’ll be able to preserve that low barrier to entry that makes JavaScript something someone can pick up as their first language and feel confident with after a day or two?

I think so, and I think we need to. We would be making a tragic mistake if we didn’t retain the language’s simplicity. Most of the modifications I would like to make in the language would be to make it even simpler. There’s some cruft on it, and there are some attractive nuisances in it, which we don’t need but which people become dependent on. We’d be better off without that.

Unfortunately with the Web, once something bad gets in it, it takes years to get rid of it. Ajax didn’t happen until 2005, but all of the technology that we needed for Ajax was in place and in the field in 2000. Most of that five years was spent removing old browsers from the marketplace until there was enough of an audience on IE6, making Ajax a viable application platform.

I’ve admired Yahoo’s educational initiative – its pattern library and the Yahoo Developer Network. How did that come about? Has it been a success for Yahoo?

I think it has been a success. You know, there are some brilliant people at Yahoo. There always have been. For years we kept that fact a secret. We’re not doing that so much anymore. I’m really happy to see that we’re being more open now, and we’re sharing what we know with the rest of the community. It’s clearly been a good thing, and there’s been a lot of interest in what we’ve released.

No doubt the infamous line from your talk today will be that we need another browser war. What aspects of a browser war lead to progress and moving the Web forward? What do we want to see the browser vendors fighting over? Is it user market share, or is it developer mind share, or is it a bit of everything?

It’s going to be everything. There will probably be fronts on the war, and it may be that different things are hot at different times. But the problem that we have now is that we’re stuck. Our technology hasn’t evolved at all since the Ajax set got put in place in 1999, and the way we understand web applications today is radically different. So we’re now trying to go forward with the wrong technology, and it’s inadequate. We’ve tried to go forward using the standards process at W3C and ECMA; that process is not effective, so we need to find another way.

I’m not really proposing a browser war – it’s going to happen by itself. I wish I had the power to say, “This is what we must do.” The best I can do is recognize, “This is what’s going to happen, and we should figure out a way to take best advantage of it.”

Yahoo is a relatively recent addition to the ECMAScript standards body; you’ve spoken about how you’re hoping to lead a more conservative approach to that standardization, where the standards body follows behind the implementation, and documents what’s really good, what’s proven. With that happening, how is JavaScript going to get better? Where are those conversations on the leading edge going to happen?

They may still happen at ECMA. I’m starting a process at ECMA to look at creating a safe dialect of JavaScript, or a capability dialect of JavaScript. That’ll be happening at ECMA, involving ECMA members. I’m hoping I can open it up to some non-ECMA members as well. Our initial motivation will not be to write a standard, but to come up with a language that we can test. We’ll try to get the language tested, see if we can get it deployed, see if it actually does what it needs to, and then we’ll try to make a standard.

I think that’s the proper sequence for everything, but in the last few years web standards – at least for the last ten years – web standards have lost focus. They’ve been more about invention than about codification, and I think that is unhealthy. At best it’s been unproductive, and at worst we’ve seen bad standards come out of that.

For example, CSS2 was un-implementable, and eventually it had to be revised as CSS2.1 – an attempt to cut CSS2 down to what people were able to figure out how to implement. That sequence was totally backwards – or it started backwards, but eventually they got it right. Let’s look at what can actually work and make a standard out of that, and then let everybody catch up with each other. I think that’s a proper role for standards.

What I see happening now with HTML5 is appalling. There is some stuff there that I really like: I really like that they figured out what the rules of HTML parsing are. Brilliant. That’s long overdue. And you can look at any individual feature that they’re doing and say, “Yeah, that makes sense.” But there’s just too much, and there’s not a good set of trade-offs, there’s not a complexity budget. It’s not motivated by real need, but by what’s shiny in front of a committee.

So, I would like to find a way to inject more discipline into the process, and I think one way to do it is to change it to an evaluation and description process, where we’ll observe what’s going on out in the wild, and document the best of it. And that documentation process is really hard – it’s a lot of work. Taking something as complex as a computer system and describing it in a way which is generally useful is difficult. It’s good that we have these organizations to do that work, but that should be their focus.

One of the projects you mentioned in your talk was AdSafe, a method of injecting ads into pages in a safe way, so that the ads don’t have unfettered access to the rest of the site that’s hosting them. Speaking from the perspective of a site that runs ads and receives the most appalling code from our advertisers – which they expect us to inject into our site – how do we get the advertising industry to buy into that?

We’re going to have to do it all together. At Yahoo we’ve talked about going to the industry, and then we always back down because we don’t want to be perceived as difficult to work with – we’re already perceived as difficult to work with! So, we need to approach them all at once and say, “Look, we can’t accept these lousy ads anymore. We need to have at least this level of technical quality if you want to get on our sites.”

I think computer networks are the only place where there are no such quality standards. If you want to show an ad on a television network, it’s going to be exactly thirty seconds. You don’t get to go longer if you want – it’s not an option. It’s got to be encoded properly, it’s got to be on a standard tape format … all that stuff. (Otherwise) there’s no play. We don’t have those sorts of limits on computer-based advertising, and we need to. So, this is a remedial effort that we have to undergo.

So, consider it a slight spoiler for your book, but if you had fifteen minutes of attention from everyone who’s writing JavaScript in the world today, what one thing would you teach them to do better – or not do – with the language, to improve JavaScript on the Web?

The number one thing is, be aware that you can and must write good programs. One of the principal measures of the quality of a program is its legibility. We should be writing programs for other people to read. And I recommend code reading as a standard process of all development activities, so a team would do weekly code readings at the least, whether you take time out to read each other’s code … I think the benefits that come from that are tremendous.

Great. Thanks very much!

Thank you.

Image credit: Web Directions

Kevin YankKevin Yank
View Author

Kevin Yank is an accomplished web developer, speaker, trainer and author of Build Your Own Database Driven Website Using PHP & MySQL and Co-Author of Simply JavaScript and Everything You Know About CSS is Wrong! Kevin loves to share his wealth of knowledge and it didn't stop at books, he's also the course instructor to 3 online courses in web development. Currently Kevin is the Director of Front End Engineering at Culture Amp.

Share this article
Read Next
Leveraging Progressive Web Apps (PWAs) for Enhanced Mobile User Engagement
Leveraging Progressive Web Apps (PWAs) for Enhanced Mobile User Engagement
SitePoint Sponsors
10 Artificial Intelligence APIs for Developers
10 Artificial Intelligence APIs for Developers
SitePoint Sponsors
The Ultimate Guide to Navigating SQL Server With SQLCMD
The Ultimate Guide to Navigating SQL Server With SQLCMD
Nisarg Upadhyay
Retrieval-augmented Generation: Revolution or Overpromise?
Retrieval-augmented Generation: Revolution or Overpromise?
Kateryna ReshetiloOlexandr Moklyak
How to Deploy Apache Airflow on Vultr Using Anaconda
How to Deploy Apache Airflow on Vultr Using Anaconda
Vultr
Cloud Native: How Ampere Is Improving Nightly Arm64 Builds
Cloud Native: How Ampere Is Improving Nightly Arm64 Builds
Dave NearyAaron Williams
How to Create Content in WordPress with AI
How to Create Content in WordPress with AI
Çağdaş Dağ
A Beginner’s Guide to Setting Up a Project in Laravel
A Beginner’s Guide to Setting Up a Project in Laravel
Claudio Ribeiro
Enhancing DevSecOps Workflows with Generative AI: A Comprehensive Guide
Enhancing DevSecOps Workflows with Generative AI: A Comprehensive Guide
Gitlab
Creating Fluid Typography with the CSS clamp() Function
Creating Fluid Typography with the CSS clamp() Function
Daine Mawer
Comparing Full Stack and Headless CMS Platforms
Comparing Full Stack and Headless CMS Platforms
Vultr
7 Easy Ways to Make a Magento 2 Website Faster
7 Easy Ways to Make a Magento 2 Website Faster
Konstantin Gerasimov
Powerful React Form Builders to Consider in 2024
Powerful React Form Builders to Consider in 2024
Femi Akinyemi
Quick Tip: How to Animate Text Gradients and Patterns in CSS
Quick Tip: How to Animate Text Gradients and Patterns in CSS
Ralph Mason
Sending Email Using Node.js
Sending Email Using Node.js
Craig Buckler
Creating a Navbar in React
Creating a Navbar in React
Vidura Senevirathne
A Complete Guide to CSS Logical Properties, with Cheat Sheet
A Complete Guide to CSS Logical Properties, with Cheat Sheet
Ralph Mason
Using JSON Web Tokens with Node.js
Using JSON Web Tokens with Node.js
Lakindu Hewawasam
How to Build a Simple Web Server with Node.js
How to Build a Simple Web Server with Node.js
Chameera Dulanga
Building a Digital Fortress: How to Strengthen DNS Against DDoS Attacks?
Building a Digital Fortress: How to Strengthen DNS Against DDoS Attacks?
Beloslava Petrova
Crafting Interactive Scatter Plots with Plotly
Crafting Interactive Scatter Plots with Plotly
Binara Prabhanga
GenAI: How to Reduce Cost with Prompt Compression Techniques
GenAI: How to Reduce Cost with Prompt Compression Techniques
Suvoraj Biswas
How to Use jQuery’s ajax() Function for Asynchronous HTTP Requests
How to Use jQuery’s ajax() Function for Asynchronous HTTP Requests
Aurelio De RosaMaria Antonietta Perna
Quick Tip: How to Align Column Rows with CSS Subgrid
Quick Tip: How to Align Column Rows with CSS Subgrid
Ralph Mason
15 Top Web Design Tools & Resources To Try in 2024
15 Top Web Design Tools & Resources To Try in 2024
SitePoint Sponsors
7 Simple Rules for Better Data Visualization
7 Simple Rules for Better Data Visualization
Mariia Merkulova
Cloudways Autonomous: Fully-Managed Scalable WordPress Hosting
Cloudways Autonomous: Fully-Managed Scalable WordPress Hosting
SitePoint Team
Best Programming Language for AI
Best Programming Language for AI
Lucero del Alba
Quick Tip: How to Add Gradient Effects and Patterns to Text
Quick Tip: How to Add Gradient Effects and Patterns to Text
Ralph Mason
Logging Made Easy: A Beginner’s Guide to Winston in Node.js
Logging Made Easy: A Beginner’s Guide to Winston in Node.js
Vultr
How to Optimize Website Content for Featured Snippets
How to Optimize Website Content for Featured Snippets
Dipen Visavadiya
Psychology and UX: Decoding the Science Behind User Clicks
Psychology and UX: Decoding the Science Behind User Clicks
Tanya Kumari
Build a Full-stack App with Node.js and htmx
Build a Full-stack App with Node.js and htmx
James Hibbard
Digital Transformation with AI: The Benefits and Challenges
Digital Transformation with AI: The Benefits and Challenges
Priyanka Prajapat
Quick Tip: Creating a Date Picker in React
Quick Tip: Creating a Date Picker in React
Dianne Pena
How to Create Interactive Animations Using React Spring
How to Create Interactive Animations Using React Spring
Yemi Ojedapo
10 Reasons to Love Google Docs
10 Reasons to Love Google Docs
Joshua KrausZain Zaidi
How to Use Magento 2 for International Ecommerce Success
How to Use Magento 2 for International Ecommerce Success
Mitul Patel
5 Exciting New JavaScript Features in 2024
5 Exciting New JavaScript Features in 2024
Olivia GibsonDarren Jones
Tools and Strategies for Efficient Web Project Management
Tools and Strategies for Efficient Web Project Management
Juliet Ofoegbu
Choosing the Best WordPress CRM Plugin for Your Business
Choosing the Best WordPress CRM Plugin for Your Business
Neve Wilkinson
ChatGPT Plugins for Marketing Success
ChatGPT Plugins for Marketing Success
Neil Jordan
Managing Static Files in Django: A Comprehensive Guide
Managing Static Files in Django: A Comprehensive Guide
Kabaki Antony
The Ultimate Guide to Choosing the Best React Website Builder
The Ultimate Guide to Choosing the Best React Website Builder
Dianne Pena
Exploring the Creative Power of CSS Filters and Blending
Exploring the Creative Power of CSS Filters and Blending
Joan Ayebola
How to Use WebSockets in Node.js to Create Real-time Apps
How to Use WebSockets in Node.js to Create Real-time Apps
Craig Buckler
Best Node.js Framework Choices for Modern App Development
Best Node.js Framework Choices for Modern App Development
Dianne Pena
SaaS Boilerplates: What They Are, And 10 of the Best
SaaS Boilerplates: What They Are, And 10 of the Best
Zain Zaidi
Understanding Cookies and Sessions in React
Understanding Cookies and Sessions in React
Blessing Ene Anyebe
Enhanced Internationalization (i18n) in Next.js 14
Enhanced Internationalization (i18n) in Next.js 14
Emmanuel Onyeyaforo
Essential React Native Performance Tips and Tricks
Essential React Native Performance Tips and Tricks
Shaik Mukthahar
How to Use Server-sent Events in Node.js
How to Use Server-sent Events in Node.js
Craig Buckler
Five Simple Ways to Boost a WooCommerce Site’s Performance
Five Simple Ways to Boost a WooCommerce Site’s Performance
Palash Ghosh
Elevate Your Online Store with Top WooCommerce Plugins
Elevate Your Online Store with Top WooCommerce Plugins
Dianne Pena
Unleash Your Website’s Potential: Top 5 SEO Tools of 2024
Unleash Your Website’s Potential: Top 5 SEO Tools of 2024
Dianne Pena
How to Build a Chat Interface using Gradio & Vultr Cloud GPU
How to Build a Chat Interface using Gradio & Vultr Cloud GPU
Vultr
Enhance Your React Apps with ShadCn Utilities and Components
Enhance Your React Apps with ShadCn Utilities and Components
David Jaja
10 Best Create React App Alternatives for Different Use Cases
10 Best Create React App Alternatives for Different Use Cases
Zain Zaidi
Control Lazy Load, Infinite Scroll and Animations in React
Control Lazy Load, Infinite Scroll and Animations in React
Blessing Ene Anyebe
Building a Research Assistant Tool with AI and JavaScript
Building a Research Assistant Tool with AI and JavaScript
Mahmud Adeleye
Understanding React useEffect
Understanding React useEffect
Dianne Pena
Web Design Trends to Watch in 2024
Web Design Trends to Watch in 2024
Juliet Ofoegbu
Building a 3D Card Flip Animation with CSS Houdini
Building a 3D Card Flip Animation with CSS Houdini
Fred Zugs
How to Use ChatGPT in an Unavailable Country
How to Use ChatGPT in an Unavailable Country
Dianne Pena
An Introduction to Node.js Multithreading
An Introduction to Node.js Multithreading
Craig Buckler
How to Boost WordPress Security and Protect Your SEO Ranking
How to Boost WordPress Security and Protect Your SEO Ranking
Jaya Iyer
Understanding How ChatGPT Maintains Context
Understanding How ChatGPT Maintains Context
Dianne Pena
Building Interactive Data Visualizations with D3.js and React
Building Interactive Data Visualizations with D3.js and React
Oluwabusayo Jacobs
JavaScript vs Python: Which One Should You Learn First?
JavaScript vs Python: Which One Should You Learn First?
Olivia GibsonDarren Jones
13 Best Books, Courses and Communities for Learning React
13 Best Books, Courses and Communities for Learning React
Zain Zaidi
5 jQuery.each() Function Examples
5 jQuery.each() Function Examples
Florian RapplJames Hibbard
Implementing User Authentication in React Apps with Appwrite
Implementing User Authentication in React Apps with Appwrite
Yemi Ojedapo
AI-Powered Search Engine With Milvus Vector Database on Vultr
AI-Powered Search Engine With Milvus Vector Database on Vultr
Vultr
Understanding Signals in Django
Understanding Signals in Django
Kabaki Antony
Why React Icons May Be the Only Icon Library You Need
Why React Icons May Be the Only Icon Library You Need
Zain Zaidi
View Transitions in Astro
View Transitions in Astro
Tamas Piros
Getting Started with Content Collections in Astro
Getting Started with Content Collections in Astro
Tamas Piros
What Does the Java Virtual Machine Do All Day?
What Does the Java Virtual Machine Do All Day?
Peter Kessler
Become a Freelance Web Developer on Fiverr: Ultimate Guide
Become a Freelance Web Developer on Fiverr: Ultimate Guide
Mayank Singh
Layouts in Astro
Layouts in Astro
Tamas Piros
.NET 8: Blazor Render Modes Explained
.NET 8: Blazor Render Modes Explained
Peter De Tender
Mastering Node CSV
Mastering Node CSV
Dianne Pena
A Beginner’s Guide to SvelteKit
A Beginner’s Guide to SvelteKit
Erik KückelheimSimon Holthausen
Brighten Up Your Astro Site with KwesForms and Rive
Brighten Up Your Astro Site with KwesForms and Rive
Paul Scanlon
Which Programming Language Should I Learn First in 2024?
Which Programming Language Should I Learn First in 2024?
Joel Falconer
Managing PHP Versions with Laravel Herd
Managing PHP Versions with Laravel Herd
Dianne Pena
Accelerating the Cloud: The Final Steps
Accelerating the Cloud: The Final Steps
Dave Neary
An Alphebetized List of MIME Types
An Alphebetized List of MIME Types
Dianne Pena
The Best PHP Frameworks for 2024
The Best PHP Frameworks for 2024
Claudio Ribeiro
11 Best WordPress Themes for Developers & Designers in 2024
11 Best WordPress Themes for Developers & Designers in 2024
SitePoint Sponsors
Top 10 Best WordPress AI Plugins of 2024
Top 10 Best WordPress AI Plugins of 2024
Dianne Pena
20+ Tools for Node.js Development in 2024
20+ Tools for Node.js Development in 2024
Dianne Pena
The Best Figma Plugins to Enhance Your Design Workflow in 2024
The Best Figma Plugins to Enhance Your Design Workflow in 2024
Dianne Pena
Harnessing the Power of Zenserp for Advanced Search Engine Parsing
Harnessing the Power of Zenserp for Advanced Search Engine Parsing
Christopher Collins
Build Your Own AI Tools in Python Using the OpenAI API
Build Your Own AI Tools in Python Using the OpenAI API
Zain Zaidi
The Best React Chart Libraries for Data Visualization in 2024
The Best React Chart Libraries for Data Visualization in 2024
Dianne Pena
7 Free AI Logo Generators to Get Started
7 Free AI Logo Generators to Get Started
Zain Zaidi
Turn Your Vue App into an Offline-ready Progressive Web App
Turn Your Vue App into an Offline-ready Progressive Web App
Imran Alam
Clean Architecture: Theming with Tailwind and CSS Variables
Clean Architecture: Theming with Tailwind and CSS Variables
Emmanuel Onyeyaforo
How to Analyze Large Text Datasets with LangChain and Python
How to Analyze Large Text Datasets with LangChain and Python
Matt Nikonorov
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form