Fork me on GitHub
#clojurescript
<
2016-09-20
>
stbgz02:09:59

hey all so I have been thinking in starting to slowly port leningen from the jvm to a node based implementation

stbgz02:09:28

do people think that would be useful?

rauh08:09:22

@stbgz I'd hate to have to deal with NPM and the dozen of node versions out there. It's much more of a pain IMO than Java/Maven.

artur09:09:02

I'm using cljs-http.client to make a GET request. Is there a way to read custom repsonse headers?

artur09:09:32

in the response's :headers they are not accessible but my browser says the response headers do exist

yury.solovyov10:09:25

If I target electron env, where es5 and 6 are fully implemented, would setting language-out to es5-strict have any effect? or cljs only generates es3 and nothing more?

yury.solovyov10:09:17

I guess it would at least add strict mode pragma

dnolen11:09:03

@yury.solovyov we only generate es3, not sure what effect language-out really has

yury.solovyov11:09:33

I guess there is nothing that useful in es5 for cljs anyway. rest params are es6 thing for example

dnolen11:09:57

right there’s not much interest in ES6 for ClojureScript as far as language features

dnolen11:09:17

there’s also no perf advantage for generating that kind of the code - all VMs have heavily optimized ES3, not 6

yury.solovyov11:09:52

yup, you can do most stuff with conditionals, loops and functions anyway

dnolen11:09:29

the primary interest in ES6 would be consumption of libraries - not code gen

yury.solovyov11:09:10

yeah, looking at rollup in js world es6 modules looks like a better thing to consume over commonjs / umd

yury.solovyov11:09:38

I guess it has more guarantees

plexus13:09:58

something I came across yesterday: I compiled D3 to a single ES6 file with rollup, then used that with :module-type :es6. D3 defines a namespace method, which resulted in a JSC_PARSE_ERROR, it seemed to imply namespace is a reserved keyword

plexus13:09:57

I tried to google for this but it doesn't seem like namespace is a reserved keyword in JS at all. Closure docs also didn't yield anything. Any clue where this comes from?

plexus13:09:56

I renamed the function, after that it worked. Advanced optimizations did cause a lot of warnings and resulted in broken code, but I thought it was still cool 😆

plexus13:09:34

For the curious: here's demo code of all the ways I could think of to load a JS lib from CLJS https://github.com/lambdaisland/thirdpartyjs

anmonteiro13:09:43

@plexus that’s really awesome for reference. I think it would be a very nice addition to the ClojureScript Wiki / Website

plexus14:09:37

@anmonteiro that makes sense. I need to focus now on getting this next episode out, but I'll see if I can contribute some documentation

anmonteiro14:09:08

looking forward!

Pablo Fernandez14:09:21

Is there a way to test if ClojureScript is being compiled at the moment? Or if there are any ClojureScript files due for compilation?

dnolen14:09:12

@pupeno no to the first question. 2nd question - any source file that has a more recent timestamp than the corresponding compiled file in the output directory will be recompiled

anmonteiro15:09:57

@jetzajac ClojureScript doesn’t take pull requests

anmonteiro15:09:39

@jetzajac there’s also #cljs-dev if you wanna discuss something related to ClojureScript development

jetzajac15:09:57

oh I see, thank you

stbgz15:09:50

@pesterhazy well the idea is to start moving tools to a less jvm centric world but keep all the niceties like project.clj @rauh, but I am also not 100% there is a lot of value in doing that

pesterhazy15:09:01

I think you'll find most people in cljs land are hapy in their JVM environment

pesterhazy15:09:18

Unless there are things you want to do which absolutely need to be done from node, I'm skeptical if a cljs-based build tool based on node would gather much momentum

dnolen16:09:25

@stbgz I’m sure that would be of use to some people, but I think not so much for the existing user base

stbgz16:09:41

@dnolen yeah I can see that, following up on that, david what do you think the story for OS interop should be for cljs, in clj world you have a clear answer, but in cljs I’ve been rolling my own, I can see having IO wrappers(http://clojure.io) useful

dnolen16:09:25

there is no story and there is likely not to be any time soon - it’s been discussed before

dnolen16:09:38

tldr; the JS I/O is async, JVM isn't

dnolen16:09:49

writing incompatible APIs just doesn’t make much sense

dnolen16:09:26

and because of interop it’s no big deal anyway for real applications

dnolen16:09:37

just shim to whatever, Node.js, Objective-C, Nashorn

yury.solovyov16:09:43

doesn't JVM has nio ?

dnolen16:09:04

@yury.solovyov having something and it being the default/idiomatic are two different things

yury.solovyov16:09:21

yeah, that's valid point

yury.solovyov16:09:35

more, it is even harder to do cause cljs can run both on node and browser, which makes it even harder

dnolen16:09:23

@yury.solovyov it’s why we don’t bother, I/O is going to mean something different in every JS environment

dnolen16:09:47

prioritizing Node.js over other cases is not going to happen - yet

alpheus17:09:39

Is there a write-up somewhere about the Clojurescript compilation process? Macros in cljs are a little confusing w.r.t. when evaluation happens. Would be nice to read an overview.

alpheus17:09:58

Some of my macros access the network to get information that's not static

dnolen17:09:48

@alpheus you don’t need to understand the compilation process to under stand CLJS macros

dnolen17:09:57

they are compile time only macros

dnolen17:09:10

you can access nothing from runtime

dnolen17:09:57

that doesn’t mean you cannot use I/O to generate code or whatever

dnolen17:09:07

but that’s going to happen in Clojure not ClojureScript

alpheus17:09:34

That's all understood, but the compilation seems to happen one more time than I'd expect. I don't want to bother people with vague descriptions at this point but it would help me to have a better picture of compilation.

dnolen17:09:45

in the REPL that’s possible

dnolen17:09:55

until recently macroexpansion could happen twice

dnolen17:09:05

but that’s been fixed as far as I know

alpheus17:09:35

We're using 1.9.216

dnolen17:09:57

we also analyze fn bodies twice for optimization reasons, so maybe that’s it

dnolen17:09:17

if macro-expansion isn’t idempotent then yeah you might have problems

alpheus17:09:24

It may not be idempotent if run on different days, but twice during a single compilation isn't a problem. Evaluating just once would speed up startup time, which wouldn't be so bad.

dnolen17:09:34

someone could write an optimization pass on the AST to avoid the second macro-expansion

dnolen17:09:40

happy to take a patch for that of courese

alpheus17:09:15

Thanks for your help. I may ask better questions later when I have a better understanding.

alpheus17:09:31

I'm used to Common Lisp's eval-when which gives pretty fine-grained control

dnolen17:09:00

right Clojure doesn’t have that, probably won’t get it either

smw20:09:34

I think planck-flavored-clojurescript has real potential as systems scripting language in ways that clojure-on-jvm doesn’t, for instance. Instant startup, lack of jvm dependency, etc.

smw20:09:26

could possibly be worth standardizing on os level io, etc before it just becomes a de facto standard?

smw21:09:35

After dealing a lot with the mess that happens in the salt/ansible world due to yaml not being a real programming language, I’ve been desperately wanting clojure for that space.

dnolen21:09:49

planck is still relatively new - best course of action is “let’s wait and see ..."

spieden22:09:59

anyone know what to check when cljsbuild with advanced optimizations doesn’t output any code?

spieden22:09:25

the dev build works fine and I have ^:export and a \:main

spieden22:09:12

all my foreign libs end up in the app.js but for the compiled code I believe there’s just

;(function(){

})();

dnolen22:09:44

@spieden need more information, are you using 1.9.229

spieden22:09:21

i’ll try downgrading to the version of one of my working projects real quick

spieden22:09:38

hmm, didn’t help

spieden23:09:42

@dnolen .. aaand it fixed itself. i overwrote my project.clj with a working one and slowly evolved it back to the original state. never stopped working again 👺

spieden23:09:29

actually i spoke too soon: somehow going from [devcards “0.2.0-8”] -> [devcards "0.2.1-7”] causes it!

cfleming23:09:16

@dnolen Question about clojure.* -> cljs.* namespace mapping. The tricky case is requires for macro namespaces for clojure.test, since that will be on the classpath from Clojure.

cfleming23:09:03

I’m assuming that if the user :requires clojure.test, then for macros that will be mapped to cljs.test because clojure.test does not exist in cljs, and implicit macro sugar is in play for cljs.test, i.e. cljs.test in cljs uses :require-macros for the clj equivalent.

cfleming23:09:43

I’m also assuming that if the user just uses :require-macros clojure.test then they will get clojure.test from Clojure itself, which is probably not what they want.

cfleming23:09:47

Is that correct?

anmonteiro23:09:49

@cfleming from a quick test it looks like that’s correct

dnolen23:09:45

@cfleming if they do that that is what they want

dnolen23:09:25

but we’re really talking about two different things here at the same time, and the interaction between the two

dnolen23:09:51

a) macro nses and runtime nses can be linked by the library author so they come together as one require

dnolen23:09:14

b) clojure core namespaces get aliased (with some tweaks to make sure that a) works)

dnolen23:09:43

@cfleming I’m also not fully sure what you are asking