https://sourceacademy.org/sicpjs/index is the URL you get redirected to in other browsers. (It still doesn't work in safari.)
SICP in JavaScript
11–20 of 126 posts
Re: SICP in JavaScript
#12It seems like they have attempted to write scheme using JavaScript syntax to avoid having to make any significant changes to the non-code sections of the book. Here is an excerpt, it's not good: function deriv(exp, variable) { return is_number(exp) ? 0 : is_variable(exp) ? is_same_variable(exp, variable) ? 1 : 0 : is_sum(exp) ? make_sum(deriv(addend(exp), variable), deriv(augend(exp), variable)) : is_product(exp) ? m…
maybe it's only me, but it's really hard to reason about this.
Re: SICP in JavaScript
#13I 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 it in ways that were off-putting to my coworkers (we're a TS shop), which is weird given that it's a book in JS.
Someday I'm going to get around to reading the original, but I can't recommend this one.
Re: SICP in JavaScript
#14This is really the death knell of SICP isn't it?
Re: SICP in JavaScript
#15Re: SICP in JavaScript
#16It seems like they have attempted to write scheme using JavaScript syntax to avoid having to make any significant changes to the non-code sections of the book. Here is an excerpt, it's not good: function deriv(exp, variable) { return is_number(exp) ? 0 : is_variable(exp) ? is_same_variable(exp, variable) ? 1 : 0 : is_sum(exp) ? make_sum(deriv(addend(exp), variable), deriv(augend(exp), variable)) : is_product(exp) ? m…
One thing I have learnt very well from rewriting a legacy PHP code written by amateur teams is: never ever nest ternary operations. maybe it's only me, but it's really hard to reason about this.
Oh, but fully agreed, nested ternaries is right out. In fact, usually in those other cases too, it's just annoying that there's not a good alternative.
Re: SICP in JavaScript
#17It seems like they have attempted to write scheme using JavaScript syntax to avoid having to make any significant changes to the non-code sections of the book. Here is an excerpt, it's not good: function deriv(exp, variable) { return is_number(exp) ? 0 : is_variable(exp) ? is_same_variable(exp, variable) ? 1 : 0 : is_sum(exp) ? make_sum(deriv(addend(exp), variable), deriv(augend(exp), variable)) : is_product(exp) ? m…
Re: SICP in JavaScript
#18It seems like they have attempted to write scheme using JavaScript syntax to avoid having to make any significant changes to the non-code sections of the book. Here is an excerpt, it's not good: function deriv(exp, variable) { return is_number(exp) ? 0 : is_variable(exp) ? is_same_variable(exp, variable) ? 1 : 0 : is_sum(exp) ? make_sum(deriv(addend(exp), variable), deriv(augend(exp), variable)) : is_product(exp) ? m…
Re: SICP in JavaScript
#19It seems like they have attempted to write scheme using JavaScript syntax to avoid having to make any significant changes to the non-code sections of the book. Here is an excerpt, it's not good: function deriv(exp, variable) { return is_number(exp) ? 0 : is_variable(exp) ? is_same_variable(exp, variable) ? 1 : 0 : is_sum(exp) ? make_sum(deriv(addend(exp), variable), deriv(augend(exp), variable)) : is_product(exp) ? m…
Re: SICP in JavaScript
#20Earlier quoted context omitted.
One thing I have learnt very well from rewriting a legacy PHP code written by amateur teams is: never ever nest ternary operations. maybe it's only me, but it's really hard to reason about this.
Unfortunately there is no if-expression in JS so sometimes it's awkward _not_ to use ternaries in multi-line statements - for instance, when writing in an expression only context like a string interpolation or JSX. It's also just annoying to not be able to assign conditionally without using it, instead of a more clear and readable if/else. It's one of the more annoying nits of the Algol legacy. Oh, but fully agreed,…