2 ms·
It may be a toy language, but it's a serious idea, one I've often wondered about. I work a lot with both Common Lisp and Javascript and the one killer JS featur
by gruseom 16y ago
It may be a toy language, but it's a serious idea, one I've often wondered about. I work a lot with both Common Lisp and Javascript and the one killer JS feature that I miss in CL is its maps, or rather its use of the map as its organizing principle. This particularly shines for exploratory programming, since it frees you from having to work very hard when adding, removing, or reordering information in your program: it's trivial to stuff a property into a JS map and trivial to get it back. Since nearly everything is a map, nearly everything has this flexibility. CL's plists seem like they ought to serve this purpose, but they don't (compared to JS) because plists are conses and their identity changes when you prepend new properties to them; also, all null plists are the same, which turns out to be surprisingly restrictive (again compared to JS).
On my project we ended up adding a JS-style property operator to CL and using JS-style maps wherever we wanted this flexibility, which was nearly everywhere. It just compiles to CL hashtables under the hood. This is so valuable, it's natural to wonder what a Lisp with the map as its organizing principle would look like.
- aaronblohowiak 16y agoLua is similar in this regard, but offers more flexible semantics than JS. Further, i believe most luas support TCO. http://stackoverflow.com/questions/323346/what-can-lisp-do-that-lua-cant http://stackoverflow.com/questions/323346/what-can-lisp-do-t...
- cgrand-net 16y agoIn Clojure, the default collection for data modeling is the map (and has literal support). Unlike javascript, properties are namespaced so you can extend someone else map without fearing a nameclash. Records (which are objects with a user defined types) are maps too so the upgrade is easy (and yes you can add you own fields to an object).
- gruseom 16y agoSure, but maps are still bolted on. That's convenient, but it's not interesting. The interesting question is, what would a language that is to maps as Lisp is to s-expressions look like? The OP is the first person I know of who's tried to answer that. It's an important question because maps are flexible and flexibility is important for exploratory programming, which is nearly all programming. If there exists a language that is as regular and programmable as Lisp but organized around maps rather than lists, that would be a big deal.