Protocols + Prismatic schema + Records


#1

I enjoyed Priyatam Mudivarti’s presentation at Clojure Remote:

I haven’t gotten to the lessons on Protocols yet, but do they cover the combination he recommended of protocols + records + schemas?

On a related note, I’d like some guidance on when using all this is a good idea … and when not.

From Stuart Sierra’s review of Clojure Applied:

Embracing the possibilities of design in a dynamically-typed language requires a willingness to work with values whose types may be unknown at certain points. For example, the type of the “accumulator” value in a transducer is hard to define, because for most transducers its type is irrelevant. The ability to ignore types when they are not needed is what makes dynamic languages so expressive.

On the other hand, I have seen many large Clojure programs drift into incomprehensibility by failing to constrain their types in any way, passing complex nested structures everywhere. In this case, the lack of validation leads to a kind of inside-out spaghetti code in which it’s impossible to deduce the type of something by reading the code which uses it. Given the choice between these two extremes, “over-typed” code will be easier to untangle than “under-typed,” so perhaps introducing validation early is a good idea.

Please vote. Comments are encouraged!

  • :thumbsup: Yes, please teach this!
  • :thumbsdown: No, I’m not interested.

0 voters


#2

This is an amorphous and hard to discuss topic but an important one, I’d say!

One thing I find tough about Clojure is the combination of:

  1. lack of types of parameters and return values
  2. Incredibly terse, unformatted documentation of standard library functions.

The second is really adding insult to injury. Okay, the language doesn’t tell me the required/allowed types! I get it. But in that case I really hope the docstring will make it brain-dead simple to understand what they are. But then too often the docstring give the impression of being written by someone who thought that man pages were overly focused and conversational.

It seems like a clear bug in the documentation that searching google for a trivial example is usually a shorter round-trip than reading the embedded docs in the repl for standard functions.

Exacerbating this is that there is no standard markup format for doc strings, so you cannot quickly parse them to pick out comments on the arguments, return value, throwing behavior, etc…