Fork me on GitHub
#clojurescript
<
2015-07-18
>
mfikes00:07:21

@meow: Interesting. I never looked into letfn for :def-emits-var. Gonna see if it has implications there.

lazy-lambda01:07:39

Guys I need some feed-back on the cljs android REPL that I am working on. Should I drop the android apk on slack ?

dnolen01:07:00

@lazy-lambda: I don’t have an android phone but if you do I’m sure someone will try it!

erichmond02:07:29

Dumb question: Why “lein clean ; lein figwheel”. Why is the lein clean needed / what is it doing?

dnolen02:07:14

@erichmond: it’s not hard to get corrupted builds between sessions, lein clean is just a safeguard

erichmond02:07:41

@dnolen: I had suspected something like that. makes sense, thanks!

dnolen02:07:44

it’s something that’s improving but you still need lein clean to be safe

erichmond02:07:47

Between auto-reload on the server and figwheel on the front-end, and REPL driven development, it’s already a dream fulfilled. No complaints here! simple_smile

shofetim02:07:06

I think lein do clean, figwheel may be faster

mfikes02:07:31

If you don’t have an Android device handy, you can try @lazy-lambda ’s Replicator in http://Appetize.io: https://appetize.io/app/ea677qtmeyy9ec50khdp85j78c

borkdude09:07:42

@erichmond: There's also boot. Never a need to do 'clean', since it has the concept of immutable file sets.

borkdude09:07:05

@erichmond: I'm still working with lein by default (old habits...), but good to know that this exists

meow13:07:31

like a dog worrying a bone, I've been working on letting go of OO, embracing functional programming and immutable values via calculating frames-per-second. I finally have a version that doesn't use atoms. It was a good exercise for me. Here is the final result (so far - these things are hard to let go of):

(defn listen-fps-interval!
  "Executes callback at regular intervals returning the frames-per-second."
  ([callback]
   (listen-fps-interval! callback 500)) ; Measure every half-second
  ([callback interval]
   (request-animation-frame! (listen-fps-interval! callback interval nil 1)))
  ([callback interval start-time frame-count]
   (letfn [(step
            [timestamp]
            (let [start-time (or start-time (- timestamp 17))
                  elapsed (- timestamp start-time)]
              (if (< elapsed interval)
                (request-animation-frame!
                 (listen-fps-interval! callback interval start-time (inc frame-count)))
                (let [fps (->> (/ frame-count elapsed) (* 1000) (.floor js/Math))]
                  (if (callback fps)
                    (request-animation-frame!
                     (listen-fps-interval! callback interval timestamp 1)))))))]
     step)))

pesterhazy13:07:57

What's a good way to set a dom ready handler in cljs (I'm using reagent)?

meow13:07:25

@pesterhazy: there is a #C0620C0C8 channel. I'm not using reagent atm, but most of these things have an on-load or main function that gets invoked. Plus you want to make your code reloadable.

pesterhazy13:07:07

@meow: I guess I can simply make XHR requests in my (init) function?

erichmond14:07:14

Are there any frameworks that embrace a relay/falcor model besides Om Next, currently?

greywolve15:07:26

@erichmond: https://github.com/tonsky/datascript , not really a framework, but a building block that can certainly replicate that, and perhaps even be better (imo) simple_smile

dnolen16:07:34

@greywolve: Om Next was designed to integrate with DataScript trivially 😉 It’s like 10 lines or something last I checked.

greywolve16:07:54

@dnolen: looking forward to trying it out !

bostonou17:07:31

@dnolen: regarding http://dev.clojure.org/jira/browse/CLJS-1277, any objection to creating separate issue for implementing require, in-ns, etc?

dnolen17:07:24

@bostonou: only want to support require for the time being, no in-ns for now.

dnolen17:07:45

but sure separate issue is fine

bostonou17:07:00

@dnolen ok, guess i need some clarification on what falls under “etc.” simple_smile

dnolen17:07:09

only require for now

bostonou17:07:57

i’m looking into this now. implementing require might be beyond my current understanding of the compiler

dnolen17:07:43

@bostonou: the only thing that require needs to do is generate goog.require(…)

dnolen17:07:35

that’s step 1

bostonou17:07:42

i’m unclear on require relation to the :require in ns declaration

dnolen17:07:24

step 2 is demonstrating we can compile a file with require in it with no other ns forms.

dnolen17:07:35

@bostonou: we should do the minimal amount of work at each step.

dnolen17:07:55

actually supporting the features of ns would be another step.

dnolen17:07:57

it will likey be far simpler than it sounds simple_smilel

dnolen17:07:09

we already have support for merging this stuff into cljs.user

dnolen17:07:15

REPLs already work this way

dnolen17:07:36

so I would not get worried about these details till you get there.

bostonou17:07:49

our conversation yesterday made this sound more complicated in my mind.

dnolen17:07:10

it is more complicated, but the work has already been done for REPLs

dnolen17:07:16

and I can point you to how it works

dnolen17:07:55

we can just re-use existing logic

dnolen17:07:26

the only real significant new work will be making this work for builds

dnolen17:07:41

but that’s separate step which doesn’t need to tackled by these earlier ones.

bostonou17:07:52

ok, just trying to wrap my mind around the compiler in general. i blame the >20k LOC issue 😉

dnolen17:07:14

haha, yeah I wouldn’t bother looking at everything - it’s too much.

dnolen17:07:54

@maria’s work on the compiler is a good approach, incremental patches and just focus on the aspects of the compiler that are relevant to the task at hand.

dnolen17:07:18

the compiler is mostly functional so you rarely have to worry about significant repercussions for any small change.

dnolen17:07:17

@bostonou: note the REPL hack to make require work

dnolen17:07:51

(require ‘goog.string) -> (with-meta (ns cljs.user (:require [goog.string])) {:merge true})

dnolen17:07:45

this allows us to completely reuse the ns logic in the compiler and tell the compiler that this should merge existing information not replace anything.

bostonou17:07:27

ok sweet. that’s what i was looking for

samedhi17:07:59

I am looking to use https://github.com/streamproc/MediaStreamRecorder , where should I start when it comes to integrating this into my cljs boot build process?

dnolen17:07:02

@samedhi: there’s also a #C053K90BR channel (in case you don’t get an answer here)

samedhi17:07:34

Thanks you @dnolen, would https://github.com/clojure/clojurescript/wiki/Dependencies#using-externs still be the most up to date information about getting external code integrated?

dnolen17:07:33

@samedhi: yes for a library like that you will definitely need to provide your own externs

samedhi17:07:09

@dnolen: Thank you, things move so fast I wasn't sure if that was still the case.

dnolen17:07:27

@samedhi: I don’t think you’ll see a better story for foreign libraries until much later this year

meow17:07:49

@samedhi: to build on what @dnolen said, take a look at http://cljsjs.github.io/

meow17:07:23

and here is info and a boot tool to help with what you'll need to do: https://github.com/cljsjs/boot-cljsjs

erichmond18:07:57

@dnolen: when are you expecting Om Next to be “kick the tires” worthy?

dnolen18:07:29

@erichmond: probably sometime in September at the soonest

dnolen18:07:40

ton of work to do

erichmond18:07:04

Sounds good! Excited to check it out

bbloom19:07:13

A while back I was rambling about an alternative virtual-dom approach in this here chatroom. I don’t remember exactly who was involved in the discussion, but for those who were listening in, here’s an implementation of that approach: https://github.com/brandonbloom/cljs-vdom

bbloom19:07:18

feedback welcome!

dnolen19:07:55

@bbloom: seems like dealing with the reparenting issue is pretty novel amount VDOM implementations

bbloom19:07:18

Yeah, I don’t think anybody else has tackled it from what I can tell.

dnolen19:07:37

was definitely one of Rich Hickey’s expressed complaints about React

bbloom19:07:47

The “syntax” that’s provided for my testing purposes doesn’t address it b/c it uses hierarchical paths as IDs, but if you use the “core” API directly, you can easily give things any ID you want.

bbloom19:07:02

When I take a crack at a component model, I’ll encode IDs in terms of a “context” plus a “key”, where the default context will just be the ID of the current parent. The net effect being that you can opt-in to reparenting by overriding the default context, at the cost of having to ensure your keys are unique within a the greater scope of that given context.

bbloom19:07:17

But the underlying machinery handles it all quite well in my experimenting.

bbloom19:07:51

@dnolen: If I recall correctly, you said Rich also didn’t like the lack of independent addressability. With the global IDs, this is no problem either.

dnolen20:07:53

@bbloom: btw, seems like with bootstrapping sharing programming language experiments will be a lot simpler simple_smile

dnolen20:07:43

bootstrapped ClojureScript is still less JS than the front page of the New York Times 😛

bensu20:07:26

@bbloom: do you have any specific ideas wrt to event handling? or is that something that should be added as a layer on top?

orther20:07:28

I'm looking to jump back into cljs (I used it a little over a year ago for some experiments). Do you guys have a suggested article/tutorial/etc to get started with cljs using all the new great tooling I hear about?

orther20:07:02

I'm looking to build thick client style apps so I don't need integrated backend functionality.

orther20:07:07

cool thanks

orther20:07:35

well I guess thick client doesn't make that much sense, basically building the entire app clientside and in nw.js

dnolen20:07:47

@orther: lots of people really like figwheel, you can start programming a ClojureScript app in about 30 seconds

dnolen20:07:01

and it requires pretty much zero editor integration

orther20:07:28

I've read about figwheel, I've wondered if the magic behind it will cause me any problems.

orther20:07:38

I'll just have to try and see I guess.

bensu20:07:49

@orther: it probably won't. it has been very battle tested.

dnolen20:07:54

@orther: it’s quite popular, usually means it’s OK.

bensu20:07:22

after you understand the basic tooling underneath from the Quickstart I reccommend the figwheel template

orther20:07:42

Thanks for the advice guys.

orther20:07:58

Is cljs headed towards compiling in/on js rather than jvm?

orther20:07:10

Err, better stated self-hosting

mfikes20:07:44

@orther: No, that’s not the plan

dnolen20:07:58

@orther: already there, but people misunderstand the purpose

dnolen20:07:11

eliminating the JVM is a non-goal

mfikes20:07:16

Maybe there needs to be a FAQ covering the frequently asked question simple_smile

orther20:07:31

I did think that was the goal

dnolen20:07:44

@orther: nope, never was

mfikes20:07:50

@orther: You are not alone in that view for some reason.

orther20:07:01

I think I red that in a blog post in passing and it made sense.

orther20:07:18

What is the purpose?

mfikes20:07:32

@orther: You recall seing that there is a larger goal to eliminate the JVM?

orther20:07:23

I recall reading a blog post on cljs and the author mentioned that by removing the need for clojure/jvm it allows a bigger group of community (the js devs) to jump right in with less of a barrier

orther20:07:38

but nw that I think about it, I guess I made the assumption on top of that

orther20:07:06

the assumption that compiling your cljs using node was the end goal

dnolen20:07:53

@orther: yeah none of those things are part of any goal

dnolen20:07:07

ClojureScript is for Clojure developers and potential Clojure developers

dnolen20:07:11

not JavaScript developers

mfikes20:07:51

One common theme I sense is “I think I want to get into ClojureScript, but yuck, you are asking me to install the JVM on my box."

mfikes20:07:23

(I’m not making any judgement… just a sense of one common theme.)

orther20:07:09

Cool, glad you guys explained that to me.

mfikes20:07:51

@orther: No problem. You won’t be the last to broach the question. It happens once per day or so at least.

mfikes20:07:20

@orther: Especially with bootstrapped ClojureScript becoming a reality now. simple_smile

dnolen20:07:17

@dottedmag: I don’t see why not, would be cool

orther20:07:55

A few people I have talked to that watch clojure/clojurescript and are interested in cljs but not using it now have said things like, "Yeah I heard they are porting the compiler to be self hosting so I don't have to use java. I'm waiting for that."

dnolen20:07:38

@orther they’ll be waiting forever

dnolen20:07:46

we’re never going to ship a bootstrapped thing

dnolen20:07:57

it’s just a thing for ClojureScript developers to do if the target demands it

dnolen20:07:39

@orther: that said some people may very well end up using ClojureScript only via Planck or whatever, and that’s great.

dnolen20:07:12

and ClojureScript will actively help make such cool efforts possible and simple, but it’s not a “direct" focus area

orther20:07:16

ahhh yes I see

mfikes20:07:09

A different way of looking at it: What if ClojureScript required Node.js (instead of the JVM)? That would be a new thing for people to cope with. My advice: Deal with it! Don’t let something as simple as that cut you off from the great things you can do with this language.

bbloom20:07:23

@dnolen: bootstrap cljs vs NYT = hilarious

dnolen20:07:52

@bbloom: yeah gzipped bootstrapped cljs 300K, NYT loads 500+K gzipped

bbloom20:07:59

@bensu I do have many ideas for event handling, but yeah, higher level layer

dnolen21:07:33

@mfikes: a FAQ is probably a good idea simple_smile

orther21:07:36

Q: Is ClojureScript for JavaScript developers. A: Nah.

mfikes21:07:55

@dnolen: A part of me sees where the questions regarding ditching the JVM comes from. It could be a goal. But, in fact, it is not a goal. Just needs to be in a place.

mfikes21:07:07

@dnolen: I’ll start a draft Wiki, if you think that’s cool.

mfikes21:07:17

We can flesh it out and then point people to it.

mfikes21:07:00

Cool. As opposed to what is bootstrapped ClojureScript, this may answer why.

spiralganglion21:07:05

The painful thing is.. CLJS is very attractive as an alternative to JS, from the perspective of a recovering JS dev such as myself. Historically, the JVM was a necessary evil for using CLJS. With self-hosting, it looked for a moment like it might become an unnecessary evil. But instead, I think we JS devs just need to learn that the JVM actually isn't evil at all. It might be incidental complexity, but it's not a very deep tar pit at all — it's just hard to know how deep it is until you step in it.

mfikes21:07:44

@ivanreese: I never learned Python, never really developed an opinion about it. But, I used Mercurial, and loved it. I wonder… does ClojureScript actually require users to know a lot about the JVM? Maybe it is not as hidden as is the case with Mercurial / Python.

dottedmag21:07:00

ivanreese: Closure Compiler is in Java, and ClojureScript it is not very useful without it.

dnolen21:07:42

@dottedmag: to be a bit more precise, the primary use case is not very useful without it simple_smile

mfikes21:07:23

I created a new Wiki, with a stab at the JVM FAQ entry, spit out off the top of my head. Perhaps we can clean it up over time: https://github.com/clojure/clojurescript/wiki/Bootstrapped-ClojureScript-FAQ

dnolen21:07:44

@mfikes: looks like good start!

mfikes21:07:18

I think I’ll add an entry for the natural follow-on question that someone might have “Then why was bootstrapped ClojureScript crated?

chancerussell21:07:32

@maria @dnolen @mfikes Kudos on all the progress with bootstrapped cljs/Replete/planck. Really fun to watch you all work!

mfikes21:07:09

@chancerussell Thanks! (It is fun building little applications on top of bootstrapped ClojureScript!)

mfikes21:07:00

It will be interesting to see where all of this goes. simple_smile

chancerussell21:07:53

I’m looking forward to the day where it’s as easy/fast to write my little system scripts in ClojureScript as it is in Ruby, etc. Not that it’s particularly hard now, but the idea of compiling and running one-off scripts in one go is really appealing.

dnolen22:07:20

@chancerussell: Planck is definitely a big step in the right direction

dnolen22:07:39

being able to write scripts w/ zero build config is not a small simplification

mfikes22:07:20

I’m having trouble wording this one “JVM” point (trying to say it right without sounding negative): "A significant majority of ClojureScript developers are also Clojure developers. (In other words, ClojureScript largely exists to support the Clojure development community; not the JavaScript development community.)” (Anyone feel free to edit my botched attempt to express this.)

mfikes22:07:18

I think I’ve dumped all I’ve got on that page so no edit collisions will occur simple_smile

dnolen22:07:54

@mfikes: I don’t think we need to say anything about JavaScript developers

mfikes22:07:29

Maybe the parenthetical bit can be deleted. or the entire point.

dnolen22:07:44

@mfikes: or about the primary users. Yeah I don’t think that point is really so relevant.

annapawlicka22:07:02

@dnolen: I’ve tried to put the clojure version checking code into a separate ns, and require it and call its function before other ns form. and it doesn’t work in AOT compilation. i wanted to avoid dropping the same code all over the place. is there anything i should try (that i obviously don’t know of) to make AOT work?

dnolen22:07:25

@annapawlicka: yeah this was something I was afraid of.

annapawlicka22:07:00

yup, it’s throwing NPE in AOT

dnolen22:07:33

@annapawlicka: hmm, it’s for this reason that I’ve really avoided wanted to include this type of thing in ClojureScript

dnolen22:07:44

@annapawlicka: so much easier to solve at boot or cljsbuild

annapawlicka22:07:17

that was my thought. those type of checks should be done by the build tools

dnolen22:07:03

@annapawlicka: sorry for encouraging you to pursue this, but at least it’s a bit clearer why it’s not the right place to check

annapawlicka22:07:45

@dnolen: that was fun, i’ve never actually looked closely at cljs source code. Now I do simple_smile

annapawlicka22:07:41

I’m gonna try and create PRs for boot and cljsbuild - more knowledge about tools for me

annapawlicka22:07:14

@dnolen: i will comment on the jira issue about the AOT problem and will close it

martinklepsch22:07:49

@annapawlicka: boot-cljs is probably the best place to add this kind of check. If you have any questions feel free to ping me simple_smile

annapawlicka22:07:08

@martinklepsch: thanks! I have a free morning tomorrow so might start looking into that then. and cljsbuild too

annapawlicka23:07:18

yup, looks very much like what i wrote recently

martinklepsch23:07:20

boot-cljs follows ClojureScript versioning so the most recent version always checks for this. Maybe this is going to become a bit more loose in the future though.

annapawlicka23:07:02

i think it should only warn when the version of clojure prevents cljs from compiling

martinklepsch23:07:58

you mean of two incompatible versions are used? Agree.

martinklepsch23:07:25

That’s why I mentioned that boot-cljs follows CLJS version numbers

martinklepsch23:07:15

Anyways, I should really sleep. Feel free to hit me up if you have any questions. simple_smile

annapawlicka23:07:12

it looks like assert-clojure-version! checks for 1.7 only, and from experience i know that `1.7.0-alpha2’ won’t work with the latest cljs. so it should check for qualifiers as well.

dnolen23:07:21

cljs.js now very usable from a REPL simple_smile