Fork me on GitHub

is there any library you guys can recommend for doing matrix algebra in cljs + clj? hopefully something that can compute determinants, eigenvalues/vectors, and row reduction


My first reaction is core.matrix but I'm not familiar with it so I don't really know what it does 😐


thanks i’ll check it out


Hi, does anyone have experience with organizing assets like css, images, and fonts in clojurescript? In javascript, it will have module bundler like webpack taking care of that. Just wonder we have sth similar or what is the way clojurians would do?


for example, I want to bundle font-awesome and bootstrap


i’m not sure if you can actually load css the way webpack does using a module system. most people tend to have a resources/public directory and inside of there you might have a css folder and a js folder etc


then you can use something like figwheel which will watch your cljs/html/css and auto reload everything when anything changes without losing application state


that’s what I see in many examples


i would google around however, I know it is possible to break up your app into separate modules which can then be loaded as needed, because I’m guessing that why you were asking


if it is an optimization thing, then what I suggested above won’t really help you


uhm, I also want to break my app into separate chunk that for css, and js


actually, I can achieve that by using sth like webpack to do the hard work for bundling assets


and use clojurescript load that bundle file to get the assets


read this also when it comes to css you can check out with garden you can generate css using clojure data structures, and then load them as needed, so you can separate it up into only the minimal css needed for page load. then as people navigate to other pages you can inject the needed css.


I checked out that but it doesn’t mention anything about loading css files


I like to use garden but sometimes I just want to load the predefined css lib like bootstrap


maybe putting in resource folder will make sense in this case


your not a fan of using a cdn? then you could just toss a link into your html


but if you are using bootstrap that is something your whole app will need anyway right? so is the cost of just loading it upfront not worth it for you


so i think it will be fine to just download it and put it into your resources/public


if performance becomes an issue then try something more complicated


uhm, thanks for your help :thumbsup:


Hi all, I’m still at the beginning of my Clojure learning path. What is the recommend way to handle exception with clj-http ? From what I see in the doc, a simple try/catch is fine but as I collect the data directly within the let I’m not sure on how to do this ? Any idea ?


@lucj06: Using slingshot’s try+ is very nice with clj-http, but it’s still a try/catch setup, which sounds heavier than you were hoping for. Just for reference, I hope you’ve read the clj-http doc about this


There may be a way to ask clj-http to not throw exceptions on error status codes (but you’ll still get exceptions for things like timeouts, those come from deeper down the call chain).


@bruceadams: yes, I saw this doc but was not sure how to handle this. Is is a good practice to use a try/catch within a let ?


I do it: try/catch within the bindings part of a let. I’m not sure if it’s good practice or not. ¯\(ツ)


doing it inside the let bindings would mean you still want the code inside the let to run even if case of an exception


generally you're probably better off doing it around the whole let


in fact I just want to catch the error if the data cannot be retrieved and return an error message


And yet, keeping a try narrow avoids catching exceptions from actions other than the intended one.


in fact, I just need to catch the www/get error in case API is not accessible


in the doc exemple the result of the www/get is not directly assigned to something


so the try/catch is done directly around it.


i just discovered the advantages of transducers, holy shit this provides so much more flexibility!


it's like a map, or reduce, but then having the entire context at your disposal, instead of just a single item


am i correct that transducers are the preferred way to go if the transformation i'm trying to do are more complex than a typical map operation allows to do ? for example, transform a big nested structure into a "flat", denormalized object ?


Probably, yes. A big benefit is that they will transom your data in a single pass, instead of generating intermediate representations


@lucj06: note that data will be bound with whatever value log/error returns (maybe nil?)


@bruceadams: hum I agree… this is bad. Any advice on how to do this ?


in a more Clojure way ? simple_smile


I should probably return nil with each catch


@bruceadams: I do not get, from the doc, how you can affect the result of the request (let’s say it’s an api that return json) to a var.


@lucj06: I’m not sure I understand what you are asking. Each catch can contain multiple forms, can return nil from one like this:

(catch [:status 403] {:keys [request-time headers body]}
    (log/warn "403" request-time headers)


@bruceadams: in fact, I’m not sure what is the correct way to mix let and catch in my case. Should I embed try/catch in the let or the other way round ?


So, I can see that you want to log a message for failures (which makes sense). What happens next? Where do you want your program to go from here?


(In my one serious use of clj-http, my try+/catch was typically much higher up the call chain, not very near the call to clj-http. I assumed, up at that higher level, that anything with a numeric status came from clj-http.)


thanks, things are much clearer now. In my case, I need to send a json or nil.


Thanks to your help, I've understood several things of Slingshot.


I’m curious whether there are any docs that would explain the craziness that is a modern flexible clojurescript development environment


because entering it now new is rather daunting and confusing given all the tools


like one enters the clojure world and picks up emacs/cider because not to high learning curve and (eventually fulfilled) promises of ease of development


then one enters the clojurescript world desiring the same sorta dev env


only to encounter… well not so fast there etc .etc.


then one finds figwheel, ah! beautiful!


wait what about cider...








</(rant|cry for help) >


@puhrez: the clojure/cljs community has a lot of really awesome tools. So far I’ve just been focusing on using the ones I need at that moment and keeping aware of the general shape of tools that I don’t need so that I don’t miss a good reason to learn them. Setting up leiningen with custom profiles, and hooking it up to cider and getting emacs set up (for those of us who are not emacs-natives), etc. is a lot, and also, by the end of that list: you haven’t written any code!


So I’d say prioritize the stuff closest to writing code (figwheel, components) before the environment stuff like emacs/cider unless you have a particularly strong urge to learn those things (I’m assuming you have a meaningfully finite amount of time to spend on clojure stuff, otherwise just learn everything! lol).


@bwstearns: the thing is I’ve written clojure code, to production even! but now that I’m like let me take the full stack approach I want to maintain the same dev experience I’ve had with emacs/clojure/cider the whole figwheel stuff seems so familiar but oddly difficult to integrate


@puhrez: oh cool. I've just been using clojure for personal stuff so far so you're way ahead of me there. I think the thing is that there are just a lot of tools that all play together and it's a young enough ecosystem that there isn't a one true way yet. It might also be a touch of the lisp curse in that people can hack stuff together easily enough often enough that a lot remains in the state of solving "my 80%" of a problem instead of getting fully generalized.


yea that’s definitely a factor


i guess it just means that it’s ripe for contribution!


:D I'm commuting or I would cite specifics but I've experienced a lot of clojuretv's videos on YouTube being helpful for tool setup because watching someone set it up can be easier than reading a howto since you can see the rest of files that may make assumptions that you weren't aware of.


@puhrez: Have you looked at especially the section "Using the Figwheel REPL (Leiningen-only)"


this is beautiful