C# Dev - I've tried Lisps, but I don't get it.
- by Jonathan Mitchem
After a few months of learning about and playing with lisps, both CL and a bit of Clojure, I'm still not seeing a compelling reason to write anything in it instead of C#.
I would really like some compelling reasons, or for someone to point out that I'm missing something really big.
The strengths of a Lisp (per my research):
Compact, expressive notation - More so than C#, yes... but I seem to be able to express those ideas in C# too.
Implicit support for functional programming - C# with LINQ extension methods:
mapcar = .Select( lambda )
mapcan = .Select( lambda ).Aggregate( (a,b) = a.Union(b) )
car/first = .First()
cdr/rest = .Skip(1) .... etc.
Lambda and higher-order function support - C# has this, and the syntax is arguably simpler:
"(lambda (x) ( body ))" versus "x = ( body )"
"#(" with "%", "%1", "%2" is nice in Clojure
Method dispatch separated from the objects - C# has this through extension methods
Multimethod dispatch - C# does not have this natively, but I could implement it as a function call in a few hours
Code is Data (and Macros) - Maybe I haven't "gotten" macros, but I haven't seen a single example where the idea of a macro couldn't be implemented as a function; it doesn't change the "language", but I'm not sure that's a strength
DSLs - Can only do it through function composition... but it works
Untyped "exploratory" programming - for structs/classes, C#'s autoproperties and "object" work quite well, and you can easily escalate into stronger typing as you go along
Runs on non-Windows hardware - Yeah, so? Outside of college, I've only known one person who doesn't run Windows at home, or at least a VM of Windows on *nix/Mac. (Then again, maybe this is more important than I thought and I've just been brainwashed...)
The REPL for bottom-up design - Ok, I admit this is really really nice, and I miss it in C#.
Things I'm missing in a Lisp (due to a mix of C#, .NET, Visual Studio, Resharper):
Namespaces. Even with static methods, I like to tie them to a "class" to categorize their context (Clojure seems to have this, CL doesn't seem to.)
Great compile and design-time support
the type system allows me to determine "correctness" of the datastructures I pass around
anything misspelled is underlined realtime; I don't have to wait until runtime to know
code improvements (such as using an FP approach instead of an imperative one) are autosuggested
GUI development tools: WinForms and WPF (I know Clojure has access to the Java GUI libraries, but they're entirely foreign to me.)
GUI Debugging tools: breakpoints, step-in, step-over, value inspectors (text, xml, custom), watches, debug-by-thread, conditional breakpoints, call-stack window with the ability to jump to the code at any level in the stack
(To be fair, my stint with Emacs+Slime seemed to provide some of this, but I'm partial to the VS GUI-driven approach)
I really like the hype surrounding Lisps and I gave it a chance.
But is there anything I can do in a Lisp that I can't do as well in C#? It might be a bit more verbose in C#, but I also have autocomplete.
What am I missing? Why should I use Clojure/CL?