Performance enhancements
The following architectural decisions might evolve into performance bottlenecks in the future and require further investigation. A nice read about ClojureScript performance from juxt
Multimethods vs Protocols vs Maps
We are currently using multimethods in order to dispatch the correct function depending on the selected tool or element. Protocols' dispatching should be much faster and they are also open to dynamic extension, just like multimethods. Clojure docs on runtime polymorphism Old but related discussion
Immutable vs Mutable matrix operations
We are using mikera/core.matrix for our matrix operations. We need to investigate the performance cost of the immutable data structures and also the cljs implementation of the library in general. Related ClojureScript issue Related talk of Mike Anderson
Transducers
We should consider using transducers for chained transformations. https://clojure.org/reference/transducers https://clojure.org/guides/faq#transducers_vs_seqs
String literals vs Collections for attribute values
Element attributes are currently saved as strings on our db. Any input value is considered valid and is going to be used as an attribute of the element on the SVG canvas. The problem is that to manipulate those strings, extra transformations are required.
For instance, if we have a long d attribute on a path element, converting the string to a vector of instructions every time we need to transform it is expensive. We might have to reevaluate this decision or find a way to cache the collections.
Eliminate callback functions from render
See https://day8.github.io/re-frame/Performance-Problems/#4-callback-functions
Optimize Speed vs Default text-rendering and shape-rendering
Setting those properties to optimizeSpeed would probably reduce the quality a lot, but it is worth investigating this for specific cases.