Holy crap take a look at some of the JS examples in Chapter 4 - functions declaring functions declaring functions returning functions
I hate this style of coding. I don't see how it's any better than turning everything into data and code in encapsulated class objects and passing them around
SICP: JavaScript Edition available for pre-order
41–50 of 123 posts
Re: SICP: JavaScript Edition available for pre-order
#42One major benefit here is how approachable this is. One could even simply open Dev Tools on their browser and use the console as a REPL. As someone who installed Scheme/Dr Scheme/Dr Racket long ago, it's nice to say, "you can get started right now". I know there'll be a lot of complaint about JS as a language choice but, it's pretty ubiquitous. And, much like Scheme, no one's saying, "you should use this for your nex…
This is the wrong kind of approachable, because you have to learn a ton of random web things before you do anything outside the repl and before your program can even process user input and then people struggle with those two concepts that would be trivial to them if they could be introduced earlier. Having seen what having javascript as a first language does to first year students I can't understand why this is consi…
Nothing prohibits them from learning, "better" languages after you reach them, but first you have to reach them.
Re: SICP: JavaScript Edition available for pre-order
#43I saw this the other day on Amazon while picking up the SICP instructor's edition. For the life of me, I can't figure out why they chose JavaScript to do this. And the new authors are professors . Since the original SICP has a permissive license, I've actually thought about doing something similar, but with a more modern functional language.
Yeah, imagine the craziness of making materials like this accessible to users of the most widely used language.
Re: SICP: JavaScript Edition available for pre-order
#44Note to the unaware, both* this version and the classic (Scheme) version are Creative Commons-licensed and freely available online. (*edit: thanks to keithwinstein for enlightening me -- I wrongly thought it was just the one. The publisher's site doesn't advertise this at all!) https://sicp.sourceacademy.org/ (JS version) https://mitpress.mit.edu/sites/default/files/sicp/index.html (1984 classic)
I believe they are both CC-licensed. See https://sicp.sourceacademy.org/ A ton of work seems to have gone into this -- they have a meta-circular evaluator in JavaScript (and it's not that much longer than the original Scheme)!
list("sequence",
list(list("constant_declaration",
list("name", "size"), list("literal", 2)),
list("binary_operator_combination", "*",
list("literal", 5), list("name", "size"))))
https://sourceacademy.org/sicpjs/4.1.2 ("4.1.2 Metalinguistic Abstraction / Representing Components")This isn't an ideal language for doing this stuff. The Scheme version is completely transparent about what you're doing; whereas this kind of language makes you work through a thick veil of abstractions.
(This line doesn't occur in the Scheme version, but the analog would be (quote (let ((size 2)) (* size 5))). Which would you rather debug?)
Re: SICP: JavaScript Edition available for pre-order
#45I saw this the other day on Amazon while picking up the SICP instructor's edition. For the life of me, I can't figure out why they chose JavaScript to do this. And the new authors are professors . Since the original SICP has a permissive license, I've actually thought about doing something similar, but with a more modern functional language.
Yeah, imagine the craziness of making materials like this accessible to users of the most widely used language.
What is "accessible" in this context is purely a state and attitude of the intellect.
Re: SICP: JavaScript Edition available for pre-order
#46Re: SICP: JavaScript Edition available for pre-order
#47Re: SICP: JavaScript Edition available for pre-order
#48Re: SICP: JavaScript Edition available for pre-order
#49Re: SICP: JavaScript Edition available for pre-order
#50I have a copy of SICP right next to me, and it's one of my favorite computer science books. I'm not sure how I feel about this javascript edition though...
A
false != x
test failed for a zero-valued x; had to make it !==. WTF? I never want false and 0 to be other than different objects.Almost every twist and turn in this language is an imbecillic clusterfuck.
I had one instance of a if (foo.bar = 0) typo; no warning from the implementation. Why do we want stupid C mistakes in a higher level language, without the C fixes for them?
list.forEach(function (item, i) {
...
});
makes my eyes bleed. JavasSript borrows the syntax of languages geared toward a form of computing at which JavaScript is poorly suited for; when you're combining functions together, it looks like dog's breakfast.To get a value out of a switch statement, you have to wrap it in a function that is immediately called?
function () {
switch (WTF) {
}
}();
the switch statement has the idiotic break with fallthrough found in C.One redeeming feature: A || B || C ... works a lot like (or A B C ...).
Unfortunately, this is required for the simple task of incrementing a nonexistent dictionary key from zero:
dict[key] = (dict[key] || 0) + 1;
this calls for two dictionary key lookups. You want this sort of thing in a single operation.Oops! In the following, j isn't lexical:
for (let i = 0, j = 0; ....
I copy and pasted something like this from a StackOveflow answer into a recursive function and spotted that the j in a recursed frame was messing with the j in outer frames, there just being one j.What is "function scope" and why even have something so idiotic? Just let, or GTFO! C has function scope for goto labels, that's it; why introduce something like that.
Appending together Lists has functional semantics, like Lisp:
a.concatenate(b) // new thing is returned, a stays the same, so you must do a = a.concatenate(b).
But a.push(b) // mutates a in place.
Here is a shitshow, curently with a fitting number of upvotes: 666.https://stackoverflow.com/questions/881085/count-the-number-...
I accidentally wrote
if (foo.bar.indexOf[key]
code was silently skipped even though foo.bar is an empty list. No diagnostic, nothing. Oh, indexOf is a function, which is an object. Every damned object is a dictionary with properties you can access as strings with square bracket indexing, and that is always safe: it yields undefined if the property is not found.