This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-24
Channels
- # beginners (108)
- # boot (16)
- # bristol-clojurians (1)
- # cider (20)
- # cljs-dev (167)
- # clojure (64)
- # clojure-greece (4)
- # clojure-hamburg (1)
- # clojure-russia (1)
- # clojure-uk (27)
- # clojurescript (235)
- # datomic (1)
- # devops (2)
- # fulcro (80)
- # graphql (6)
- # heroku (2)
- # jobs-discuss (1)
- # jobs-rus (2)
- # lein-figwheel (1)
- # lumo (2)
- # nyc (1)
- # off-topic (22)
- # portkey (4)
- # re-frame (44)
- # reagent (39)
- # ring-swagger (9)
- # shadow-cljs (90)
- # tools-deps (5)
- # vim (8)
- # yada (2)
On application projects directories also affects which files are included in uberjar. Cljs files aren't necessary as it is already compiled into JS.
Hey, I'm trying to set up a remote nodejs repl following https://github.com/clojure/clojurescript/wiki/Remote-REPL but it fails with:TypeError: Cannot read property 'nameToPath' of undefined
file sync seems to be working fine but I don't see /tmp/cljs-repl-share/out
I also found this issue https://dev.clojure.org/jira/browse/CLJS-1933
@john I don’t think it’s idiomatic to intermingle @juhoteperi point is right on
Clojurescript compiler doesn’t really intermingle that much, so not evidence that this is a idiomatic pattern
Hey guys, could you comment on this suggestion: https://dev.clojure.org/jira/browse/CLJS-2376?focusedCommentId=48829#comment-48829 What do you think about metadata in ns form? Could it potentially break something?
I’ve always intermingled clj cljc and cljs. I don’t see the benefit of having separate directories. I just The the confusion of having to search multiple trees. Also sometimes I migrate a cljs to a cljc later (or the other way around) jumping directories with that sort of change just doesn’t make sense. If there is a compelling reason to not intermingle, it’d be great to here it. Perhaps I just haven’t seen it yet.
@juhoteperi just described a perfectly fine reason
anyways it’s a minor point - but to say intermingling is more or less idiomatic than not isn’t a supportable claim
lein has an option to exclude specified files from the uberjar, hasn't it? I agree that there's no widely accepted convention, although I don't see any reason not to intermingle, similar to mikerod
@just_crashed Yes, there are other ways to filter uberjar contents, but in those cases you have to create additional logic yourself, as you have lost the additional information the separate paths provide.
I don't see reason to intermingle as just putting files in separate paths doesn't cost anything. Editor should allow jumping between files in any path and moving files in git is easy anyway. But yes, this is minor thing.
is there anyone here who came from typescript and finally chose cljs, can you tell a story why?
If I'm working on a datomic/DB/SQL, pedestal/jetty, om/re-frame/react sort of stack, in a particular project, it's probably going to be most idiomatic to separate src/clj from src/cljs
If I'm able to write 90% of my app in cljc though, I doubt I'd go about making split directories just for the sake of having them.
But 90% of the clj/cljs work out there is probably going to involve that frontend/backend architecture
@dnolen if I was writing a cross platform lib or data structure, would you still recommend separating out clj/c from cljs by directory?
@razum2um I am not 100% here or there yet, but I’ll write my thoughts on Typescript vs ClojureScript vs Reason/Bucklescript in a thread...
I started doing proper JS just a bit after ES6 became a little bit more mainstream and Safari had 100% support. My hope was to be able to just write code and being able to reload my browser, at least during dev time. Also, the new ES6 syntax features and data structures like Map and Set made it a bit more sane.
In the end though, I wasn’t comfortable enough creating abstractions in JS. Too many sharp edges and hoops to jump through slowed me down a lot. Also, rather than slowing done until ES6 was widely adopted, it seems everyone in the JS ecosystem wanted to add even more features, muddying things up a lot. It seems nowadays there’s not even a set standard to adhere to, and features are added continuously by committees.
So I turned to Typescript as a saner target that: a) doesn’t get in my way, b) provides a stable platform to build against and c) helps me navigate the intricacies of JS by giving me a type system on top.
After using it in anger for a few months and successfully creating my own little in-house library for a simple CMS app, I was quite satisfied regarding those targets. However, I realized that TS (at least at that point in time, not sure about what’s going on now) did not have any runtime or libraries. You even had to provide your own polyfills to target older browsers.
Fast forward a few months, and I had a look again at it, and it seems that MS has adopted the “continuous change” mindset. Lots and lots and lots of changes happening over the course of months, hidden behind compiler flags, etc etc. That did not give me confidence to continue using it for new projects.
So I then turned to evaluate other languages that compile to JS. Top contenders were ReasonML and CLJS.
I really wanted to like ReasonML, but I chanced upon it just as the Reason team decided to tweak a whole lot of the syntax. Also, it seems again that there was no aim to provide a runtime/standard library. However, Bucklescript/Ocaml have the advantage of being around for some time and quite proven languages. Still, it is still very new and under active change so I didn’t want that.
The main attraction to CLJS for me was that a) it was old, 7 years out now, b) was building on an even older language, c) it was based on a robust standard library and tooling, d) it came from a community that values backwards compatibility
I have to say that I had evaluated Clojure a few years back and the syntax scared me away. For some reason this time round I stuck my teeth into it and I got over it, I even like it now :)
Do you have a look at a talk called “ClojureScript for skeptics”. It did score a lot of points for me.
I don't know, Bucklescript is a pretty stable solid compiler, it produces readable JS and the reason it doesn't have a library like the closure library (although you can use lots of ocaml stuff that makes sense in the browser) is because it was designed to embrace the npm ecosystem from the start (unlike cljs which was reinventing its own npm world with stuff like cljjs), the interop with JS ecosystem from BS is way superior, also BS is the fastest compile to JS compiler.
You are definitely right on all of those points. I had the misfortune of happening across Reason first and that might have tinted my perspective at the time a bit.
I can’t say the same for npm — I wonder what % of packages would be missing from there if JS had a better standard library, and if the drive to publish everything as a npm module wasn’t that strong in the JS community.
I think cljs made the mistake of not embracing the node/npm tooling from the start, but new tools like shadow (I haven't use it) seem to be improving things for some
I’m not sure there was much to embrace when CLJS was released though. But yes, there are efforts underway, and for compatible libraries you can even get full DCE which sounds quite compelling.
I am wondering how large is the Bucklescript/Reason community compared to CLJS. I certainly haven’t seen frameworks like om/reframe that aim to tackle harder problems than virtual dom. There’s some activity in Bucklescript-tea (elm architecture) but I haven’t tried it.
IDK, there’s certainly useful libraries there — but also a ginormous amount of crap. Also, all the transitive dependencies that you get plus the node_modules explosion make it for a really shitty experience.
sure, closure provides you with a base to build stuff but there are is so many cool JS stuff out there.
@U4R5K5M0A it wasn’t there yet
I tried rollup some time ago, and it had most of the issues CLJS is having with the npm integration, because it tries to work through all the ways JS code is published on npm. ES6 modules are sane, but still to this day it’s not widely used.
anyways we intend to play the long game, and I firmly believe our long game is superior
And on the subject of Typescript, not only you have to figure out how to bring in dependencies, but you also have to hunt down or write your own typespecs or find an outdated version online that mostly works, otherwise your program doesn’t even compile.
@just_crashed no problem :) feel free to pick some of the rest though — the bit about having to write your own .d.ts files is a huge pain, on par or even worse than figuring out closure externs.
When I finally sit down to use CLJS in anger, I will have a more rounded opinion about it. So far I’m just thinking about it :)
Another thing is that comparing ClojureScript to Elm / BuckleScript is really half-baked
when Elm / BuckleScript can do what Clojure can do then maybe you do a real comparision
because OCaml as a backend technology is not really taken seriously outside a miniscule number of companies
Again, my biggest gripe with Elm/Bucklescript is the lack of standard lib for the web. Rarely are the problems of web dev so “pure” as to be solved by just a nice type system.
and why not write in a language that transports cleanly to a reasonably successful multithreaded backend language
I know that BS can just drop down to JS code, even embeddable in the same source file, but I’ve no idea how this plays out regarding the type system.
I’m trying to think of escape hatches for a company that is invested in Node right now, but have created a ball of mud. I’m thinking of slowly introducing CLJS into the system, perhaps at crucial points. I’d have to train 2-3 developers in order to get full buy-in, so I’m thinking hard about how best to sell this whole approach.
Client is much much harder as you say, because I can’t even think how to slowly introduce CLJS in there. Doing a major rewrite of the client is much much costlier.
well we’re not going anywhere and 1.10.X release will be a good time to tell people to give CLJS a try again
@orestis re: your TS comment, in cljs you also need typespecs for external none closure lbs
I thought that even worst cases, writing your own externs is simpler than writing a typespec, since externs just deal with names while externs deal also with return types and arguments? I could be wrong.
@U4R5K5M0A sure!
@razum2um I went through a similar path as @orestis except flow type then reason the cljs. My basic issue with flow is that it added a lot of work but still wasn’t complete or reliable enough to be worth it. Hard to know if something was actually typed. Reason is still basically an internal tool that is available for the public to play with. I’m looking for something that has power in rapid prototyping and is deployable. cljs so far fits that bill now that I can reliably use the npm ecosystem
Breaking this out of that huge thread — does anyone have experience/ideas about how to introduce CLJS gradually into an existing system without having to do a big rewrite? Browser or Node.js perspectives are welcome.
the whole point of our deeper integration with Closure’s support for node_modules deps is that you could just replace your JS pipeline
Ah, I was more asking about systemic approaches, like e.g. create a small self-contained CLJS library that exposes somehow a JS API... (first thing that comes to mind). There’s a technical perspective which I think CLJS easily wins, and there’s a social perspective because it’s an “alien” technology. My hope is that as people experience it up close and see it working, they’ll be more amenable to using it in other parts of the system.
Surely though you can export a CLJS library as an opaque .js dump with some public API? I’ve used this approach with Typescript with good results.
@orestis if you have "world in an atom"-type architecture, maybe have a look at datascript, it has a js api
Ah, you mean that if say I export a “form validation” CLJS library and then a “data transformation” CLJS library, they will duplicate parts of the CLJS runtime because they wouldn’t be DCE’d together?
Gotcha — but still, you can plant a seed and keep adding functionality to that seed. It’s no worse than adding an npm dependency of similar scope.
Gotcha. Perhaps numbers will show how many X kb of npm dependencies are removed vs Y kb of CLJS/Closure dependencies gained.
you only need to convince a fraction of these people we’ve taken the concept to a higher level
So your argument is, instead of starting by writing CLJS code, start by replacing all your build pipeline with CLJS?
Wow, really? I’d never thought of that. So take an existing JS codebase, keep all the JS in and try to subsume it into a CLJS build pipeline?
Is there an example somewhere of a project having side-by-side JS and CLJS? This really piques my interest. Getting CLJS in even as a compiler tool would be fantastic, since most projects will see an immediate tangible benefit of reduced bundle size for free.
the harder case is random NPM libs - because sometimes people write unnecessarily dynamic stuff - but in many cases those are boring PRs
Of course, yes. I see that this team relies on requirejs. I’ll have to see how closure plays with that.
anyways if you want to DCE the world - the ClojureScript/Closure way is the approach you should contribute to
and given that you have the Google behemoth behind it - I know where I’m placing my own bets
speaking of ... I took a create-react-app
demo app and compiled it with shadow-cljs with basically zero changes. https://github.com/thheller/react-redux-realworld-example-app/tree/this-is-madness
@dnolen It’s true that downloads a lot of stuff, but the developer experience is not to be underestimated and the gzipped build release is 35kb. I use cra all the time to just do a quick experiment with some react thing. It is so incredibly useful.
For me it’s not Google per-se, but the history of Google Closure and the proven for year code. Lots of behemoths have produced shiny things that are forgotten now.
last time I tried create-react-app
it took 5 minutes on a 4-core machine and it generated 120mb of JavaScript
Hah, I’m building an Electron app and I can’t put it in Dropbox unzipped because of the million tiny files in node_modules 🙂
@orestis Closure isn’t very shiny and to be honest - I don’t think anyone uses it as much as we do
Well @dnolen and @thheller thank you both for your work and energy you are pouring into this, each from their own points. I hope that I will be able to contribute back one day, even by spreading the word.
@dnolen Funnily enough, I am using OpenLayers, which used to be a Closure-based library, but since have switched to ES6 modules. Not sure what the rationale behind it was, but I guess the non-shinyness of Closure played a part.
ES6 is basically a modern way of writing ClosureJS. similar rules regarding static imports and such
@orestis one problem here is that if you’re not in the ClojureScript community people don’t understand what Closure is doing
Hm, I’m curious though — they had a huge codebase full of goog.*
stuff and now it’s completely gone.
by switching to ES6 they’re making it possible for others to consume, but nothing has really changed from their perspective
Oh, sure, it’s just a weird move to make all this effort. Probably yes, it’s easier to just say “use rollup to get tree-shaking”.
Well, I have to go. Thanks for the conversation @dnolen — I’ll try to write a blog post exploring this avenue soon.
@dnolen Do you mind if I quote you in a future blog post? I like the “long game” take. Of course I can run it by you before publishing.
it’s just true, we’ve stuck by our principles over the last seven years to the varied complaints of the JS world who haven’t taken the time to understand the big picture
in the end I believe such complaints don’t matter - and surveys confirm - JS users are now 2nd behind Java
from right after the release of ClojureScript is a good reminder it’s important to give people what they actually need - and ignore what they believe they want
To help ensure easier upgrades to future versions of Closure, the ClojureScript compiler test suite is now automatically executed daily using the latest Closure Compiler and Closure Library. (See http://github.com/cljs-oss/canary)
@dnolen It’s true that downloads a lot of stuff, but the developer experience is not to be underestimated and the gzipped build release is 35kb. I use cra all the time to just do a quick experiment with some react thing. It is so incredibly useful.
Quick namespacing question. If I create a namespace foo.core, and refer funcs from other namespaces with (:require [bar.core :refer baz]) Should I be able to access baz at the repl with (foo.core/baz) ? Not working in my current repl setup.
@jrbrodie77 At the REPL you need to do (require '[bar.core :refer [baz]])
Oh, I see what you are saying. No. Referring doesn't put the var in the namespace you are in.
hey guys, which framework would you recommend for making a simple website? I've searched for a bit, Luminus and fulcro look really good
You might want to check out re-frame too, as an alternative to fulcro
they’re both good frameworks (if that’s the right term), just different approaches.