JavaScript = C + Lisp
cubiclemuses.com
cubiclemuses.com
Still, it can be a very nice language, I just wouldn't say it is "C + Lisp". Also I'm not sure what the article had to do with either Lisp or C, it seemed more like a discussion of haskell... Am I missing something?
Edit: I'm still confused. Anyone want to take a better shot at explaining what a monad is? Or, more precisely, what's so special about it that it deserves a special name?
They're a necessary workaround to do some stuff in pure functional languages (which is why Haskell users make such a big deal out of them), but you can do some really cool tricks with them.
(NB: This is a really vague summary. I found this OCaml-based monad intro helpful, because it mostly avoids entangling the monad concepts with unrelated issues in Haskell. http://enfranchisedmind.com/blog/2007/08/06/a-monad-tutorial... There's a good Monads-in-Scheme intro, too, I forget where.)
This isn't actually true. You can still write imperative programs in a pure FP language. The most obvious way is to write your code in continuation passing style and pass the new state of the world to each continuation; taking the implicit state changes of an imperative language and making them explicit.
The real reason for using monads is that the scheme I just described is inhumanly complicated. Monads are a much more structured way of doing the same thing. Instead of writing these state passing CPS functions, you write functions that build them for you. A consequence of this is that monads perform much the same function as macros in Lisp; they are programs that build programs.
I think that monads, too, are generally presented in a way that makes them more complicated than they really are. (Hence, I suppose, SPJ's comment about how they should have been called "warm fuzzy things".) Part of my trouble understanding them confronting the basics of Haskell at the same time, and I (along with much of what I read) focused on the IO monad. That's probably one of the most complicated ones. The ideas started to click when I switched to the Maybe monad -- not only is that one considerably more straightforward, but I (and probably many others) had already written essentially the same construct elsewhere, albeit without the formal notation.
In particular it's useful for actions. It has only two functions, 'return' and '>>=':
(return x) -- an action that returns the value x
(a >>= f) -- the action produced by attaching the
-- continuation f to the action a
It is the algebraic structure of attaching continuations to things.I think he did alright for a relatively junior level developer, a lone developer to boot, given the task of "add scripting to the browser". I can imagine far worse fates, particularly given how enamored of Java the entire industry was at the time. I have nothing but respect for Eich and JavaScript. It's held up strikingly well for what could have been, and odds were in favor of it being, a band aid solution. Given the circumstances, I think we're just lucky that Netscape had some of the best developers in the world working on it at that time...because the one who got stuck adding "scripting" happened to be quite gifted and ambitious, and took the task very seriously and came up with something quite clever.
It was a very different time, and dynamic languages were a bit downtrodden. Tcl was the closest to a "standard embedded scripting language" and I think I'm comfortable calling JavaScript a more powerful language than Tcl (at least at the time, though I think the two have stayed the same related to one another over that time, despite advances in both). And, of course, Tcl was only popular among UNIX nerds. Getting Windows developers on board might have been a problem...a whole new "simple" language like JavaScript may have been exactly what the industry needed. I dunno. It's certainly apparent that JavaScript has revealed itself to be a very powerful language in the past few years.
Similarly, many of the advantages of stack-based languages like Forth and Factor emerge from postfix notation. Very interesting to compare the two.
It's really too bad that non-C-style syntax freaks people out so much, from a technical standpoint it's almost certainly the worst of the three. </fighting words>
I agree, and I think your use of the word "emergent" is exactly right: the properties in question were unanticipated, yet orderly and beautiful.
This point explains why abortive attempts to "fix" the s-expression syntax are about as old as the syntax itself.
"JavaScript is my favorite language with curly braces" (we were lispers)
acceptOnlyIf name doesn't tell what the function does. acceptEach or acceptAll could be a clearer alternatives (at least for a python programmer (there are any() and all() general functions in Python)).