Live data from Hacker News

SICP in JavaScript

sourceacademy.org

101–110 of 126 posts

Re: SICP in JavaScript

#101
post #93

Earlier quoted context omitted.

> So then astronomy is about telescopes...? No? I never said that. SICP teaches concepts, those concepts are better understood with lisp. Astronomy teaches concepts, those concepts are better understood with telescopes. In neither case is the subject about the tool, it's just better understood with the tool.

I just really think you should be ready to accept the full force of your words: >Same thing here -- SICP just isn't the same if it's not in scheme or lisp. That straight up reads like SICP and lisp are inseparable and that exactly means that SICP is not as general as people claim. What we have here is unstoppable force meets immovable object (otherwise known as a contradiction). The resolution is simple: either SICP…

Oh come on, would you reckon that SICP would be just as good in Assembly? Just because computation is substrate independent doesn't mean our brains don't care about the form computational concepts are expressed in.

Re: SICP in JavaScript

#102

Earlier quoted context omitted.

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

JavaScript will coerc the types. 1+1 and true+true both = 2

So you've gone from "nested ternary is hard to read" to "This is an introductory text, let's mix arithmetic with numbers and booleans by using true and false for 1 and 0"? That's a remarkable turn in just a few comments toward the side of obfuscation.

Re: SICP in JavaScript

#103
post #82
post #47

Earlier quoted context omitted.

I think SICP would be just peachy in Elixir, but I’m coming around to the notion that keeping functional programming for functional programmers is a form of professional neglect. Functional core, imperative wrapper is one of the few sane ways to build a large (Conway’s Law afflicted) system, and too many of my peers never studies SICP in school. They don’t even know the damage they do, and as we’ve learned in many, m…

Scheme is not a functional programming language. The last 2/3rds of sicp are possible only because you can mutate state.

Actors in Elixir (and AFAIK the Actor Model in general) can mutate their internal state in response to receiving a message. It would probably be awkward to use actors in this way just to facilitate mutation though.

Re: SICP in JavaScript

#104
post #3

I might be wrong, but I feel like writing SCIP on JS is like "Sustainable Energy using Oil." Not quite the right analogy... JS isn't as bad as Oil. But you get the idea... Kinda... don't make sense?

>writing SCIP ... Then you should probably SCIP SCIP.

Did you mean to say "SCIP SICP"? :-D

Re: SICP in JavaScript

#105
post #19

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

The tragedy of JS if blocks being statements not expressions is made explicit here

There was a library adding macros to JS that was a thing long ago. I always thought that `cond` would make JSX way better, though JS + macros sounds terrifying in general.

Code example below, `cond` is an example in their tutorial: https://www.sweetjs.org/doc/tutorial.html#sweet-cond

    let realTypeof = cond {
      case x === null: 'null'
      case Array.isArray(x): 'array'
      case typeof x === 'object': 'object'
      default: typeof x
    }
Discussed in 2017 on HN: https://news.ycombinator.com/item?id=14695495

Re: SICP in JavaScript

#106

Earlier quoted context omitted.

>writing SCIP ... Then you should probably SCIP SCIP.

Did you mean to say "SCIP SICP"? :-D

No. I say what I mean, and I mean what I say, like that quote by (maybe) the Mad Hatter in Alice in Wonderland :)

To be more precise, as Thomson and Thompson (of Tintin comics) would say, I meant it as a double irony on the GP's misspelling or typo.

Re: SICP in JavaScript

#108

Earlier quoted context omitted.

Did you mean to say "SCIP SICP"? :-D

No. I say what I mean, and I mean what I say, like that quote by (maybe) the Mad Hatter in Alice in Wonderland :) To be more precise, as Thomson and Thompson (of Tintin comics) would say, I meant it as a double irony on the GP's misspelling or typo.

Double irony may be the wrong term, but I'm tired, and

SICP(SICP)

;-)

Only the math and Lisp / Scheme cognoscenti will get that one.

Re: SICP in JavaScript

#109

Earlier quoted context omitted.

I just really think you should be ready to accept the full force of your words: >Same thing here -- SICP just isn't the same if it's not in scheme or lisp. That straight up reads like SICP and lisp are inseparable and that exactly means that SICP is not as general as people claim. What we have here is unstoppable force meets immovable object (otherwise known as a contradiction). The resolution is simple: either SICP…

Oh come on, would you reckon that SICP would be just as good in Assembly? Just because computation is substrate independent doesn't mean our brains don't care about the form computational concepts are expressed in.

i have a pretty simple perspective on SICP and lisp: neither are that amazing and both are idiosyncratic examples of a very generic thing (ds&a book and programming language, respectively) and also both attract a cargo cult following.

Re: SICP in JavaScript

#110
post #77

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

Uh oh. That's like the original Numerical Recipes in C. All the arrays had their first value as 1, instead of 0. It was a conversion from FORTRAN, where arrays really did start at 1. The Numerical Recipes authors provided an array allocator which generated an address offset before the beginning of the array to make that work. It was awful. I rewrote the algorithms I needed with sane layout. The whole point of SCIP wa…

Maybe we have a different definition of "mathematical beauty", because I personally didn't find much mathematical beauty from SICP.

I found the most helpful part of SICP is the chapter 4, but to call it mathematical is a bit like to say "everything is foundamentally math"...

Post reply on HN