9 ms·
Structure and Interpretation of Computer Programs – JavaScript Adaptation
- dprophecyguy 7y agoHoly Shit... This is awesome ... !!!
- voldacar 7y agoThere's kind of a reason why SICP was written in Scheme in mind and not a blub language...
- mpfundstein 7y agowhat a stupid comment. why is modern javascript a blub language? and what does it matter anyway? the concepts are the same.
- dspillett 7y agoAny language can be a blub language, assuming we are referring to the same thing here: https://en.wikipedia.org/wiki/Paul_Graham_(programmer)#Blub https://en.wikipedia.org/wiki/Paul_Graham_(programmer)#Blub
- mpfundstein 7y agoAh! I totally misunderstood that. Thx
- jcbrand 7y agoJavaScript is heavily influenced by Scheme, this is actually mentioned in the linked to book.
- iLemming 7y agoEvery single language in the industrial use today is pretty much influenced by Lisp. For that reason alone every self-respected programmer should get familiar with a Lisp - Racket, Clojure, Fennel, CL, etc.
- lifthrasiir 7y agoThat'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 https://sicp.comp.nus.edu.sg/source/source_4.pdf
- mattacular 7y agoWere 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.
- deleted 7y ago[deleted]
- jackewiehose 7y ago> Were you going to let the rest of us mere mortals in on the reason? Scheme (in contrast to Java etc) is special because of its very easy syntax and how it is evaluated. Since SICP is about syntax/structure and its evaluation/interpretation you should really stick to lisp. > 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. I don't. Maybe this Javascript-Version is also a great book, but if you don't know scheme/lisp and wonder why scheme is a better choice for SICP I encourage you to read the original.
- caiocaiocaio 7y agoA long essay could be written about that. A few quick things. There's Scheme's simple syntax, which doesn't get in the way of what the book is actually teaching. The fact that, of the mainstream programming languages, Javascript is the most crufty and full of gotchas, with all kinds of weird, unexpected behaviours even experienced developers can't always keep track of, many caused by bugs in the first version. Javascript's tendency to fail quietly when other languages would shoot out error messages makes it an awful language to experiment and play around in. Javascript Stockholm Syndrome. Decades of tradition. The entire last section of the book's intimate relationship with Scheme. The fact that this is a book about learning to program, not about maximizing your potential for jobs. It's a compsci book to learn to be a good programmer, not a book about synergizing industry trends to build your resume. When SICP was written, most people still wrote in Assembly for most things but COBOL, ADA, and old-school FORTRAN were also popular. Part of the longevity of the book is its appropriate choice of language. Would it be as enlightening to write a series of JS compilers in JS? Or are they writing Lisp compilers in JS? Doesn't that miss the entire point of the book?
- andybak 7y agoSo you won't allow "Lisp in C's clothing"? https://www.crockford.com/javascript/javascript.html https://www.crockford.com/javascript/javascript.html
- dmix 7y agoIf you’ve read SICP and saw how the abstractions were slowly layered on top of each other which scheme is amazing for with its simplicity - no I don’t think a weird prototypal language like JS is sufficiently like scheme enough to communicate the beauty of programming like SICP does. And I write JS for a living.
- bryanrasmussen 7y agorebuttal https://journal.stuffwithstuff.com/2013/07/18/javascript-isnt-scheme/ https://journal.stuffwithstuff.com/2013/07/18/javascript-isn... although I don't necessarily agree that JavaScript is so minimal anymore.
- acqq 7y agoI really enjoyed reading it! A small sample: About JavaScript features: “Don’t tell me it’s got lexical scope, because JavaScript’s scoping is an abomination in the face of God. Guy Steele isn’t even dead and JS scope makes him pre-emptively roll in his not-yet-occupied grave. Likewise, claiming JS is homoiconic because you can eval strings of code is nonsense. If that’s the only criteria for homoiconicity, then C is too, since you can treat an array of bytes as code and jump to it.” Wonderful.
- braythwayt 7y agoIt's a wonderful read, but having used JS since well before it attained its current status as a combination floor wax and dessert topping... The scoping for "JavaScript, The Good Parts" is exactly the same scoping as Scheme. You can write expressive programs without ever using var, let, or const just using binding to named function arguments, which is very close to thinking in lambdas. Of course, that style of JavaScript isn't what most people think of, and without macros, you can't build fuller-featured syntax on top of "The Good Parts." And that's the real problem with treating JS as "a kind of Lisp." It's true that you can program in a certain minimal SICP-like style in JS, but if you have to write a Babel plugin to implement a new feature made out of closures and argument bindings... Then you really aren't programming in "a kind of Lisp" any more.
- braythwayt 7y agoOf 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.
- projektfu 7y agoThe nadir is the low point, the antonym of zenith.
- braythwayt 7y agoThanks!
- throwawaybbb 7y agoSimple question: do you know enough lisp to write a self hosting interpreter in it? People talk up their language until they learn lisp then this happens: https://www.draketo.de/proj/py2guile/ https://www.draketo.de/proj/py2guile/
- jessaustin 7y ago
- mananvaghasiya 7y ago“There are only two kinds of languages: the ones people complain about and the ones nobody uses.” ― Bjarne Stroustrup
- rimliu 7y agoThere is also this: https://en.wikipedia.org/wiki/False_dilemma https://en.wikipedia.org/wiki/False_dilemma - Wikipedia
- throwawaybbb 7y agoThe cpp 2020 is 2000 pages. There comes a point when a language is a valid target of complaints.
- de_watcher 7y agoStill better than n-page v2 and m-page v3.
- goatlover 7y agoAssuming Stroustrup is the authority on programming languages.
- joelfolksy 7y ago"There are only two kinds of politicians: the ones people complain about and the ones who don't get elected." - Republicans
- deleted 7y ago[deleted]
- agbell 7y agoHal Abelson thinks that javascript is Today's Scheme. That is is carrying the flame of the ideas of Scheme forward.
- caiocaiocaio 7y agoWhat's your source for that? Not that I doubt you, I just can't find any record of him saying that.
- mhaberl 7y agohttps://corecursive.com/039-hal-abelson-sicp/ https://corecursive.com/039-hal-abelson-sicp/ - about 21-22 mins in
- goatlover 7y agoSince JS isn't homoiconic, that's pretty hard to believe.
- _pmf_ 7y agoHint: PG's little web shop would have been exactly as successful in PHP.
- ken 7y agoIs that sarcasm? I can't even tell any more. Assuming it's not: Do you mean modern PHP? "The source code of the Viaweb editor was probably about 20-25% macros." So are you suggesting they should have started work by extending PHP with Lisp's macro system? Or just worked an order-of-magnitude faster to make up for not having one? Or do you mean the actual PHP that was available when they started Viaweb? It's hard to imagine how Personal Home Page Tools 1.0 (not even called a 'programming language' at the time) would have been at all a reasonable alternative to ANSI Common Lisp. It was a few C files that could do basic variable substitution and output HTML tags to stdout. It couldn't do loops or if-statements, much less access files or databases.
- jancsika 7y agoHoly 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.
- dang 7y agoPlease don't take HN threads into flamewar.
- voldacar 7y agoI wasn't trying to flamewar, but my post was kind of snarky and I should have expanded upon it. It's just that when I see something like "SICP in teh script" I can't but question the value of that, since much of the elegance and staying power of SICP is inseparable from the fact that it was designed for a homoiconic language with simple syntax and easy metacircularity.
- rakhalmadhu 7y agoAwesome....
- Theizestooke 7y agoIs this the first adaption of SICP to a different language?
- mehrdadn 7y agohttps://wizardforcel.gitbooks.io/sicp-in-python/content/ https://wizardforcel.gitbooks.io/sicp-in-python/content/
- gchamonlive 7y agoThis is really cool, thanks
- juliangamble 7y agohttp://www.sicpdistilled.com/ http://www.sicpdistilled.com/ (Clojure) http://www.afronski.pl/sicp-in-clojure/2015/10/19/sicp-in-clojure-chapter-5.html http://www.afronski.pl/sicp-in-clojure/2015/10/19/sicp-in-cl...
- artemonster 7y agoI puked a little. Then swallowed it. Then puked again. Why you do this to the greatest masterpiece of all time? oh my...
- FoyrNeo 7y agoGreat news
- nhlx2 7y agoAdaption - another term for adaptation.
- jessaustin 7y agoIt's a perfectly cromulent word, but at the link only "adaptation" appears.
- kaycebasques 7y ago> It’s a perfectly cromulent word TIL: https://www.merriam-webster.com/words-at-play/what-does-cromulent-mean https://www.merriam-webster.com/words-at-play/what-does-crom...
- anaphor 7y agoI was sure it wasn't a real word but you're correct, it's an alternative (but less common) spelling.
- ghkbrew 7y ago"less common" is a bit of an understatement[0]. I'd put it in the "common misspelling" category. Though both versions seem to have been around since before English really had consistent spelling. [0] https://books.google.com/ngrams/graph?content=adaption%2Cadaptation&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cadaption%3B%2Cc0%3B.t1%3B%2Cadaptation%3B%2Cc0#t1%3B%2Cadaption%3B%2Cc0%3B.t1%3B%2Cadaptation%3B%2Cc0 https://books.google.com/ngrams/graph?content=adaption%2Cada...
- troymc 7y agoThe page at the other end of the hyperlink uses the word "adaptation" twice and "adaption" never.
- Chico11Kidlet 7y agoI'm simultaneously impressed and disgusted.
- z3t4 7y agoI 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 7y agoDont 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.
- swiley 7y agoI 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.
- b0rsuk 7y agoEvery 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.
- slimed 7y agoThere is a simple explanation of course. You are not the intended audience. Ditto for the blockbusters you mentioned.
- caiocaiocaio 7y agoThe target audience are people who don't want to learn Lisp but want to write a bunch of Lisp interpreters and compilers. Obviously.
- slimed 7y agoThat's a pretty narrow view of the teachings to be gained from SICP.
- ng12 7y agoThere's a reason SICP isn't called Structure and Interpretation of Lisp Programs. Lisp is incidental.
- caiocaiocaio 7y agoImagine a book where you wrote a bunch of Javascript implementations without learning Javascript.
- edflsafoiewq 7y agoThere is a reason SICP uses Lisp.
- brlewis 7y agoWhat 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 7y 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
- ahuth 7y ago> This version feels more like something that has added value if you already know JS, not so much when you're learning JS Totally agreed, which I think is a strength of SICP. I know historically it was for learning computer science, but I've gotten so much out of reading it, despite not being a newcomer to the field.
- kyancey 7y agoWhat fresh hell is this?
- braythwayt 7y agoDorothy Parker, is that you?
- musicale 7y agoAdd this to Little Scheme/The Little JavaScripter. https://www.crockford.com/scheme.html https://www.crockford.com/scheme.html https://www.crockford.com/little.html https://www.crockford.com/little.html
- ngcc_hk 7y agoFinally 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.