Live data from Hacker News

SICP translated to JavaScript

comp.nus.edu.sg

61–70 of 116 posts

Re: SICP translated to JavaScript

#61
post #48
post #29

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...

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

http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt...

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

Re: SICP translated to JavaScript

#62
post #41
post #35

Earlier quoted context omitted.

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 Average programmers aren't working on shell scripts, client side code, and server side code at the same time.

And everyone is better than the average. :)

Honestly, HN too has hordes of people who can't write FizzBuzz. No reason to feel elitist for anybody really.

Re: SICP translated to JavaScript

#63
post #43
post #28

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?

Maybe not everything, but to explain the concepts behind SICP, why not.

As others have pointed out, chapters 4 and 5 are as wonderful and rich as they are because Scheme is homoiconic which makes writing Scheme interpreters and compilers in Scheme very easy -- no need for hairy lexing and parsing steps. Since (IMHO) these chapters are the best introduction to the study of programming languages and their implementation, it would be a real shame to discard them simply because JavaScript is more widely known and used than Scheme.

It's true that the ideas in the book transcend programming languages, and that the first 3 chapters could probably could be covered in JavaScript with little modification, if a little clumsily. But rewriting the 4th and 5th to include sections on parsing JavaScript would be quite challenging, and furthermore JavaScript does not have as simple semantics as Scheme, so there would be a loss of a great deal of elegance and beauty. The metacircular Scheme interpreter can run itself, which would be harder to do in JavaScript since its core is more rich and Scheme's core: objects, methods and so on complicate it quite a bit.

Re: SICP translated to JavaScript

#64
post #11
post #8

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.

http://sweetjs.org/

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.

Re: SICP translated to JavaScript

#65
post #62
post #41

Earlier quoted context omitted.

@seiji Average programmers aren't working on shell scripts, client side code, and server side code at the same time.

And everyone is better than the average. :) Honestly, HN too has hordes of people who can't write FizzBuzz. No reason to feel elitist for anybody really.

FizzBuzz seems to be an American thing.

I have been coding since 1986 and only learned about it via the usual HN hiring discussions.

Re: SICP translated to JavaScript

#66
post #7

Earlier quoted context omitted.

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

SICP uses Scheme, not Common Lisp. Scheme is a deliberately minimalist language, which is fairly accessible and easy to write your own implementation of. In fact, in SICP, you do that, a couple of times, writing first a Scheme interpreter, then extending it in various ways like adding logic programming capabilities, then you write a virtual machine and a compiler that compiles down to that virtual machine. JavaScript…

> Scheme is a deliberately minimalist language

Ever looked at R6RS?

Re: SICP translated to JavaScript

#67
post #58

Earlier quoted context omitted.

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

SICP isn't a book about Scheme. It's a book about writing computer programs. Scheme was used because it imposes the minimum additional cognitive load. Worrying about all the warts in, e.g. Common Lisp (to say nothing about Javascript or Scala, say) would detract from the pedagogical mission of the book.

SICP did not use Scheme. SICP used a tiny subset of an early Scheme.

You can use a subset of Common Lisp and the programs in SICP would mostly look the same when written in that CL subset.

I have a surprise for you: Scheme has warts, too.

Re: SICP translated to JavaScript

#68
post #38
post #16

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 butto…

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.

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

Re: SICP translated to JavaScript

#69
post #43

Earlier quoted context omitted.

Maybe not everything, but to explain the concepts behind SICP, why not.

As others have pointed out, chapters 4 and 5 are as wonderful and rich as they are because Scheme is homoiconic which makes writing Scheme interpreters and compilers in Scheme very easy -- no need for hairy lexing and parsing steps. Since (IMHO) these chapters are the best introduction to the study of programming languages and their implementation, it would be a real shame to discard them simply because JavaScript is…

Not to mention that if you are already learning the concepts taught in SICP, then learning Scheme is trivial.

Re: SICP translated to JavaScript

#70
post #40

Earlier quoted context omitted.

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!

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 y…

Yeah, I'm with you on this. Aesthetically, I'm in the "ugh, Javascript" camp. But practically, I recognize that I should just get over this. For web stuff, I fully expect that I'll be writing everything in JS in a few years.
Post reply on HN