Fork me on GitHub
#clojurescript
<
2016-03-06
>
richiardiandrea01:03:31

Never mind I found out 😄

mattly02:03:53

if I have some edn that in clojure read-string will parse but in cljs, cljs.reader/read-string won’t parse, is there somewhere I should check known issues?

adamkowalski02:03:35

hey what do you guys think the best editor is that has good clojure AND good clojurescript support?

adamkowalski02:03:59

and hopefully it can work well with figwheel as well

richiardiandrea03:03:25

@adamkowalski: emacs with cider can launch a clojure AND clojurescript at the same time

adamkowalski03:03:24

Yeah I used that for a while, and while it is great for Clojure I personally struggled using it with figwheel

adamkowalski03:03:10

You end up using nrepl and figwheel sidecar, and piggieback

adamkowalski03:03:38

I heard things might get better with the socket repl thats being worked on, but for now I was wondering if there is a solution that just works

adamkowalski03:03:53

Ideally it has some support for parinfer as well

adamkowalski03:03:38

That being said, maybe I am doing something wrong, and emacs/cider are great for clojurescript/figwheel and I would love to be told I am incorrect

richiardiandrea03:03:47

@adamkowalski: I am using it at the moment and, while I had some problem as well, it looks like now it is easier then ever

richiardiandrea03:03:08

you need lein repl and the three figwheel commands only

richiardiandrea03:03:33

I can link you to some working project.clj

richiardiandrea03:03:03

on the other end, if you are not an emacs enthusiast, I heart Cursive and figwheel do work well together

adamkowalski03:03:45

yeah could I see your project.clj?

adamkowalski03:03:58

And how would you say light table compares to cursive and cider?

richiardiandrea03:03:51

nice, kind of new, you have paredit (optional) of course and inline eval result, but I have never tried it with figwheel

richiardiandrea03:03:26

it is kind of still in progress so I hope it is working fine, I switched to the new figwheel way recently

adamkowalski03:03:54

Interesting. The reason I thought about light table is because of this https://github.com/mauricioszabo/lt_parinfer

richiardiandrea03:03:52

yes well there is parinfer support in atom as well if i am not wrong, but I do not use parinfer so I cannot advice on that

adamkowalski03:03:26

ok so it seems like this is the important part to include right :profiles {:dev {:resource-paths ["dev-resources"] :source-paths ["src/cljs" "src/clj" "test/clj" "test/cljs" "test/browser" "src/browser" "repl-demo/browser/cljs" "dev"] :dependencies [[com.cemerick/piggieback "0.2.1"] [org.clojure/tools.nrepl "0.2.12"] [figwheel-sidecar "0.5.0-6"] [cljsjs/jqconsole "2.13.2-0"] [reagent "0.5.1"] [binaryage/devtools "0.5.2"] [spellhouse/clairvoyant "0.0-72-g15e1e44"]] :plugins [[lein-doo "0.1.7-SNAPSHOT"] [lein-figwheel "0.5.0-6" :exclusions [cider/cider-nrepl]] [lein-shell "0.4.2"]]} :repl {:plugins [[cider/cider-nrepl "0.11.0-SNAPSHOT"]] :repl-options {:nrepl-middleware [#_cider.nrepl/cider-middleware cemerick.piggieback/wrap-cljs-repl]}}})

adamkowalski03:03:55

oh if you are not using parinfer you need to try it, it is amazing

adamkowalski03:03:21

its not great, but it works in emacs

adamkowalski03:03:39

unfortunately it is not in melpa or marmolade

richiardiandrea03:03:44

no I know it is, just slacked a bit 😄 I want to add parinfer support in http://clojurescript.io

adamkowalski03:03:05

oh awesome, is that an online repl?

adamkowalski03:03:12

I know that @mfikes has it working in https://github.com/mfikes/replete so maybe you can talk to him about how to go about integrating it into your project

richiardiandrea03:03:54

yes Mike and I are discussing constantly as replumb is basically a rib of planck 😄

adamkowalski03:03:50

I wish that somehow we could combine the efforts of all the people that are working on projects like this so we could have a common base that works

adamkowalski03:03:16

I know that nrepl tries to do that but it seems like it hasnt really achieved that goal “im my opinion"

adamkowalski03:03:48

like figwheel has its own repl, then there is the brepl, nrepl, ios repl, and so on

richiardiandrea03:03:00

I guess replumb was born out of that necessity, for bootstrapped Clojurescript only

adamkowalski03:03:17

if we could make a common standard that could support clojure/clojurescript/ios

adamkowalski03:03:36

and could have an easy to use way to extend it

adamkowalski03:03:50

so that way maybe parinfer, paredit, whatever could be made as part of the repl itself

adamkowalski03:03:00

then different projects could automatically get that for free

richiardiandrea03:03:13

mmm, I don't know, I think you would me mixing too many responsabilities

richiardiandrea03:03:28

a repl is just, read eval print loop

laggybit03:03:40

on the other hand, having so many different implementations is a pretty nice problem to have

laggybit03:03:10

I don't recall ever having such a nice integration story between vim and a lisp

adamkowalski03:03:24

@laggybit: yeah they have fireplace right

richiardiandrea03:03:50

yes what's going on with Clojure tooling it's awesome imho

richiardiandrea03:03:06

we even have a successor of paredit

adamkowalski03:03:10

yeah the tooling story is great

richiardiandrea03:03:12

quite unexpected 😄

adamkowalski03:03:29

figwheel, devcards, browser repls, custom clojure devtools

richiardiandrea03:03:07

probably we also need them because debugging and error messaging is, let's say, to be improved

adamkowalski03:03:21

I am just in search of “the best” experience I can make with the awesome tools we have available

adamkowalski03:03:47

cursive was great, but it is maintained by one person so that is a little scary to me

laggybit03:03:18

emacs probably still has the best experience

adamkowalski03:03:31

yeah it seems like a lot of people think that

laggybit03:03:33

with cider and all

adamkowalski03:03:42

do you use it with nrepl as well?

laggybit03:03:01

(but cider's middleware actually works everywhere too!)

adamkowalski03:03:24

the one thing that appeals to me about light table is that it is written in clojure, and something about having a clojure ide written and extended in clojure seems awesome

adamkowalski03:03:06

emacs has elisp which is nice, so it is definitely of much interest to me as well

laggybit03:03:02

I'm not sure changing editors in search of the best integration is your best bet; bringing that integration to your favored editor would probably work better in the long run

richiardiandrea03:03:02

I think light table is written is Javascript no? I might be wrong

adamkowalski03:03:37

it is written in clojurescript

adamkowalski03:03:59

I think one of the ideas behind it is that the whole editor is one big immutable value

smw03:03:22

(devcards are so damn cool)

laggybit03:03:32

isn't lighttable based on codemirror?

smw03:03:51

so obvious in hindsight, but so much cooler in practice than you’d imagine

adamkowalski03:03:45

but i think it is based on codemirror

adamkowalski03:03:51

@smw yeah definitely

adamkowalski03:03:04

i really like the ideas he has about using it for testing your user interface too

laggybit03:03:02

indeed, it exposes so many edge cases in UI design

laggybit03:03:18

going back to building js/css components the old fashioned way feels like banging rocks together

laggybit04:03:28

on the other hand, clojurescript has proven extremely detrimental to my ability to write javascript

adamkowalski04:03:43

I also never write css anymore

adamkowalski04:03:50

I just use the style map

adamkowalski04:03:58

that way all my styles can be generated using functions

adamkowalski04:03:17

and I can compose styles together to get more interesting looking components

laggybit04:03:29

I haven't made that jump yet

laggybit04:03:09

been exploring garden but I haven't had a project yet where I could make the switch and not piss off everyone else

laggybit04:03:23

gonna stick to BEM for a while

adamkowalski04:03:25

yeah garden is really interesting

adamkowalski04:03:34

but I don’t even use that

adamkowalski04:03:55

because I havn’t found a way to make the styles dynamic with garden

adamkowalski04:03:10

if you just use a map {:style {:font-size “24px”}}

adamkowalski04:03:16

you can generate the styles on the fly

adamkowalski04:03:48

it just requires a change in mindset. before things like on hover were handled by css, and now they are part of the model

laggybit04:03:49

wouldn't garden basically just give you that?

adamkowalski04:03:38

perhaps, but I havnt found a way where I can make garden product styles dynamically, to for example take in the current model as input to a function and then product different styles based on that

adamkowalski04:03:16

usually you need to use goog.style/injectStyles I think it was called

adamkowalski04:03:03

from vanilla react I used to use a library called Radium http://stack.formidable.com/radium/

laggybit04:03:52

right, so you apply styles directly to your elements

adamkowalski04:03:00

yup, no css classes

laggybit04:03:03

my coworkers could stop talking to me if I did that, lol

adamkowalski04:03:28

its definitely something I would try on a smaller project first just to see if you like it or not

adamkowalski04:03:33

it may not be for everybody

adamkowalski04:03:02

and I wouldn’t try to impose it on your coworkers before you have a firm understanding of how it works, and the sometimes wierd things you deal with

laggybit04:03:09

I can see that working if your project is an SPA

laggybit04:03:39

I deal with too many actual websites to make that work; we spent so much effort on our current css methodology already

adamkowalski04:03:22

thats understandable, but I think that if you have a small project that you can work on for your own leisure try it out

adamkowalski04:03:47

in my opinion css is really hard to wrangle because it lacks many things that we get out of the box in a real programming langauage

laggybit04:03:51

how do you handle style reuse?

adamkowalski04:03:59

style reuse is the best part

adamkowalski04:03:19

since it is just clojure code, you can namespace it, and include it wherever

adamkowalski04:03:48

everything about clojure that makes it fantastic for managing your code now works for css

adamkowalski04:03:51

it is simply a map

adamkowalski04:03:00

everything is just a datastructure

laggybit04:03:08

that's the way garden pretty much works; everything is a clojure data structure until you actually persist the data structure to css, then it all becomes classes

adamkowalski04:03:22

yeah, thats exactly right

adamkowalski04:03:31

and that is the only thing I dislike about css

adamkowalski04:03:02

I think that class names are a really bad means on naming your styles

laggybit04:03:03

so I assume you're doing the same thing, but instead of generating an entire css file and then using classes on your components, you rather have the component be written to the DOM with the styles built-in

adamkowalski04:03:18

^ yup that is exactly correct

adamkowalski04:03:38

naming is a really hard problem, and being able to make small composable building blocks is the key to modularization

laggybit04:03:40

that could work, actually

adamkowalski04:03:49

you have a generic function that can create the styles for a button

laggybit04:03:05

obviously you're still naming your clojure variables, but you get namespacing, which css doesn't give you

adamkowalski04:03:06

instead of having {:className ".button .green”}

adamkowalski04:03:21

you now have {:style (button “green”)}

adamkowalski04:03:29

where button is a function which takes a color

adamkowalski04:03:37

obviously a really contrived example

adamkowalski04:03:39

but you get the point

laggybit04:03:55

I think I do

adamkowalski04:03:57

if you can generate a map in some way, you have a valid style that you can attach to a component

adamkowalski04:03:16

if you want to share it between componenets, toss it in a seperate file and then include it wherever you need it

adamkowalski04:03:38

merge your different styles into larger and larger maps and boom! you get more interesting styles

laggybit04:03:39

I could probably apply that approach in both use-cases, the css case, and your direct-to-style case

laggybit04:03:53

because initially, the styles are in a clojure data structure

laggybit04:03:36

for a website, export to css via garden, whereas for an SPA, apply the style directly to react components

adamkowalski04:03:47

yeah, or have a mixture of both

adamkowalski04:03:55

static styles can be made via garden or raw css

adamkowalski04:03:11

and if you have something that is dynamic then use my method for that portion

adamkowalski04:03:26

the best part is garden uses almost the same types of maps that I use

adamkowalski04:03:38

so you can honestly mix and match with minimal effor

laggybit04:03:14

now I need a side project, not related to work.. lol

adamkowalski04:03:44

make try making a similar project to something you have made before

adamkowalski04:03:01

that way you can do a comparison of how each way worked and which way works best for you

adamkowalski04:03:15

you probably wouldn’t even need to re code the app, just port the styles

laggybit04:03:33

my daytime job isn't interesting enough for that 😛

adamkowalski04:03:01

unfortunately I cant help you with that one

rlucha11:03:33

if I have a doubt of a code snippet not working where should I paste it / ask?

rm11:03:35

rlucha: try here

rlucha11:03:45

;; ----------------------- ;; Channels (listen for events in a element and put then on a channel) (defn listen [el type] (let [out (chan)] (events/listen el type (fn [e] (put! out e))) out)) ;; clicks is a channel that receives all the click on app element (def clicks (listen (dom/getElement "app") "click")) (defn output-clicks [] (go (while true (<! clicks) #(swap! current-slide inc) (println current-slide))))

rlucha11:03:58

the swap is not working inside the go expression

rlucha11:03:02

I have no clue why

rlucha11:03:18

I've previously defined (defonce current-slide (reagent/atom 0))

rm11:03:28

wrap your code with 3 `

rlucha12:03:04

(defonce current-slide (reagent/atom 0))

;; -----------------------
;; Channels (listen for events in a element and put then on a channel)

(defn listen [el type]
  (let [out (chan)]
    (events/listen el type
      (fn [e] (put! out e)))
    out))

;; clicks is a channel that receives all the click on app element
(def clicks (listen (dom/getElement "app") "click"))

(defn output-clicks []
  (go (while true
        (<! clicks)
        #(swap! current-slide inc)
        (println current-slide))))
`

rlucha12:03:41

println executes but the atom won't change

cjmurphy12:03:20

How come the #( ...) around the swap?

rlucha12:03:43

sintactic sugar afaik

rm12:03:02

#(swap! ...) is a function, it doesn't do anything

cjmurphy12:03:13

Is same as (fn [] ...)

rm12:03:22

cjmurphy: exactly

cjmurphy12:03:56

Does it work w/out #?

rlucha12:03:23

yes (facepalm)

rlucha12:03:29

thank you!

bbss12:03:28

I am playing around with parinfer and replumb, I had looked at using the bootstrapped compiler half a year back or so but found it a bit too difficult. Replumb made it way more accessible!

bbss12:03:38

And parinfer makes it soo I don't have to miss paredit too much and actually makes my phone a viable device for development simple_smile

iwankaramazow12:03:37

@bbss: any advantages over paredit w/parinfer?

iwankaramazow12:03:07

I've just managed to somehow get comfortable with emacs/paredit

bbss12:03:10

@iwankaramazow: hmm, too early to tell.

bbss12:03:28

but on mobile keyboards with limited hotkeys, for sure!

bbss12:03:06

although I do have a bluetooth adapter to connect and power my keyboard to it 😄

inhortte14:03:41

I'm trying to use react-native and clojurescript (https://github.com/mjmeintjes/boot-react-native). I'm having problem using React.fetch(url) as I want to use .then on the returned promise: (.then (.fetch js/React uri) (fn [res] ...)), but I'm getting "undefined is not a fuction (evaluating 'React.fetch(....)'. Does anyone have any pointers?

bbss15:03:34

@inhortte: there is #C0E1SN0NM

inhortte15:03:05

@bbss thanks. I'll post there.

bbss15:03:17

I am having trouble require-ing macro's with replumb. Not sure if I need a newer version of cljs(.228)/replumb(0.1.5-3) or need to configure something differently (maybe add an additional source-path to repl opts) or it's just not possible yet. I would like to use core.async, mount and devcards macro's.

bbss15:03:52

There are some posts/gists about using macros from bootstrapped cljs. This issue seems related: https://github.com/Lambda-X/replumb/issues/108, but I can't figure out if those fixes should be in cljs .228, judging from the ticket still being open maybe not. I will try to figure out how to build cljs from source.

mfikes17:03:49

@bbss core.async is not compatible with bootstrap ClojureScript

adamkowalski23:03:38

Idk if you guys have seen atom and clojure work together but I thought I would share this

adamkowalski23:03:47

this is amazing

adamkowalski23:03:27

between those 3 packages atom is honestly as good as light table in my opinion

chrisoakman23:03:34

why thank you 😉

chrisoakman23:03:22

Ever since the invention of Parinfer, I have practically only used Atom for writing ClojureScript. No complaints.

adamkowalski23:03:46

awesome haha, have you been using figwheel as well?

richiardiandrea23:03:07

@bbss that bug is still open but it is not macro related, macro are loading but you need to configure the source path and plug io in replumb

chrisoakman23:03:14

I don't use figwheel personally, but I think it's an excellent project. And the importance of rapid feedback while developing cannot be understated.

adamkowalski23:03:28

yeah, I am going to try to get atom and figwheel to play nicely with protorepl

adamkowalski23:03:48

I feel like I can go down the nrepl + sidecar + piggieback route and see how that works out

adamkowalski23:03:53

But, how was the process of writing plugins for atom? Was it a pleasant experiance?

chrisoakman23:03:12

It wasn't terrible. I enjoyed writing the Atom plugin better than writing the Sublime plugin.

chrisoakman23:03:25

I was driven by an intense desire to see Parinfer working in Atom; that over-shadowed any difficulty in working with the API.

adamkowalski23:03:39

Since Atom is javascript based, we should be able to write ClojureScript and transpile down to JavaScript right?

adamkowalski23:03:04

so we could write plugins with the same language as your actual projects

chrisoakman23:03:31

atom-parinfer is written in CLJS, and I wrote it using Atom

chrisoakman23:03:59

so I would test out Parinfer features in atom, on the atom-parinfer codebase, the whole process was very recursive

adamkowalski23:03:39

wow, why are more people not doing this yet?

adamkowalski23:03:23

you should think about writing a blog post describing your process so more people get inspired and make more things 😛

adamkowalski23:03:48

that way we get more people writing clojure in atom, which leads to more packages, which makes the workflow even better

adamkowalski23:03:56

positive feadback cycle

chrisoakman23:03:31

I have been meaning to write more about CLJS.

chrisoakman23:03:38

I tend to seek out programming over writing with my spare time; the pendulum has probably swung too far towards programming though. Need to produce more English.

adamkowalski23:03:49

Yeah, but anyway thanks for your work on parinfer

adamkowalski23:03:36

If you need any help with the project you should let me know

adamkowalski23:03:50

I would love to check out the work and help contribute if I can

chrisoakman23:03:23

You're welcome simple_smile Although @shaunlebron deserves the lion's share of the credit for Parinfer. The #C0F2A0MJN channel has some discussion around plugin development and whatnot.

adamkowalski23:03:39

alright cool, I joined. I will lurk around there and keep my ear open

chrisoakman23:03:54

There are some issues on the language-clojure package that would indirectly help atom-parinfer: https://github.com/atom/language-clojure

adamkowalski23:03:04

I gotta head out but it was nice talking to you

adamkowalski23:03:23

oh ok I will bookmark that and take a look tonight when i get back!

chrisoakman23:03:58

Specifically, writing some test cases for this PR would benefit atom-parinfer: https://github.com/atom/language-clojure/pull/37

chrisoakman23:03:15

no problem; thanks for the kind words simple_smile