Cloje types vs host types, revisited

While preparing the Cloje 0.2 release last week, I came across something I had written, part of the goals for Cloje:

Importing all of Cloje will allow you to write code in a language very similar to Clojure. Or if you prefer, you will be able to pick and choose which pieces of Cloje to import, so that you are still mostly writing code in Scheme/Lisp, but with some added features from Clojure.

I had written that over a month ago, long before I had explored host interop issues. Reading it again during the release preparations made me wonder if I had neglected this use case when considering the host interop API design.

My consideration of host interop was from the angle of someone who was writing in Cloje, and wanted to interact with certain host language features or libraries. I hadn’t really considered someone who was writing in the host language, and wanted to integrate certain Cloje features or libraries. It made me wonder whether it was accurate to say that users would be able to “mostly write code in Scheme/Lisp”, considering that much of Cloje will probably depend on a bunch of new types.

This got me thinking on a more fundamental level about Cloje’s stance regarding host types. Should it be possible (and acceptable/idiomatic) for Cloje users to decide to write Cloje programs that primarily (or exclusively) use host types? Or are Cloje users expected to primarily use Cloje types, and only use host types for host interop?

Note: When I talk about “Cloje types” and “host types” in this post, I am mostly thinking of lists, vectors, hash maps/tables, and strings. Those are the types where Cloje and the host language would have “colliding” types (analogous types with different implementations), and thus the source of possible trouble. Certain other types (such as symbols, numbers, and functions) are the same type in Cloje as on the host, so no conversion (implicit or explicit) would be needed.

To help me organize my thoughts and guide my decision, I have sketched out a few scenarios for different stances Cloje might take regarding host types, and explored some of the implications of each scenario. Continue reading Cloje types vs host types, revisited

Cloje 0.2.0 Released

Cloje icon Yesterday I tagged version 0.2 of Cloje. If you want to play around with it, you can clone the repository. Installation and usage instructions are available in the README.

In terms of features, the biggest changes in Cloje 0.2.0 are the addition of hash sets (an unordered collection of distinct elements), and several set operations based on the clojure.set standard library. Please read the release notes for the full list of changes in Cloje 0.2.0.

Also noteworthy is that the goal of Cloje has changed since 0.1. For reasons described in the Cloje 0.1 Post-Mortem, Cloje will no longer attempt to faithfully emulate Clojure. Instead, the new goal is to bring the best aspects of Clojure to Scheme/Lisp. The first effects of this new direction can be seen in the new set operations, whose behavior is more predictable and consistent than clojure.set when given non-set collections. The old goal would have required me to laboriously recreate Clojure’s quirks and bugs, rather than address and fix them.

Tentative plans for 0.3 are to create placeholder types (vectors, maps, etc.) and an API to convert between Cloje types and host types. This will set the stage for adding Clojure-style immutable persistent data structures in the future. The placeholder types will be immutable, but not (yet) have the structural sharing of Clojure’s types.

Besides writing code, I will also be dedicating a significant portion of my project time to establishing policies, project documentation (how to start contributing, etc.), and outreach to help get more people involved in the project, especially people from underrepresented groups.

Designing Cloje’s host interop API

Lately I have been working on designing Cloje’s host interop API. I had the outlines of a design for the API already, but as I started filling in the details and thinking about different use cases, I realized that my simple design would have had some serious problems in actual use. The host interop API was scheduled for Cloje 0.2, but I have decided to push it back to 0.3 to give me time to get it right.

I wrote this post mostly for my own benefit, to help me focus and organize my thoughts. But, it might be interesting to anyone interested in API design. Continue reading Designing Cloje’s host interop API