Aye, but minus the low level features of C and the high level features of Lisp. Like pointer and memory manipulation and macros.
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?
A monad is a kind of control structure between functions. Kind of like if you could overload add extra hook functionality to the Unix shell pipe, besides just piping stuff along. For instance, seed it with a countdown, and every time stuff is piped to another process, see how much time has elapsed; if at any point it's been more than, say, 30 seconds, just stop the whole series and return an error. Or find a path through a maze by backtracking every time it hits a dead end, returning to the most recent unexplored path.
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.)
"They're a necessary workaround to do some stuff in pure functional languages"
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.
Agreed. I guess I should have added, "without making things unnecessarily complicated.".
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.
A monad is a means by which people who are pedantically attached to the notion of pure functional programming can write programs that /actually do something/ while still claiming that they're functional.
Monad is the name for an algebraic structure, the same way that 'field' and 'group' and 'monoid' and 'integral domain' and 'vector space' are names for algebraic structures.
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.
Not really news, is it? Brendan Eich himself has said that he wanted to use Scheme as the embedded language in the browser, but the higher ups thought people would be frightened off by all the parentheses. So, he sneakily implemented Scheme with C-style syntax and nobody seemed to notice for a few years.
It seems like many of the strengths of Lisp/Scheme are an emergent property of the S-expression syntax, though. Expressions like ((if test func-one func-two) arg1 arg2 etc) are certainly more awkward with infix notation, for example. Using OO/polymorphism is one way around this, but that's a bit heavy-handed in situations where it's just a workaround for infix syntax. (Duplicated code with a switch or if block is even worse.) Also, macros / code generation are vastly easier with a consistently prefix notation.
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 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.
Don't get me wrong, I'm a big fan of Javascript. I'm just saddened that we didn't get a complete Scheme. Things like, for example, metaprogramming are massively helpful when interacting with HTML. Collectively we all might have had a lot less work to do.
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)).
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?