Live data from Hacker News

SICP in JavaScript

sourceacademy.org

61–70 of 126 posts

Re: SICP in JavaScript

#62

Earlier quoted context omitted.

I frankly find it hard to imagine an expression form of if...else that's more readable than either the JS or Scheme versions of the code. In fact, I believe the problem with the JS example's readability is the formatting. Here's how I'd format the same code, and I find this quite readable: function deriv(exp, variable) { return is_number(exp) ? 0 : is_variable(exp) ? is_same_variable(exp, variable) ? 1 : 0 : is_sum(e…

The 0 and 1 are completely unnecessary though in some of these. Example is_same_variable(exp, variable) ? 1 : 0 If is_same_variable returns a truthy value then return 1 else 0. We can remove that and it will still follow the same while also being more readable

It’s calculating the derivative. 0 and 1 aren’t used for their truthiness, but as values. d/dx x becomes 1 and d/dx y becomes 0 (the two cases, same variable and different variable).

Re: SICP in JavaScript

#63
post #4
post #2

On my phone I just get a drawing of an alien spaceship? I tried loading it through an archive (and I do get the front page of a web book) but none of the links work there.

it's supposed to redirect to https://sourceacademy.org/sicpjs/index

That's the page I'm on: https://files.catbox.moe/kyql13.png

Re: SICP in JavaScript

#64

Earlier quoted context omitted.

I see this opinion voiced all the time, and I can never understand how people can struggle with something like nested ternaries. Surely a straightforward use (i.e. not a weird edge case) of very basic syntax shared by most widely used programming languages shouldn't cause much of an issue? It should also be easier to reason about nested ternaries than an equivalent set of nested if-elses, because at least with ternar…

Should ternaries be left or right associative?

Right associative! It's just one of the many rites of passage for people working with PHP to get bitten by its left associative ternaries. Naked nested ternaries are deprecated now, but maybe one day, PHP can have right associative ternaries.

Re: SICP in JavaScript

#65
post #14

What I loved most about my class based on SICP was that I learned a whole new way to reason about code, and that came from using Scheme. They changed the intro class at Berkeley to use Python a while back, when the folks who knew lisp/scheme retired, and I think it made the class much worse. This is really the death knell of SICP isn't it?

You know how people love to repeat that old saw about how computer science is no more about computers than astronomy is about telescopes (or whatever it is)? Well ironically (because it's the same exact people but this time on the other side of the misunderstanding) SICP is no more about scheme/lisp than computer science is about computers.

Re: SICP in JavaScript

#66
Why does everything have to be Javascriptified? Scheme is a big part of the SICP experience and trying to do it in another language you are losing a lot. Do people learn Javascript when starting their web development career then refuse to learn anything else? Getting stuck with JS in the browser is an artifact of history and given how bad the language is we should avoid spreading it yet the opposite is happening. Funny for an industry that's allegedly about doing things as smart as possible the lowest common denominator dominates.

Re: SICP in JavaScript

#68

I started this book with coworkers and it fell really flat. I haven't read the original, but knowing Scheme I could see why the book would be structured the way it is. In JavaScript, though, it really just doesn't work. The code is horribly non-idiomatic for JS, and because JS isn't actually Scheme the order of the concepts introduced doesn't make sense. When it does talk about JavaScript, it's condescending towards…

Thanks for the heads-up - I'm not going to bother with this piece then.

Anyone with strong opinions about mainstream programming languages is automatically suspicious to me.

I mean, I get it - plenty more elegant and better thought-out languages than JavaScript, with their practitioners pounding the floor, saying "it should have been me - not him!".

But, ultimately, who can't write good code just because they're not using their favourite language?

Re: SICP in JavaScript

#69

Earlier quoted context omitted.

I think the Scheme version of SICP will live on outside of academia and CS undergrad studies. I'm using SICP for self-learning and I had the choice of Scheme, JS, or Python. I still chose Scheme. This is because I figured Scheme would offer something those other languages didn't since Scheme is the original language of the book and Scheme is just "different" than other languages. It forces you to think differently ab…

What's deterring me from pulling the trigger on the Scheme version is the price. CAD$87 seems a bit steep for a paperback edition that's almost 30 years old. The JavaScript version is CAD$20 cheaper.

Seeing a lot of $25-45 (USD) used price.

Used books are awesome. I have north of 500 books and I doubt more than 50 were purchased new. Only that many because some of my relatives want Christmas and birthday wishlists every year, but won't shop anywhere but Amazon and think it's weird to buy someone a used book as a gift (I'd rather have 2-3x as many books for the same money, but hey, I'm not the one paying, so whatever, I guess).

Post reply on HN