Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Douglas Crockford makes reference to Simplified JavaScript in this article about Top Down Operator Precedence. Unfortunately he only makes references to it in this article. The best explanation I found here. But I still don't have a clue what it actually is.

What is Simplified JavaScript?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

Douglas Crockford, in his book JavaScript: The Good Parts (p. 98-99), describes Simplified JavaScript:

I was invited last year to contribute a chapter to Andy Oram’s and Greg Wilson’s Beautiful Code (O’Reilly), an anthology on the theme of beauty as expressed in com- puter programs. I wanted to write my chapter in JavaScript. I wanted to use it to present something abstract, powerful, and useful to show that the language was up to it. And I wanted to avoid the browser and other venues in which JavaScript is typecast. I wanted to show something respectable with some heft to it.

I immediately thought of Vaughn Pratt’s Top Down Operator Precedence parser, which I use in JSLint (see Appendix C). Parsing is an important topic in computing. The ability to write a compiler for a language in itself is still a test for the complete- ness of a language.

I wanted to include all of the code for a parser in JavaScript that parses JavaScript. But my chapter was just one of 30 or 40, so I felt constrained in the number of pages I could consume. A further complication was that most of my readers would have no experience with JavaScript, so I also would have to introduce the language and its peculiarities.

So, I decided to subset the language. That way, I wouldn’t have to parse the whole language, and I wouldn’t have to describe the whole language. I called the subset Simplified JavaScript. Selecting the subset was easy: it included just the features that I needed to write a parser. This is how I described it in Beautiful Code:

Simplified JavaScript is just the good stuff, including:

Functions as first class objects: Functions in Simplified JavaScript are lambdas with lexical scoping.

Dynamic objects with prototypal inheritance: Objects are class-free. We can add a new member to any object by ordinary assignment. An object can inherit members from another object.

Object literals and array literals: This is a very convenient notation for creating new objects and arrays. JavaScript literals were the inspiration for the JSON data interchange format.

The subset contained the best of the Good Parts. Even though it was a small language, it was very expressive and powerful. JavaScript has lots of additional features that really don’t add very much, and as you’ll find in the appendixes that follow, it has a lot of features with negative value. There was nothing ugly or bad in the sub- set. All of that fell away.

share|improve this answer
    
Doug Crockford's jslint will parse a program and flag anything that deviates from the good parts. I recommend it for all javascript programs. –  Zachary K May 15 '11 at 15:08
add comment

Douglas Crockford (in that article) writes a parser (in JavaScript) which handles a simplified set of JavaScript.

share|improve this answer
    
I guess what I'm getting at is, what is that simplified set of JavaScript. –  Derek Adair Jan 2 '11 at 16:29
    
@Derek: See pwc's answer for a more complete description. –  Josh K Jan 2 '11 at 16:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.