test output of clojure functions visually in a browser

Viewed 111

I'm developing a Clojure application, which downloads images from the web and analyzes them for certain criteria.

Whatever this might mean, the important part is, that there will be some quite expensive functions in the app, which take a while until they are processed.

In the end, there will be an API that exposes the app's functionality to a web frontend. This is meant to be a second step though.

Since the app has a lot to do with graphics, it makes sense to visualize the outputs of the functions I'm writing during the development process. Basically I'm looking for an easy way / environment to archive this. More precisely: Whenever I created a new function, I want to test it's functionality inside a browser: E.g. plot the output, draw some intermediate steps, maybe create some small interactive scripts, that help me to supervise that the algorithms are doing what I intend to. Note: I don't want to to transform the functions to ClojureScript and let them run in the browser, the browser should be just a "display".

Some approaches that came to my mind:

  • Writing a little backend-server that exposes all the functions of a namespace. So the front-end could access all these functions simply by sending an ajax request to the server, that includes the function and it's parameters in a string, or maybe better in edn format. The back-end receives the request, calls the requested function and sends back the result whenever the calculation is done. Is there maybe already a project, that does exactly this?

  • Using a project like "Gorilla Repl" This would be a good option, and maybe I'm going to use it. However, I could not yet figure out if it's mechanism covers a way to interactively influence the rendered outputs. It rather works as a worksheet with static renderings.

How would you guys do this? Any suggestions are appreciated.

2 Answers
Related