Fork me on GitHub

I am trying to make a CLJ library also usable for CLJS projects for the first time. Does anybody know about a blog, documentation or best practices? It is Leiningen based, and after some reading I’m under the impression that switching to deps would make the whole procedure easier… :thinking_face:


Not much to say here - in the end, it's just a JAR somewhere. But: • Common code should be in .cljc with platform-specific stuff in reader conditionals • It's simpler and easier to store all macros in .clj files • deps.edn will also allow your library to be used as a Git dep Given that your library also works with CLJ, you probably don't care about NPM dependencies, so that's not an issue.


Forgot to add that information: I have the need to add npm dependencies. My API is a wrapper around a Java library, and the same wrapper should now delegate the call to a very similar npm library. Already moved the code to .cljc files and don’t have any macros


In this case, specify your dependencies in a deps.cljs file at the root of your projects. Alternatively, just document them in the README. There's been a discussion about it in #clojurescript with some links and advice, should be easy to find via the Search panel.

👍 1

Will read into that, thanks!


IMHO leiningen is definitely easier


except for adding a deps.cljs file to declare the npm-deps everything else stays the same


no compilation or anything needs to be done


just .cljc files


Easier - you mean, in terms of packaging a JAR? Or is there something CLJS-specific?


easier as in you just need to run lein deploy clojars


not CLJS specific no since nothing special needs to be done for CLJS

👍 2

How AI looks in Clojure? Do we have good libraries? Or in Java? Like for example tensorflow ? In other words I am thinking if it makes sense to do AI in Clojure vs Python.


Worth checking out #uncomplicate, libpython-clj and the ecosystem.

👍 1

Lots of great stuff here too:

👍 1

thank you for the links. Although I think it moves mi closer to think “doing this in clj is not worth it”


There's definitely people doing AI and ML in Clojure, what are your criteria for "worth it" ?


If your question is "can you", the answer is yes you can. If the question is: "Are there more libraries, frameworks, books and tutorials than for Python", the answer is no, Python has the richest ML ecosystem of all languages. That said, you can use Python libraries from Clojure using libpython-clj, bit you won't find the level of tooling and tutorials/books that you'd have in pure Python.


This website has kinks to all the tooling/libs that exist: for various categories for ML/AI in Clojure


> There’s definitely people doing AI and ML in Clojure, what are your criteria for “worth it” ? simplicity. If I can do this in Clojure it doesn’t mean it is good idea. Amount of energy and complexity doing this in Clojure vs Python even when I don’t know Python.


If the solution is to use Clojure libpython-clj to use Python, then it sounds using Python directly is simpler.


even considering I have to learn Python first


unless I don’t have to use Python to do AI and still will be on the same level of simplicity as if I would use Python


I have 0 experience with AI


Hum... this is hard to answer. If you have zero experience, Python will have a million times more tutorial, books and videos, etc. So its probably best to use Python. But, there's this which is a big investment, but you learn a lot: and That said, you might be best starting with Python to learn, because of how much material it has. Then revisit Clojure afterwards.

👍 1

Thank you for your input


To summarise this do I correctly understand in your opinion doing Python in Clojure make sense? Why? Or do you mean not use Python at all in Clojure for AI make sense?


let me ask in that way: what is the use case / benefits to use Clojure over Python for AI?


I think the “use case” is the point here. Why would choose Clojure over Python for AI?


My summary is, you'll find it easier to learn AI using Python even if you don't know Python but know Clojure. But if you know and like Clojure, doing AI in it is more fun and brings more joy, using the REPL is still really nice, even though notebooks aren't too far from it, and all the Lisp, FP, and everything else you might still miss from Clojure. The only reason to choose Clojure over Python would be because you prefer using Clojure over Python. You could make a case that productionizing some models is easier in Clojure, especially if your services are already in JVM world or Clojure and not in Python. Like taking a trained model / feature computation from Python and putting it in production can be trickier if your prod services are not Python, sometimes you have to rewrite the same thing in your own language, though nowadays you can often put that in a separate microservice running Python in a container.


Clojure is kind of great for data manipulation and processing, which is a big part of AI, but it lacks the amount of tooling/libs specific to AI that Python has and all the documentation about them. That's kind of a pro/cons, like Clojure is a good choice to build AI libs/tooling on, but it doesn't yet have a solid universal toolkit for it that's widely used.


Other, not mentioned, option is and/or clojure wrapper for it:


Can you link me the simple example of using AI Python (for example PyTorch or TensorFlow) in Clojure?