top | item 21822903

Structure and Interpretation of Computer Programs – JavaScript Adaptation

317 points| hwartig | 6 years ago |sicp.comp.nus.edu.sg

180 comments

order

brlewis|6 years ago

What an interesting and ambitious project! Of course the first thing I did was skim the Metacircular Interpreter section to see how they handled the additional syntactic complexity. They gloss over the "parse" function, which is probably the best one can do. That the Scheme function "read" could be implemented by a novice is one of the advantages of using Scheme for SICP and it wouldn't be reasonable to expect an adaptation like this to reproduce the exact experience. I do think it's great the way SICP leads people through doing powerful things with a programming language, and then shows them that they themselves could implement the language they've been using. It gives a powerful feeling of control in an environment (computer programming) that can otherwise be intimidating. I think this adaptation does almost the same thing.

The translation is pretty direct, so the data structures are more idiomatic to Scheme than they are to JavaScript. I think that's OK.

vanderZwan|6 years ago

> The translation is pretty direct, so the data structures are more idiomatic to Scheme than they are to JavaScript. I think that's OK.

I do wonder if it wouldn't be simpler to write a Scheme interpreter in JS (or take one of the undoubtedly existing ones) and make the book interactive with that.

This version feels more like something that has added value if you already know JS, not so much when you're learning JS

voldacar|6 years ago

There's kind of a reason why SICP was written in Scheme in mind and not a blub language...

braythwayt|6 years ago

Of course SICP is brilliant in Scheme. But hello? There is no such thing as a “blub language.” Your comment misrepresents the entire point of the original PG essay!

The point is that givens some fictional language called “Blub” for the sake of the essay, some programmers believe that their language has everything that could possibly be useful, productive, expressive, &c.

But PG’s contention that languages exist on a continuum of power (a gross oversimplification), and when a programmer believes that their “Blub” is as powerful as possible, they have closed their mind to more powerful/useful/expressive ideas.

But that’s as true of Scheme as it is of JS: If someone believes that LISP was the zenith of programming, and everything else since then has just been wankery, if they think we have nothing to learn from Haskell, or Julia, or Joy... Then for them, Scheme is Blub.

Blub is a mindset, not a language. Sure, some communities might be infested with Blub programmers, but nevertheless, languages themselves are not Blub.

Now, if someone says that SICP in JS proves that Scheme is no better than JS, well... That person has a Blub mindset. But teaching some of the same principles as SICP using JS is not in and of itself the Blub mindset.

Summary:

Blub is a mindset, not a language.

All languages are Blub languages if someone has the Blub mindset.

SICP in JS in-and-of-itself is not Blub.

JS in-and-of-itself is not Blub.

lifthrasiir|6 years ago

That's fine as long as we have both a canonical version written in Scheme and good "translations" to other languages---including "blub". Good translations should not diminish the value of the canonical SICP. It can be argued that this particular translation is not good; I guess not, as SICP JS's version of metacircular interpreter does interpret (a subset of) JavaScript! The cost is of course this complex definition [1] of which language metacircular interpreter is written in and implements.

[1] https://sicp.comp.nus.edu.sg/source/source_4.pdf

mattacular|6 years ago

Were you going to let the rest of us mere mortals in on the reason?

I think it's good to offer a version of SICP adapted to a language that's used today very prominently and is relevant to many current jobs in the industry.

agbell|6 years ago

Hal Abelson thinks that javascript is Today's Scheme. That is is carrying the flame of the ideas of Scheme forward.

jancsika|6 years ago

Holy shit I love that term "blub language."

I'm just imagining someone taking the text of Crockford's talks on Javascript, removing all his clear description of the language features, and replacing it with highly opinionated non-technical terms of derision like this.

Though not instructive, it would be really fun to read.

mananvaghasiya|6 years ago

“There are only two kinds of languages: the ones people complain about and the ones nobody uses.” ― Bjarne Stroustrup

dang|6 years ago

Please don't take HN threads into flamewar.

jcbrand|6 years ago

JavaScript is heavily influenced by Scheme, this is actually mentioned in the linked to book.

_pmf_|6 years ago

Hint: PG's little web shop would have been exactly as successful in PHP.

mpfundstein|6 years ago

what a stupid comment. why is modern javascript a blub language?

and what does it matter anyway? the concepts are the same.

ngcc_hk|6 years ago

Finally have a free 1 hour and try the site. The site cert. is not valid ... and also if you start with the book, click it does not result in running code. More important the first preface is about Scheme which I think it should be in reverse. My 1 hour up. May try later.

kyancey|6 years ago

What fresh hell is this?

braythwayt|6 years ago

Dorothy Parker, is that you?

nhlx2|6 years ago

Adaption - another term for adaptation.

jessaustin|6 years ago

It's a perfectly cromulent word, but at the link only "adaptation" appears.

anaphor|6 years ago

I was sure it wasn't a real word but you're correct, it's an alternative (but less common) spelling.

troymc|6 years ago

The page at the other end of the hyperlink uses the word "adaptation" twice and "adaption" never.

b0rsuk|6 years ago

Every now and then a great movie comes out. Then it gets its American remake. It's been proven you can put Al Pacino, Robert de Niro and Bruce Willis in any movie (with predictable results!). This is the book equivalent of an American remake for me.

Is Javascript the new pseudocode? Honestly I'd rather be forced to learn a new language to understand a book than to read the book adapted to JS.

dxbydt|6 years ago

I just wanted to take 2 minutes to thank you personally for that comment. Honestly its amazing to find another person on this planet who has the exact same reaction to this idea ! I was going to type out what you said pretty much word for word, and then I'm reading what you wrote & I'm like, hey, who's this person who has read my mind & how're they doing that ? For a minute it was like, completely mindblowing.

I think most of the comments below are entirely missing the point & thinking of this as JS hatred. Its more about...cultural degradation...Pedestrianization. sicp was holy grail. you looked up to it, you cherished it, it was something few people have partaken of & it was nice that way. then gradually that got diluted over time. berkeley did the python3 gig & that itself was icky but now this is a whole new low. sicp in js ?! jesus. what next ? are we going to sicp in qbasic ? why not a sicp do-over in Visual Basic so all them fogey 90s microsoft-for-life developers! developers! developers! on win95 code up COM DLL interpreters in Notepad++ ? where does the madness end ?

sicp & scheme. buttons & bows. mac & cheese. bread & butter. things that go together.

Now, sicp & js is...is..what is it ? mustard & jam ?

you know what would be real cool ? sicp in J !!! Now that's a marriage made in heaven. if i was a rich vc i would happily fork over a million for a sicp in J effort. the apl family has so much to offer! now that i recall, there was actually an effort called aprol http://www.cs.trinity.edu/~jhowland/aprol.paper.pdf

bryanrasmussen|6 years ago

Well since I very much enjoy the first half of SICP I like that I can look at problems I have some familiarity with in a language I use day to day.

Anyway, how did you like the Pacino remake of Pippi Longstocking?

slimed|6 years ago

There is a simple explanation of course. You are not the intended audience. Ditto for the blockbusters you mentioned.

scottoreily|6 years ago

Typical dramatic Hacker News user. JS is a great language and enjoyed by millions of developers.

pluto9|6 years ago

HN's ability to shoehorn a swipe at the USA into almost any topic is really an impressive thing to behold.

ritchiea|6 years ago

To dang and the other moderators, can you think of a way to auto-penalize effectively contentless/empty anti-Javascript comments?

Imagine this kind of comment for any other language, C, Python, Ruby, Rust, Scheme whatever. It would be downvoted to death. And yet people still make & upvote these comments about JS despite JS being the most popular language, run on the most devices & having a massive community of people fixing its warts and modernizing JS.

There are still valid critiques of JS but they have nothing to do with Al Pacino or Bruce Willis. Please spare us, or if you want to criticize Javascript, learn something about Javascript in 2019 & criticize that.

swiley|6 years ago

I remember finding the SICP in our university’s library as a freshman, me and a friend (both of us had never used scheme) had a lot of fun going through the first chapter together.

dprophecyguy|6 years ago

Holy Shit... This is awesome ... !!!

z3t4|6 years ago

I skimmed through the book and think I saw a function declared inside an if-statement. Some JS engines don't like that. And if the engine does support it, the function will be function scoped. To make an if-scoped function, declare it using const f = x => y,

nitpick: I personally prefer to use intermediate variables instead of nested function calls and ternary operator.

muzzletov|6 years ago

Dont like where they state shit (code, programs, processes etc.) isnt comprise of anything.

Everything is comprised of something.

Please, if you compose something many people could potentionally consume, at least dont be all esoteric and/or mystical about it. This is not a campfire, where everyone tells a story of fairies and shit. They maybe even more so eager to learn a typical umderlying layer/architecture.