

SICP translated to JavaScript - Splendor
http://www.comp.nus.edu.sg/~cs1101s/sicp/
Sections of Structure and Interpretation of Computer Programs translated to JavaScript by Professor Martin Henz with executable examples.
======
neilk
Obvious objections - JS has no tail call elimination, no macros, and state-
changing is managed with entirely different conventions in Scheme. Also the
conceit of SICP (not really justified) is that they don't have to teach you
syntax, because homoiconicity. Still, I think it's a worthy pursuit to try to
bring the insights of this book to a wider audience.

Side note: the navigation is really irritating. The back button only works
sometimes, because it's replacing content without doing some kind of
pushState. So you have to hunt for links.

Another side note: Sean Burke and Piers Cawley have ported some of mjd's
excellent book Higher-Order Perl to JavaScript. This might be even better,
because both Perl and JS have C-like syntax hiding some impressive functional
capabilities. I wish someone would finish that, but I guess few people even
know about HOP, these days.

[http://interglacial.com/hoj/hoj.html](http://interglacial.com/hoj/hoj.html)

[http://www.bofh.org.uk/2010/11/18/higher-order-
javascript](http://www.bofh.org.uk/2010/11/18/higher-order-javascript)

~~~
btilly
I know HOP.

It depresses me how much of HOP is irrelevant in Python because they have
proper iterators. And how few Perl programmers realize that these days the
lack is a major omission in the language.

~~~
xiaoma
JavaScript doesn't have them either, until you include a functional toolchain
library like Underscore. Does Perl have any similar library?

~~~
neilk
JS 1.7, already available in some browsers and bleeding edge Node, has
iterators and generators.

[https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Guid...](https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Guide/Iterators_and_Generators)

------
dysoco
What's next? "Advanced Programming in the Unix Environment: Now with
Javascript!" ?

Or "Linux Device Drivers: Javascript edition" ?

Can we just accept that JS is not for everything?

~~~
jophde
I just want to meet one programmer who can work on server side code, client
side code, etc who can't handle them being written in different languages.
This fad just doesn't make any sense to me. Let's reinvent the wheel so we can
have JSON literals instead of Ruby hashes!

~~~
erikpukinskis
I always thought this would be self-evident to people, but apparently not: The
reason why I want to have Javascript on both the client and the server is so I
can re-use code.

My software has a fairly large chunk of code which is a gardening expert
system. I'm hesitant to call it AI because it's so dumb, but it's along those
lines. It knows things like "If you live in Phoenix and it's April, you should
wait to plant your lettuce until September".

It's useful to have it on the client, when you're in the garden and there's no
connectivity, or when you tweak your settings and don't want to have to
download a bunch of "conclusions" from the server. It's useful to have it on
the server so that the server can send emails, pre-cache HTML for faster
loading pages, etc.

If my server is written in Ruby (which is is right now) then I have to re-
implement that entire system twice. That's double the code. It feels gross.
And I can't help but feel like most web-apps have code like this that could be
shared between the client and the server.

~~~
acjohnson55
Fortunately, I think we're entering an era where JS can be a nearly
transparent target language for translation from the languages of our choice,
with things like asm.js and source maps. We're not quite there yet, but it
definitely seems like where we're going.

~~~
Tichy
I'd prefer the other way round. JavaScript is better than most popular
programming languages (including Python). It is not perfect, so I consent
there might better languages out there.

------
Gonzih
Really sad to see that such amazing book that uses such nice language is now
transformed to monster with JS. Why would you do that? Painful to see all
that...

~~~
10098
This will only serve to perpetuate the stupid meme that "Javascript is
basically Scheme with curly braces and semicolons"

~~~
discreteevent
[http://journal.stuffwithstuff.com/2013/07/18/javascript-
isnt...](http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt-scheme/)

(Note that the author intended this to be humourous/exaggerated - Some people
took exception though.)

------
anaphor
Most of chapter 4 will be impossible to really translate to JS because JS has
no macros (required to implement some of the special forms like delay) and
isn't homoiconic.

~~~
azakai
[http://sweetjs.org/](http://sweetjs.org/)

~~~
spacemanaki
It's not about macros, it's about homoiconicity. I encourage you to read
chapters 4 and 5 and think about how sweet.js would help you port those
chapters to JS.

------
vezzy-fnord
Some people will stop at nothing to convert the world to JavaScript and Ruby.

(please don't do the latter... or is it too late?)

~~~
davexunit
The web developers have taken over, it seems.

Edit: I say this as a web developer. I feel like it's often forgotten that
Ruby and Javascript aren't the only languages worth using.

~~~
pjmlp
Well, I never used Ruby, besides to see what this Ruby on Rails was all about
and I already knew Python since the version 1 days.

For me the only place for JavaScript is on the browser.

For anything else, there are endless languages to choose from.

~~~
seiji
_For anything else, there are endless languages to choose from._

The Americans have taken over and the Americans have, based on their own
linguistic experience, decided most people can only handle one spoken language
and one programming language.

For some of us, we can handle six programming languages and be fine.

For "average" people, they're lucky to get one programming language, so it was
decided to fad-hype-hipster promote One Language To Rule Them All for fronted,
backend, sideend, middleware, topware, bottomware, programming your embedded
system, programming your car, scripting your operating system, and programming
your blender.

Look on github for how many people write shell scripts in ruby because they
don't know how bash works. You can find the same over-syntax'd-programming-
environment-as-shell-script with node too. We're the exceptions. They can't
handle the truth.

~~~
mbillie1
> Look on github for how many people write shell scripts in ruby because they
> don't know how bash works. You can find the same over-syntax'd-programming-
> environment-as-shell-script with node too. We're the exceptions. They can't
> handle the truth.

As someone who has done this (and who currently works in C), I will say only
that shell scripts translated to Ruby can be a lot easier to read and maintain
than those written in bash... if I get to the point where I'm having to pipe
to more than two of awk/sed/grep I will generally just write it in Ruby,
because then my mother could read it. YMMV though. In every other sense I
agree with you entirely, and I think the proliferation of JS rewrites of
things that work in actually-designed languages is appalling.

~~~
seiji
You found the one exception. There's a fuzzy line when dealing with shell
scripts.

If you're just iterating over a directory and checking some files, that's
great shell script territory. If you're making a launcher script for another
program to set the environment, check directories, fix permissions, and run
pre-flight checks, that's great for shell script.

But, sometimes we end up with feature creep. You start out with "Well, this
shell script just has to parse some CSV and insert into sqlite" then before
you know it, it also has to check another pre-existing DB for redundancy
checks or constraints, then you're 100 pages into the Advanced Bash-Scripting
Guide trying to make Bash do something that would be a six liner in Perl 4.

The benefits of over-programming bash scripts is extensive portability though
(if you make sure you aren't using features only in very late version of the
shell).

~~~
kbenson
Except if by portability you include non-unix systems. Then you're probably
better off with Perl (for example) again.

------
agumonkey
Porting it to javascript kinda defeats the idea that principles described here
transcends any current trend.

~~~
francis-
BINGO!

------
davexunit
What an abomination.

~~~
indubitably
Wow, stay classy.

------
zodiac
Background: this is the textbook used for a class at NUS (National University
of Singapore). Previous iterations of the class, CS1101S, used the original
scheme version of SICP, but omitted chapters 4 and 5 in the interest of time.
[1]

I took the scheme version of the class and learned a ton. From what I've
heard, the reasons for the switch included javascript being more practical and
the previous professor deciding to take a break from teaching that class.
Basically, many of the reasons overlap with that for Berkeley switching 61A
from scheme to python [2].

I've also heard that the javascript version of the class is just as rigorous
and challenging as the scheme version.

Shameless plug: if you want an interactive version of SICP in the original
scheme, check out
[http://xuanji.appspot.com/isicp/1-1-elements.html](http://xuanji.appspot.com/isicp/1-1-elements.html)

[1] Which might explain why the lack of macros in javascript wasn't a concern

[2]
[http://www.eecs.berkeley.edu/~bh/61a.html](http://www.eecs.berkeley.edu/~bh/61a.html)

------
jfe
why, God, why?

~~~
hackNightly
Perhaps due to the increasing popularity of JavaScript and the decreasing
accessibility or usage of Scheme.

~~~
brudgers
Due to the increasing popularity of casual dining and the decreasing
accessibility of Danish nobility, I've rewritten Hamlet to be an Appleby's
assistant manager.

The fifth act of SICP is meta-linguistic abstraction, and among Javascript's
merits it is not. SICP is no more a book about Scheme than _Moby Dick_ is a
whale tale.

I admire the effort, and understand the sentiment behind the project. I just
think the authors are missing the big picture of SICP. In fairness, few of us
are Ablesons or Sussmans.

~~~
dragonwriter
> Due to the increasing popularity of casual dining and the decreasing
> accessibility of Danish nobility, I've rewritten Hamlet to be an Appleby's
> assistant manager.

Replace "casual dining" with "megacorporations" and you get an actual movie
made in 2000 [1]. And, of course, that example is not unique
[2][3][4][5][6][7][8][9][10].

[1]
[http://www.imdb.com/title/tt0171359/](http://www.imdb.com/title/tt0171359/)

[2]
[http://www.imdb.com/title/tt0114279/](http://www.imdb.com/title/tt0114279/)

[3]
[http://www.imdb.com/title/tt0117509/](http://www.imdb.com/title/tt0117509/)

[4]
[http://www.imdb.com/title/tt0184791/](http://www.imdb.com/title/tt0184791/)

[5]
[http://www.imdb.com/title/tt0265713/](http://www.imdb.com/title/tt0265713/)

[6] _et cetera_

[7] _et cetera_

[8] _et cetera_

[9] _ad nauseum_

[10] _ad infinitum_

------
DanBC
Cool - next they should try "How to Solve it by computer"
([http://www.amazon.com/Computer-Prentice-Hall-
International-S...](http://www.amazon.com/Computer-Prentice-Hall-
International-Series-Science/dp/0134340019))

------
joe5150
Meta-gripe: the navigation seems to use some kind of asynch loading without
pushing to the browser history stack, and I'm finding it very difficult to
move back and forth from the ToC to chapters. Maybe this can be addressed.

~~~
mbillie1
Check out my new library, SICPinJSnavigation.js

------
snaky
Why so square? Translating SICP to Forth would be at least eclectic and truly
creative gesture.

~~~
rspeer
JonesForth at least seems in the same spirit as SICP, though what it
accomplishes is different.

It explains and implements a Forth environment from scratch, initially in
literate assembler code (yes, that exists) and then, once that's bootstrapped
enough, in literate Forth that it runs using itself.

[http://sage.math.washington.edu/home/wstein/www/home/wbhart/...](http://sage.math.washington.edu/home/wstein/www/home/wbhart/jonesforth.S)

------
scorpion032
"An invasion of armies can be resisted; an invasion of ideas cannot be
resisted" \-
[http://en.wikiversity.org/wiki/Victor_Hugo_quote](http://en.wikiversity.org/wiki/Victor_Hugo_quote)

This generation is going to be rewrite in Javascript/v8, everything that can
be written in Javascript.

~~~
qu4z-2
And a few things that can't, I suspect.

------
aufreak3
Btw Prof. Martin Henz was one of the major contributors to the design of Oz.

------
011011100
It's like you didn't even understand why it was done in scheme...

------
contingencies
Wanted to care but the page wouldn't display without Javascript.

------
hepek
blasphemy!

