More and more I find myself wanting a programming language where I could mark classes as immutable and functions as pure (no side-effects) and have this checked statically by the compiler. Being able to mark methods as read-only (like C++ const) would also be nice.
This is coming from a variety of sources:
- reading about functional languages like Haskell and Clojure
- working on concurrency in jSuneido (immutable classes and pure functions make concurrency easier)
- problems in my company's applications where side-effects have been added where they shouldn't
I have been using the javax annotation for Immutable, which in theory can be checked by programs like FindBugs and that's a step in the right direction.
There are a lot of new languages around these days, but so far I haven't seen any with these simple features. Of course, in a "true" functional language like Haskell, "everything" is pure and immutable (except for monads), so this doesn't really apply. But I think for the foreseeable future most of us are going to be using a mixture.
2 comments:
Hi Andrew, the D programming language looks quite promising regarding all that.
I haven't looked at D for a while, it has grown a lot.
I had to search a bit, but I found that D can declare "pure" functions and "const" (immutable) structures and classes. Nice.
For some reason I've never gotten excited about D. I'm not sure why.
I see there is a book out on D, I'll have to get it.
Post a Comment