Fork me on GitHub
#clojurescript
<
2016-01-29
>
richiardiandrea00:01:52

Has someone ever tried to "bend" code mirror and have a repl in the style of a terminal (like http://clojurescript.io) ? @jaredly

jaredly01:01:28

@richiardiandrea: http://jaredforsyth.com/reepl/ uses codemirror if that’s similar to what you’re imagining

richiardiandrea01:01:18

yes, that's exactly why I am asking you 😄 basically I would like CodeMirror but with the familiar top-to-bottom terminal

jaredly01:01:36

it wouldn’t be too hard to change reepl to have the top-to-bottom style. just change the element that scrolls, really

richiardiandrea01:01:06

because I am having problems with jqconsole and I was wondering if I should switch...still...i don't know if CodeMirror is reagent friendly enough

richiardiandrea01:01:34

but you tell me that it is not difficult to change the style, well I might dig into it

jaredly01:01:10

I made a codemirror wrapper that sync w/ a reagent atom

richiardiandrea01:01:02

I'll have a look

richiardiandrea01:01:58

I will either go with your solution or implement a custom re-console (I always propose it but everybody feels like reinventing the wheel)

jaredly01:01:35

have you seen the various codemirror-console libraries? http://kybernetikos.github.io/SoleMirror/ (and some others that I can’t find immediately)

richiardiandrea01:01:14

Nice! I like jq-console because it has the classic feeling of being in a terminal simple_smile

richiardiandrea01:01:44

I guess that with some css-fu I can adapt code mirror to that style

jaredly01:01:04

I’m sure there’s a theme that’s green text on a black screen 😄

Josh Horwitz02:01:55

Hey everyone, I was wondering is it necessary to learn Javascript prior to learning Clojure Script? It’s not my first language , I am a Java developer, but I rarely use Javascript.

jaredly02:01:16

@joshua.d.horwitz: it’s not necessary. you might run into some javascript things (just like clojure gives you java stacktraces) but the people here are super helpful 😄

jethroksy02:01:09

It's good to know how JavaScript works though, like how its single threaded

jethroksy02:01:56

I'd say it's good enough to Google your way out when your run into problems but that's still not ideal

Josh Horwitz02:01:07

Hmm, I guess it wouldn’t hurt to do some javascript learning quickly before

jethroksy02:01:10

Hmm a "just enough JavaScript for clojurescript" tutorial would be nice

jethroksy02:01:02

One thing I underestimated was how powerful the Google closure library was

jaen02:01:10

So I've heard, but it's a very Java-ish, hardly documented style of Javascript unfortunately.

jaen02:01:36

Most "typical" Javascript programmers would denounce it pretty fast.

jaen02:01:57

I for one would appreciate a "just enough GClosure library for a Clojurescript developer" P ;

Josh Horwitz02:01:41

That is a great Idea for a tutorial!

Josh Horwitz02:01:47

I’ll help in anyway I can

jethroksy02:01:55

After reading the state of clojure results I feel like there's a huge influx of people who want to try it out, and that we should do a better job to ease in adoption

jethroksy02:01:01

one thing i'm curious about is what makes them stay

jaen02:01:39

I think that the interactive development story is pretty strong

jethroksy02:01:57

many people seem to struggle to get their environment up and running

jaen02:01:47

Hopefully boot with tutorials like Modern Clojurescript helps with that

jaen02:01:07

IMO boot's Clojurescript story is far less painful than lein-cljsbuild

jethroksy02:01:10

I really liked mark mandel's idea of dockerizing everything

jethroksy02:01:48

perhaps a container with working emacs + CIDER, or vim + fireplace

jaen02:01:00

Or Cursive <3

jaen02:01:29

Though I don't know how reliable docker is with X forwarding

jaen02:01:55

My test project seemed to work well with docker though (with Cursive outside)

jaen02:01:09

But I had problems running it on windows for example

jaen02:01:35

And at least setting up Clojure projects is still simpler than Ruby or such

jethroksy02:01:36

^ docker should precisely solve that

jethroksy02:01:49

all the boot windows problems would dissolve

jaen02:01:51

Should, but I couldn't even boot the image there

jethroksy02:01:57

because they're essentially running it in unix

jaen02:01:19

Though that might just be me not using windows for 4 years and not knowing what to do

jaen02:01:43

That's probably not a Clojurescript topic to be honest

amonks02:01:29

I started with cljs a couple months ago, and I’m using it for a client project now.

amonks02:01:47

I stayed for the macros, and as you said, @jaen, the interactive development story

amonks02:01:27

I ought to try boot; lein is definitely a pain point

amonks02:01:11

@jaen: awesome! thanks!

eggsyntax03:01:46

Just noticed that (inc 3 12) returns 4 rather than an arity error. Is that a ClojureScript bug, or a reflection of some JS idiosyncrasy?

eggsyntax03:01:24

JS seems to handle extra params in the same way:

function myInc(n) { return n + 1; }
myInc (3, 17)
4
but certainly some cljs functions throw arity errors...

eggsyntax03:01:02

In the Speaking JavaScript book, I'm seeing that "JavaScript does not enforce a function’s arity: you can call it with any number of actual parameters, independent of what formal parameters have been defined...[given] more actual parameters than formal parameters, the extra parameters are ignored..." But I guess what I don't understand is whether there's a clear convention for when ClojureScript will throw an arity error and when it simply passes off to JS (in which case apparently there will never be an arity error).

chrisoakman03:01:02

I could be wrong about this, but I think CLJS just shows a compiler WARNING when it detects an arity error. As you referenced, the underlying JS will never complain when that happens at runtime.

eggsyntax03:01:34

@chrisoakman: I guess you're right. eg:

cljs.user=> (reduce + 0 '(0 1 2) :extra)
WARNING: Wrong number of args (4) passed to cljs.core/reduce at line 1
Invalid arity: 4
	 cljs$core$reduce (cljs/core.cljs:2147:1)

eggsyntax03:01:43

Still, no warning on (inc 3 12). So I'm still not sure whether there's a definitive cljs convention or whether it’s just a matter of how each function happens to be implemented.

eggsyntax04:01:40

Interestingly, if I define my own inc function, it throws a warning:

cljs.user=> (defn my-inc [x] (cljs.core/+ x 1))
#'cljs.user/my-inc
cljs.user=> (my-inc 3 12)
WARNING: Wrong number of args (2) passed to cljs.user/my-inc at line 1
4
but cljs.core/inc, which seems to be defined the same way, does not. I’m not sure why they behave differently. cljs.core:
(defn inc
  "Returns a number one greater than num."
  [x] (cljs.core/+ x 1))

mfikes06:01:26

@eggsyntax: There’s something odd with bootstrapped macros like inc as compared to if-not, probably worth tracking down. (What you are describing doesn’t occur in JVM ClojureScript.)

pesterhazy13:01:30

Is there a good way to see if the JavaScript environment you're in has a DOM?

pesterhazy13:01:36

In particular in the context of working with Google Closure on iOS react-native; in boot-react-native we're shimming window.document so that won't work.

eggsyntax13:01:01

@mfikes: oh, glad you noticed this. I should have checked to see if it was Planck-specific. Thanks!

mfikes14:01:08

@eggsyntax: Yeah, you can also see it in, say, http://clojurescript.io, which is based on bootstrap as well:

cljs.user=> (if-not true)
Could not eval (if-not true) - Invalid arity: 3 at line 1  - Invalid arity: 3
cljs.user=> (inc 2 3)
3

eggsyntax14:01:42

Heh, yeah, bootstrap-specific — didn’t mean to blame Planck 😉

mfikes14:01:53

Incidentally, Planck will give you

cljs.user=> (if-not true)
Invalid arity: 1

mfikes14:01:18

Dude, Planck is flawless. 💯

mfikes14:01:19

That last difference, (arity for macros), is the difference between 1.1.170 and 1.1.228. It solved the age-old issue of doing (max) an getting an invalid arity diagnostic indicating arity 2

eggsyntax14:01:07

Cool, thanks! It’s been a good opportunity to go look at more of the cljs source code.

mfikes14:01:40

I may dig into the (inc 2 3) problem at some point—I recorded it in Planck’s issues. Maybe I can create a minimal repro, or even figure out the root cause.

gerred14:01:52

I wonder if Planck signals the start of a totally independent self-hosted clojurescript.

gerred14:01:20

as far as sentiment. I feel like we're a clojurescript version of lein away from it.

mfikes14:01:51

@gerred: you are thinking of the idea of using self-hosted ClojureScript to transpile for general targets, like the web?

gerred14:01:28

yep, and Node.

gerred14:01:41

remove the JVM dependency from the equation.

jindrichm14:01:16

Can you extend existing JS types with ClojureScript protocols? I'm getting Extending an existing JavaScript type - use a different symbol name instead of js/String e.g string.

mfikes14:01:28

yeah, if you don't use :advanced, and don't rely heavily on macros, such a transpiler is probably becoming feasible. Macros in libs makes it challenging.

dnolen14:01:01

@jindrichm: yes but not native types directly because that’s problematic

mfikes14:01:11

@jindrichm: yes, use string

dnolen14:01:22

@jindrichm: follow the advice given by the warning

gerred14:01:30

you lose a lot sadly not having the closure compiler.

gerred14:01:36

uglifier and friends doesn't quite do it

gerred14:01:47

so maybe it's not the right path.

dnolen14:01:54

@gerred: it’s certainly possible but as you say the tradeoffs are significant

gerred14:01:57

I know a lot of people, including myself at one point, have a pretty irrational response to anything that has anything to do with the JVM.

mfikes14:01:36

@jindrichm: Feedback on usefulness / accuracy of this proposed docstring change would be welcome: http://dev.clojure.org/jira/browse/CLJS-1550

dnolen14:01:43

@gerred: sure but no one involved in Clojure(Script) development is concerned about this problem at all simple_smile

mfikes14:01:47

@gerred: We are still finding bugs in corner cases with bootstrap, FWIW

gerred14:01:27

I'm thinking more along the lines of "how do we get more developers into this?!", and self-hosted probably isn't the correct answer, since they'll come JVM or not.

mfikes14:01:29

@gerred: For regular dev, JVM ClojureScript has the test of time on its side, definitely

mfikes14:01:14

@gerred: The question of JVM-less ClojureScript won’t go away, even if it is an irrational question. Hrm.

jindrichm14:01:21

@dnolen: So I need to define a custom type?

mfikes14:01:11

@jindrichm: You can use string to essentially extend js/String to a protocol

dnolen14:01:12

@gerred: as far as I can tell Clojure(Script) usage grows at a fairly healthy rate every year - not quite enough that people don’t have staffing worries - but teams and companies that adopt Clojure consistently seem quite happy about it and stick with it. Not sure any other metric matters much.

gerred14:01:56

very true.

eggsyntax14:01:55

Besides, a lot of people, including myself, have a partially rational response to anything that has anything to do with JS. If that hasn’t kept devs away, I don’t know if anything can 😉

lucien.knechtli14:01:02

tbh companies have staffing worries no matter the language

dnolen14:01:37

@jindrichm: just use string as @mfikes said

jindrichm14:01:40

@mfikes: I see, thanks!

(defprotocol Foo (bar [_]))
(extend-type string Foo (bar [_] "foobar")
(bar "") ; => "foobar"

mfikes14:01:02

It is my opinion that someone in the community that is interested in a Node-based transpiler should give it a shot. We might learn the pros and cons. Can’t hurt. Whoever does it is likely to learn a lot about how the language ticks internally, which is a lot of what drives me to mess with Planck.

gerred14:01:09

I actually came over to this side when I ceased being able to figure out what the hell was going on with ES6, Babel, Webpack, and everything else people are cobbling together into what they think a React app should be composed of/built with.

gerred14:01:32

hell, ES6/ES7 are just huge languages on their own.

dnolen14:01:00

yes we’re also not anti-JS, Closure gives us the ability to integrate ES6 etc.

gerred14:01:04

feels like a year ago I was happy with Gulp and a little React. 😉

dnolen14:01:10

so we’ve been following along and will continue to do so

gerred14:01:48

I think more what I mean is that the footprint of JS is growing at a far, far faster rate than ClojureScript's.

dnolen14:01:24

this like comparing Clojure usage to Java usage - this is non-information simple_smile

dnolen14:01:39

everything we do is going to be drop in the bucket compared to #1 and #2 languages

gerred14:01:16

was enough to make me interested enough / convinced enough to finally sit down and learn it though simple_smile

gerred14:01:26

but yeah, not useful as a basis for comparison

gerred14:01:36

it made me actually enjoy writing JS again though.

gerred14:01:08

so the personal value there is pretty massive.

jcomplex20:01:40

any good references to learn clojurescript? video tutorials would be best.

dnolen20:01:07

@jcomplex: there was an O’Reilly series fairly recently (but I haven’t seen it myself so I can’t vouch for it). One downside is that it isn’t free.

shaun-mahood20:01:21

I think you can get access to it with the 30 day trial, and Safari books also has pretty much all of the Clojure books as well.

shaun-mahood20:01:21

You can also go with http://www.purelyfunctional.tv/single-page-applications , but it's not free either - $25 / month for all his content though

dnolen20:01:54

assuming you want to take on the burden of learning Emacs at the very same time simple_smile

dnolen20:01:20

but yeah I’ve heard a lot of good things about that one too

dnolen20:01:44

would be cool to see a super beginner friendly video tutorial series using Atom & Parinfer

dnolen20:01:51

& Figwheel

shaun-mahood20:01:24

@jcomplex: If you have any specific things you really want to focus on or get stuck, the #C053AK3F9 channel is really helpful and is a great place to ask questions too (even if you think they're too basic)

jcomplex20:01:39

@dnolen I use Atom, Parinfer, & Figwheel so I guess the Safari books are my options

tord20:01:39

@jcomplex: Unfortunately, they are not books, but videos.

jcomplex20:01:55

oh videos my bad

shaun-mahood20:01:14

A lot of the concepts should apply to all editors, so once you get a little more comfortable with the basics the others might be useful as well.

dnolen20:01:37

@jcomplex: yeah I looked around not too much out there specifically for ClojureScript

tord20:01:01

I've heard good things about Modern ClojureScript: https://github.com/magomimmo/modern-cljs

jcomplex20:01:34

thanks for all the resources guys

dnolen20:01:21

@jcomplex: another approach might be to just use Clojure videos, there’s a lot more out there and lot of the concepts transfer

dnolen20:01:31

unless of course you just know you want to focus on ClojureScript

jcomplex20:01:46

just focusing on cljs

dnolen21:01:31

@jcomplex: got it, yeah definitely a lot fewer resources - hopefully that will change in the near future with all the current interest

chrisn21:01:46

I am trying to get server-side rendering working and I get "navigator is not defined". Looking at the server-side.js file, it looks like react boots up like:

var Browser = {
  isDomPresent: true,
  navigator: navigator,
  window: window,
  document: document,

chrisn21:01:06

How would this ever work?

spinningtopsofdoom21:01:23

navigator is undefined (the default value for non bound variables) so {navigator: navigator} ==` {navigator: undefined}`

jaredly21:01:26

@chrisn you can defined nodejs globals, w/ global.navigator = null etc

jaredly21:01:38

then those variable references won’t die

jaredly21:01:03

@chrisn where are you finding that code? react is very server friendly — is that an old version?

chrisn22:01:10

It took me a long time to burrow down but basically we have something including quil that is including processor.js.

chrisn22:01:41

I mis-attributed the problem; I just got something rendering with react and now I am trying to pare down our system so I can pinpoint which namespaces aren't going to work server-side.

chrisn23:01:02

If you use (defroutes (ANY "*" [] (route-fn)) is there any way to get the request url in route-fn?

seriousbug23:01:07

@chrisn I assume you are asking about compojure? If so, there is a :uri key on the requests that you can check:

(defroutes app
  (ANY "*" [] (fn [req] (ok (:uri req)))))