3 ms·
Javascript is probably semantically closest to Scheme - it's a language built around closures and one universal data type (lists in Scheme, objects/dicts in JS)
by nostrademons 12y ago
Javascript is probably semantically closest to Scheme - it's a language built around closures and one universal data type (lists in Scheme, objects/dicts in JS). Scheme is a pretty good choice for intro CS courses, because of its simplicity and the need to re-implement many common language constructs from first principles.
JS shares this property, but also gains the benefits of being widely used in industry and available in every web browser, with a good debugger in Firefox and Chrome. I'd never really considered it as a teaching language, but I think it'd be a great choice.
- mrbrowning 12y agoImmutability-by-default is a necessary, if not sufficient component of the semantics of Scheme that is lacking in JavaScript, and it's that same lack that leads me to think that any comparison between the two languages is basically spurious.
- nostrademons 12y agoScheme certainly has mutability, through set!, set-car!, set-cdr!, and procedures based upon them. It's not the default - you always know when you're mutating something - but then, there's a pretty direct syntactic translation into Javascript, where = without a var always means you're mutating something. Why is this important for students, anyway? Shouldn't they be exposed to mutability fairly early on?
- mrbrowning 12y agoIt's not important for students, I just dispute the notion that JavaScript has any special affinity with Scheme beyond that of any other language with first-class functions. Anyway, the major advantage of immutability by default is that it enables under-the-hood optimizations like structural sharing that make FP the paradigm of least resistance. To the extent that JavaScript doesn't do that, it doesn't really deserve to be called a functional language any more than e.g. Ruby.
- discreteevent 12y agoClose to Scheme? Not really. http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt-scheme/ http://journal.stuffwithstuff.com/2013/07/18/javascript-isnt...
- nostrademons 12y agoStraight from the horse's mouth: http://brendaneich.com/2008/04/popularity/ http://brendaneich.com/2008/04/popularity/ JS certainly does have other influences, notably Self and Java. But from that article: "As I’ve often said, and as others at Netscape can confirm, I was recruited to Netscape with the promise of “doing Scheme” in the browser....I’m not proud, but I’m happy that I chose Scheme-ish first-class functions and Self-ish (albeit singular) prototypes as the main ingredients. The Java influences, especially y2k Date bugs but also the primitive vs. object distinction (e.g., string vs. String), were unfortunate."