Hi. A couple of questions. I've been mostly through the ClojureScript Quick Start Guide and feel like I have a decent understanding of it. I've separately learned some Clojure syntax by going through some coding exercises (in-browser, I think, a long while ago) but not much specific to ClojureScript that I know of. I also have little background in JS. I did, though, years ago create a simple webpage with some text field string manipulation functions programmed in ClojureScript, with whatever minimal webpage manipulation was needed for that. I would like to be able to write programs that can be run in browser, on desktop, or on mobile, and am wondering what would be best to do next. 1. Would CLJS-specific syntax etc. and manipulating a webpage be the best thing to learn next? Does that translate to desktop and/or mobile apps? (Mobile apps yes, I think, but desktop?) If so, what good resources are there out there for a person who hasn't used JS much to learn CLJS? 2. Would it be better to try programming with .cljc files? I really like the idea of doing as much as possible in .cljc files, and I also came across play.cljc which has the same goal applied to games.
Depends on what you mean with web/mobile/desktop apps. If you are using a web wrapper for the mobile/desktop apps, then cljs stays cljs. And most things you learn will carry over verbatim. If you are planning to do "native" apps, UI manipulations depend on the underlying technology (eg. flutter with dart would look different than reagent in cljs). There's no real difference at this point for you to worry about cljc files, except that a cljc file can be loaded on more than one dialect (eg both on jvm clojure and in ClojureScript). But this isn't standardised yet. I've tried not to brain dump and keep this concise, hope it helps 🙂
When I say "isn't standardised yet" I mean that a little bit of care needs to be taken in cljc files. Not that it isn't worth your time. eg.
(defn valid-user? [user] (seq? (:first-name user))) ;; checks user has non blank first name
That's portable clojure that can run on prettymuch every clojure dialect incl. jvm clojure and Clojurescript
(defn valid-user? [user] (not (.isEmpty (:first-name user)))) ;; checks user has non blank first name
☝️ Relies on jvm isEmpty method on string, and would not be able to run on clojurescriptWhatever little utilities and games I learn to program next I would like to run in browser first, then on desktop with as few changes as possible, then on Android with as few changes as possible.
Stick to cljs for now, it'll serve you well. Have a look at Capacitor when you get there — it takes your compiled browser build and wraps it for Android as-is.
OK, thanks. And I hadn't heard of Capacitor, only some similar things years ago when I last looked into this.
Oh, and I'm assuming that if webpage manipulation is the way to go first then I should be trying to use Reagent instead of direct manipulation, but I'm open to suggestions.
If your apps aren't incredibly data-heavy and don't require using existing React components, there are multiple alternatives. Well, even if they are and they do require - there are still alternatives. I'd suggest trying https://github.com/cjohansen/replicant first to see if it suits you.