Fork me on GitHub
#clojurescript
<
2016-01-24
>
gerred00:01:26

Is clojurescript with Node something viable that people are doing in production? I'm really liking the idea, but don't yet know enough. I do know I'd feel more comfortable, given I've put node in production but I've never put a JVM app in prod.

gerred00:01:51

finding myself far more interested in clojurescript than I would be clojure itself oddly. simple_smile

gerred00:01:40

alternately, maybe I get over it and get more comfortable with the JVM.

dnolen00:01:46

@gerred: people do target ClojureScript + Node.js, usually AWS Lambda or for simple scripting

gerred00:01:55

ah, Lambda's a great idea for that.

dnolen00:01:09

but but more common for backend stuff to just use Clojure

gerred00:01:09

be nice if there was something like Serverless targeted for ClojureScript.

gerred00:01:14

makes sense.

gerred00:01:30

I've been in Ruby/Go land, so the JVM is a scary beast. 😉

dnolen00:01:11

well having done my fair share of Ruby there’s nothing and more or less scary about the JVM simple_smile

gerred00:01:18

ha, that's good to hear.

jimmy08:01:37

@gerred: I have experienced with go and ruby, the only downside of JVM is its startup time. But with Clojure you can enjoy its repl without restarting JVM, and once JVM run, it's blazing fast simple_smile

jarodzz14:01:53

a new bie question. i want to do some js work, and trying to figure out clojurescript. but there seems to be too much things. i see reagent, om, clojurescript and its plugins

jarodzz14:01:38

i' ve done some clojure small project, and only a little on js. can some one give me a clue where should i start?

dnolen14:01:02

@jarodzz: start with the Quick Start

dnolen14:01:56

cljsbuild is still the most popular plugin so there’s a lot of knowledgeable people if you have questions about it

dnolen14:01:40

Om is more of a UI distributed state framework - unless that seems useful to you - you might find Reagent easier going

jarodzz14:01:33

got it. so clojurescript itself first, then others. do i need to learn reactjs ?

jaen14:01:33

@jarodzz: https://github.com/magomimmo/modern-cljs/tree/master/doc/second-edition is a pretty cool introduction on how to set up a Clojurescript project; uses boot instead of leiningen though.

dnolen14:01:15

@jarodzz: if you want to use a React binding yes

dnolen14:01:33

but some people use jQuery, others just Closure Library

dnolen14:01:45

I would just use the things which are most familiar to you

jaen14:01:47

You can learn React.js first, but that's not required, really. You will be able to pick up enough knowledge from using the wrapper, I think.

jaen14:01:10

Just like you don't have to learn assembly first to program in C.

dnolen14:01:23

in my opinion don’t get caught up learning 3-4 or things a the same time

dnolen14:01:27

if you want to actually get something done

jaen14:01:53

Yeah, this is also true, it's helpful to take things one at a time.

jarodzz14:01:12

@dnolen. got it. i think i am a litle bit rush to just paint some chart using clojurescript, and got overwhelming by the info. thanks. i'll start by cljs, cljsbuild, then some others.

gerred14:01:19

@nxqd yeah, that makes sense. I've been also jumping into Elixir land, but it's "too much", and ended up on Clojure as a general purpose language for when I'm not using Ruby.

gerred14:01:29

but didn't want to spend my life tuning the JVM. 😉

dnolen14:01:00

@jarodzz: if you want to make some charts then I would recommend

jimmy14:01:07

@gerred: if you are application developer, you will be totally happy with original JVM. Optimization and such is for hardcore case, since it will be done and once you have to touch it, there are plenty of mature tools available on JVM land.

dnolen14:01:13

cljsbuild + whatever cljsjs charting thing is popular

dnolen14:01:21

I wouldn’t spend time looking at other things

jarodzz14:01:30

by the way, i have seen your youtube video on core.async, never thought i'd talk to you in person. simple_smile thx again

jarodzz14:01:56

@jaen, thanks for the link, i'll give a try.:)

gerred14:01:06

@nxqd Go, while simple, felt a little too anti-intellectual to me. Hostile to any abstraction, much less good ones.

gerred14:01:30

and once I heard core.async is much like Go's concurrency model, that helped too.

gerred14:01:07

not to pollute this channel anymore. simple_smile

jaen14:01:42

@gerred: would ask in what way you think Elixir is too much, but I guess you're right about not polluting the channel.

jaen14:01:18

If you feel like explaining, then sure.

gerred14:01:24

just want to preserve history here

iwankaramazow14:01:48

I have a question about JSON parsing: a certain REST api returns: (console.log gives me: ) #js [#js {:id 1 :foo "bar"} #js {:id 2 :foo "baz"}] What's the most efficient way to convert this to clojurescript vectors with maps inside?

jaen14:01:39

The easiest is js->clj but it's also the most simplistic.

jaen14:01:00

A better option would be to look into prismatic's schema and coercions.

jaen14:01:26

Then you can describe what data you expect and transform them in both directions

iwankaramazow14:01:00

k, thx! I noticed js->clj gives me Strings as keys instead of keywords, any workaround?

jaen14:01:20

And example of how I used this is here - https://github.com/jaen/panda-5/blob/master/src/panda_5/api/coercion.clj - there's also a similar lib out there, let me find it.

jaen14:01:32

Take a look at clojure.walk.

jaen14:01:16

And that's the library I mentioned - https://github.com/gfredericks/schema-bijections - didn't use it though, so I'm not sure how it compares to using coercions directly.

iwankaramazow14:01:30

Ok, I'll take a look at it.

jaen15:01:16

Also what do you use to get the data from the API?

jaen15:01:31

Libraries like cljs-ajax usually have parameters that take care of it for you.

iwankaramazow15:01:59

currently Jsonp from the Google closure library

jaen15:01:02

Ah, so you have to do it all by hand, yeah. So I guess you can start out with js->clj and clojure.walk/keywordize-keys and then look into schema coercions when you will want to have more complex data types converted, like dates or something.

iwankaramazow15:01:00

do you have experience with a library like Transit?

jaen15:01:22

Yes, I do.

iwankaramazow15:01:52

should I use it in this scenario?

jaen15:01:29

Hmm, that's a good question. Transit makes most sense if the backend you talk to also speaks transit.

jaen15:01:04

If I recall correctly, transit is still faster at parsing JSON than js->clj plus some transformation would be

jaen15:01:02

But it depends entirely how complex is the JSON coercion you wan to do - if you want to convert for example dates after you parse the JSON, then you will not gain much by using transit instead of JSON.parse, js->clj and then schema coercion, I think.

jaen15:01:21

If the hydration is simple, then you might gain performance, let me find that blog post

pbaille15:01:57

hello everyone, is it possible to inject raw html into a reagent component? like with the :dangerouslySetInnerHTML key in sablono

jaen15:01:20

Though probably the best idea is to benchmark how each approach behaves in your use-case to be sure.

iwankaramazow15:01:20

@jaen: Thanks, I'll evaluate all options

jaen15:01:45

No problem, hope it helped.

pbaille15:01:57

yes I just found it! apparently it is the same as in sablono

pbaille15:01:06

thank you!

glenjamin16:01:41

dnolen: thanks, those pointers have finally made the penny drop for me

glenjamin16:01:38

it’s really just all down to cleverly generated method names

dnolen16:01:07

@glenjamin: right that’s how we avoid name clashes

alex-eberts16:01:17

hi folks, I’m trying to add a map to a nested map structure (map ( vector (map map… ))) but having some issues figuring it out. It seems to work at the repl but not when I make it into functions. Could someone take a look at this paste and tell me what I’m doing wrong please?

dnolen17:01:06

@alex-eberts: seems you want update-in + merge or you want assoc-in

dnolen17:01:23

based on the data update-in + conj doesn’t seem right

alex-eberts17:01:28

@dnolen: thanks for the feedback! Is there a reason update-in + conj should work at the repl but not as a function?

dnolen17:01:53

@alex-eberts: that statement sounds unlikely

alex-eberts17:01:33

I know! that’s why it’s confusing simple_smile

alex-eberts17:01:18

I’ll try update-in + merge and / or assoc-in

alex-eberts17:01:29

appreciate the help

actsasgeek17:01:43

just an update. In an attempt to isolate the difficulties I was having on Friday with d3 and ClojureScript, I started a fresh Figwheel project with the cljsjs d3 package and pasted the code in. It worked just fine. This suggests to me that an interaction at a higher level (library?) is causing (call x-axis) to fail as I described.

hkjels20:01:18

Is there a way to start figwheel without landing at it’s repl? Up until now I’ve been starting figwheel from a separate shell in order to preserve the cider repl, but I’d like a single command to run everything from Cider

plexus20:01:55

@hkjels: use :repl false in the figwheel config in project.clj

plexus20:01:09

you might also want to look into launching figwheel from your cider repl https://github.com/bhauman/lein-figwheel/wiki/Using-the-Figwheel-REPL-within-NRepl

hkjels21:01:34

@plexus: nice! Thank you

scottbale22:01:05

Running thru the quickstart. Is there any reason the browser repl wouldn't work over the internet (as opposed to via localhost)? I'm attempting to start the repl on an ec2 instance. I'm at the point where my browser is successfully fetching every resource except this one (according to chrome dev console) : http://<ip address>:8080/repl?xpc=<...omitted...>robots.txt%22%7D console points to crosspagechannel.js:486 Meanwhile the repl just hangs with the message Waiting for browser to connect ... This is Java 8, cljs 1.7.228. I'm using a nonstandard port (8080) for the repl.