Presentation is loading. Please wait.

Presentation is loading. Please wait.

Eric Roberts Professor of Computer Science Stanford University Google Atlanta October 1, 2010 Converting Java into JavaScript.

Similar presentations


Presentation on theme: "Eric Roberts Professor of Computer Science Stanford University Google Atlanta October 1, 2010 Converting Java into JavaScript."— Presentation transcript:

1 Eric Roberts Professor of Computer Science Stanford University Google Atlanta October 1, 2010 Converting Java into JavaScript

2 What Got Me Started? Back in the 1990s, I was frustrated by the fact that—unlike the situation in most sciences—you can’t walk into your favorite bookstore and find a book about the great intellectual ideas in computer science. Walk into any bookstore, and you’ll see how to Teach Yourself Java in 7 Days alongside endless variations offering to teach Visual Basic, Windows, the Internet, and so on in a few days or hours. I did the following power search at Amazon.com: pubdate: after 1992 and title: days and (title: learn or title: teach yourself) and got back 248 hits. The first 78 were computer books (number 79 was Learn Bengali in 30 days). I replaced “days” with “hours” and got remarkably similar results: 253 more books, with 77 computer books followed by Teach Yourself Grammar and Style in 24 Hours at number 78. Out of the top 200 total, 96% were computer books. —Peter Norvig, “Learn Programming in Ten Years,” 2001. What is in the bookstore? Peter Norvig, Google’s Director of Research, tells the story better than anyone else:

3 Talking about Great Ideas In response, I started both teaching a course and developing a book on the theme of The Intellectual Excitement of Computer Science. Since that time, I have taught the course 12 times. I’m still working on the book. It was clear to me that such a book would be effective with a general audience only if readers could play with the ideas. To that end, I developed a simplified teaching language called MiniJava along with Java-based applets that let readers work with different machine models and algorithmic ideas, such as: −Karel the Robot −Babbage machines −Turing machines −The Enigma machine −Finite state machines −Various classic computer science games and algorithms

4 Writing Books in Internet Time Unfortunately, several of the design decisions in the book have proven to be less than ideal with the passage of time: −Java has proven to be difficult to use at the introductory level.

5 The March of Progress 266 pages 274 pages 911 pages 1536 pages A sobering thought: There are more public methods in the java and javax package hierarchies than there are words in Jensen and Wirth’s Pascal User Manual and Report. The amount of explanation once deemed sufficient to teach the standard introductory programming language is thus no longer sufficient for an index of the operations available today.

6 Writing Books in Internet Time Unfortunately, several of the design decisions in the book have proven to be less than ideal with the passage of time: −Java has proven to be difficult to use at the introductory level. −It was impossible to maintain the alignment between Java and MiniJava as Java evolved. −Java applets are no longer well supported in all browsers, having lost the battle for client-side programming to JavaScript. For a number of years—and four other books—I’ve been at something of an impasse in terms of knowing how to proceed. And then, on May 22, 2010...

7 The Inspiration

8 Divergent Views of the Impact

9 The Challenge I had all of these applets running in Java. PacMan had shown that the level of interactivity I needed was available in JavaScript. Would it be possible to translate the Java applets I had into JavaScript with minimal work? I looked at Google’s work in the area and decided that the learning curve might be too high. I decided it would be fun to sit down and see how close I could come without writing any difficult code. The bottom line: I was able to get my applets working by introducing some straightforward modifications to the Java code and then running those programs through what is essentially a sed -script translator.

10 The Easy Declarations (changing types to var ) Integer division ( 3 / 2 is 1.5 in JavaScript) Object and method syntax

11 The Tricky Inheritance Method overloading JavaScript’s broken iterator syntax for arrays

12 The Really Difficult The lack of threads and any mechanism for waiting Java packages that use that model My solution: Rewrite the Java programs to use a pure-event model that makes translation easy

13 Demo Time

14 The End


Download ppt "Eric Roberts Professor of Computer Science Stanford University Google Atlanta October 1, 2010 Converting Java into JavaScript."

Similar presentations


Ads by Google