8 ms·
ClojureScript 1.10.741
- bgorman 6y agoIf Clojurescript can actually work with Webpack and external modules under advanced compilation that is pretty amazing progress. Probably the biggest improvement in half a decade.
- dkersten 6y agoCan’t shadow-cljs already do that, or?
- swannodette 6y agoYep. But having this feature only in shadow-cljs doesn't do much for the ecosystem as a whole since non-portable. With this change, many tools, cljsbuild, Figwheel, etc. have the same capabilities. It also opens the door for creating ClojureScript libraries that depend on node_modules and these can again be consumed with any tool.
- tekacs 6y agoThank you so much for all of your work on ClojureScript, @swannodette! I love the work that's been done on shadow-cljs (and the maintainer is amazing) -- I've had a vastly easier and more stable time than with JS bundlers. That said, in building a business on top of Clojure(Script), it's incredibly reassuring to know that shadow isn't a single point of failure. This feature will make integrating/selling ClojureScript into existing projects easier too -- I only wish that I'd had this when moving from company to company a few years ago -- I'd have brought ClojureScript to a number of places. :)
- yomly 6y ago@swannodette In the library case does the cljs built library need a clojure runtime bundled? Or does banning eval and running it through Closure allow for only the bare minimum to be pulled through?
- dkersten 6y agoThanks David, that sounds pretty great!
- christophilus 6y agoJust wanted to pile on the thanks, too. CLJS spoiled me for just about any other way of doing front end work.
- piercebot 6y agoUnless I'm misunderstanding the ClojureScript team posts, one of the motivations for tight webpack integration is that not every npm module is compatible with advanced compilation. From the article[0]: > But after nearly three years since we first shipped Node module processing via Closure, it’s apparent that too few of the most popular libraries can be subjected to advanced optimizations. While we still believe there’s promise here, the ClojureScript community will have to show the rest of the world the way by developing compelling JavaScript libraries that can be readily consumed by popular JavaScript tools, yet still be subjected to Closure’s phenomenal tree shaking and code splitting when building with ClojureScript. 0: https://clojurescript.org/news/2020-04-24-bundle-target https://clojurescript.org/news/2020-04-24-bundle-target
- christophilus 6y agoIs this likely? Clojurescript comes with a pretty big base bundle size due to the runtime, right? Like hello world is still over 100kb or something before gzip, right? (On my phone, so it’s hard to google the exact number.)
- john-shaffer 6y agoThat was a bug. It was fixed with this release, and swannodette added a test to ensure the size stays under 10k bytes: https://github.com/clojure/clojurescript/commit/5d64c2a142e5b41a4e4390f563d4412502704e23 https://github.com/clojure/clojurescript/commit/5d64c2a142e5...
- christophilus 6y agoSwank! That’s a massive improvement. I’m going to spin up a Preact project and see how it fares.
- drcode 6y agoThis link explains the new Webpack support in more detail: https://clojurescript.org/news/2020-04-24-bundle-target https://clojurescript.org/news/2020-04-24-bundle-target Though that post is pretty good, I wish someone could create a more ELI5 version of the post for people who aren't knee-deep in javascript packaging systems. Can someone just answer some newb questions for me? 1. I know there's a website where people store javascript packages in "npm" which can be viewed here: https://www.npmjs.com/package/browse https://www.npmjs.com/package/browse. Does this new clojurescript functionality let me USE all those packages in clojurescript? What are the precise limitations? In what cases do I still want to use cljsjs? (another thing that is confusing to me, tbh) 2. Does this new clojurescript functionality let me CREATE new npm packages and put them on the main npm site? What is "webpack" exactly and how does it relate to npm? If so, what are the precise limitations? I swear I know a fair amount of stuff on other programming subjects, I just have a blind spot when it comes to javascript packaging and packages, so this info is really appreciated!
- swannodette 6y ago1. NPM is analogous to Maven for Java. Yes the ClojureScript bundler target lets you use anything you've installed from NPM into your project's `node_modules` directory. Not many limitations because we wash our hands of dealing with this stuff - use whatever popular bundler solution you prefer. 2. Not for creating NPM packages, just consuming them. Webpack lets you use dependencies from NPM and package them up into a single JS (or code-split) asset to be used on a webpage. Note, we have no integration to any particular bundler. You could just as easily run Metro for React Native on the output and build a mobile app.
- namelosw 6y agoDoes this enable the possibility of having ClojureScript loaders for Webpack? Shadow-cljs is great, but from time to time, it seems to be easier to integrate with the ecosystem if it can be loaded as Webpack modules. For example, loading arbitrary image, file, and possibly Rust modules, etc.
- swannodette 6y agoHonestly not sure, I'm not a Webpack expert and have no wish to be :) But again, as I've said elsewhere, there is no specific integration with Webpack. The bundle feature makes no choices so it's easier for users to fully control the integration with any JS build tool.
- namelosw 6y agoThank you for your response! ClojureScript is by far the best target-to-browser solution I have used. The REPL experience is stunning, macros work as expected, and Cljc compilation is seamless. Working with it is pure joy. Thanks again for everything you did for ClojureScript, and your talks are also really inspiring!
- jiyinyiyong 6y agoProbably not. I'm not an expert either but have some basic experience on transforming my own [script](https://github.com/Cirru/cirru-script-loader https://github.com/Cirru/cirru-script-loader) with a loader of webpack. Normally Webpack loader transforms a single file to another file, like CoffeeScript to JavaScript, mapping one to one. So when it's processing a single file, the loader probably has no knowledge on other files. When it's importing another module, it's Webpack detecting there's a `require` or `import` and revolsing that file. This solution is not working for ClojureScript. I thought it was thheller told me that ClojureScript has macros, it's not just transforming files one by one, which is not how I was taught to write a loader... There might be some solution but could be tricky. At least we still need a ClojureScript provided by JVM, which is already a lot more sophistached than a normal Webpack loader. (I was told WISP has macros like Clojure but transforms with Webpack loader. Didn't investigate into that: https://github.com/girvo/wisp-loader/blob/master/index.js#L14 https://github.com/girvo/wisp-loader/blob/master/index.js#L1...) .
- deleted 6y ago[deleted]
- rhlsthrm 6y agoI've been really thinking about using a functional language that complies to JS to start to learn more FP concepts and paradigms. I'm trying to decide if ClojureScript or ReasonML is better for me. Anyone have experience with both?
- enricozb 6y agoBoth are beautiful in their own ways. I think ReasonML, or even SML or OCaml might be a gentler introduction since they let you write imperative code (more closely to what you probably write already) whenever you need to. For example, I think there is a gradient from OCaml > Clojure > Haskell about using mutable data structures in your code, from Encourage > Discourage > Disallow. I think learning Haskell as your first FP might turn you off given how strict it is in this regard. So using that as a line of reasoning, using OCaml or ReasonML might be best since it lends an imperative hand whenever you need it, and lets you explore all of the amazing things FP has to offer.
- yomly 6y agoAs a counterpoint, Clojure is considerably more permissive because it is dynamically typed: CLJS has some warts due to the compiled JS being hard to understand (use source-maps) and the Clojure error messages being bad is now a meme but if you've not dealt with a Hindley Milner type system before, Clojure can help you learn some of the other basic FP concepts in a more gentle way. I think it comes down to what you want to learn from FP and where you're coming from: If you want to just "build stuff" and make it "more functional" ie using lots of data/values and passing around functions maybe go with Clojure. If you're interested in how static types can make things easier to build more robust things but you only want to dip your toes into FP go with OCaml/Reason If you want to see what it means to program 100% pure and have no side-effects (and you're willing to invest in learning and delaying instantly "shipping" something) go with Haskell/Purescript
- deleted 6y ago[deleted]
- draven 6y ago
- jwr 6y agoTo the entire ClojureScript team: thank you so much for all the great work that you are putting into ClojureScript! Without ClojureScript and Clojure, I would not have been able to build and maintain my SaaS app as a solo founder. The incidental complexity would have crushed me. Using a single language to write code, with model (domain) code effortlessly and fluidly shared or moved between "server-side" and "client-side" is a game-changer. While I don't care that much about NPM, I am extremely happy with the progress that ClojureScript is making. Thank you!
- uxcolumbo 6y agoI like reading these kind of stories. I'm trying to learn more about Clojure / CLJS for web development specifically, but there are so many different tools to pick from and as a beginner it can be hard to know where to start. And then I'm also reading about Phoenix (Elixir) and how that's better for web dev. If you don't mind - can you tell a bit more about your Clojure story, when you started using it and your setup? Or maybe you have a blog, where you wrote about this already? I'm not an experienced programmer, hence the naive questions.
- NhanH 6y agoThe Clojure way of doing things is mostly about composing different libraries for your needs. You will have a lot of small tools to work with, and comparing to Phoenix, doing even the easy things take more effort to write code. Phoenix gives you a full framework, bells whistles and all, but you have to work within the constraint of the framework. If you are an inexperienced programmer, you might want to just stick to Rails or Django, tooling and standard are easier to learn from those frameworks, and their shortcoming aren't visible to you anyways. If you just want to learn programming for fun, or at the start of your path trying to be the best programmer as you can be, Clojure is a valid option, but there will be a lot of head banging around the code. Tldr; clojure = more exotic, weird but great features, you should be comfortable rolling things on your own, elixir/phoenix = more exotic rails, stick to rails if you just want to make a website.
- 6y ago
- tartoran 6y agoReading about cljs I ended up watching some videos on youtube. I for one didn’t know cljs is so fun: https://m.youtube.com/watch?v=VbIawuoYAVY https://m.youtube.com/watch?v=VbIawuoYAVY
- manishsharan 6y agoSomebody please write a book on Clojurescript, reframe and tooling -- its about time. There are so many books on Clojure but very few on Clojurescript and most of the existing Clojurescript books are too old and have not kept up. I prefer learning new languages by reading books about them.
- simongray 6y agoWeb Development with Clojure (3rd edition) comes out later this year. It's got both Clojure and ClojureScript in it. In fact, even Clojure books that aren't focused on web development tend to have a ClojureScript section in them. ClojureScript Unraveled is being updated continuously and is available for free online: https://funcool.github.io/clojurescript-unraveled/ https://funcool.github.io/clojurescript-unraveled/ But honestly, you can use Clojure books to learn ClojureScript too. They're basically the same language, with a few minor differences based on underlying differences in the hosts (JS and JVM). I tend to write most of my code in CLJC style, which can be compiled for either platforms.
- manishsharan 6y agoThe complexity with Clojurescript is in the tooling ecosystem. With Clojure , you only have the repl. However, with clojurescript, your have figwheel, shadocljs etc etc. I gave up on setting that up correctly with my IDE( Visual Studio).
- simongray 6y agoShadow CLJS is very easy to set up and there's a whole book's worth of documentation: https://shadow-cljs.github.io/docs/UsersGuide.html https://shadow-cljs.github.io/docs/UsersGuide.html You don't need figwheel (or any other tool) if you just want to write ClojureScript. You can get a ClojureScript browser REPL like this (mac example): brew install node npm install -g shadow-cljs shadow-cljs browser-repl I get that it's going to be hard if you want to integrate stuff into an IDE that doesn't support ClojureScript. I use IntelliJ with the Cursive plugin (free version) and use `deps.edn` for dependencies since it's supported directly in Cursive.
- christophilus 6y agoHow’s the bundle size coming along? Also, I’m curious what back end most of you are using? Node with CLJS, Clojure with???, Elixir, etc? I’m spinning up a small side project, and started it out with vanilla JS and Node. Bundle sizes are tiny, startup times are fast, lots of concurrent connections, etc... But I really don’t enjoy the ecosystem or language, so am probably going to port it over to Clojure. Clojure has spoiled me. :/
- orestis 6y agoClojureScript has a baseline which you cannot go under. Can’t remember the exact number but it’s something like 250k (advanced compilation but not gzipped). For this you get the immutable data structures, and a decent chunk of the standard library, which you would use anyway. On top of that, everything else that you get from the ClojureScript ecosystem, which is run through the Google Closure Compiler, is added incrementally. Use only one function, pay only for one (and its dependencies).
- deleted 6y ago[deleted]
- solbloch 6y agoI believe this is fixed [0]. [0]: https://github.com/clojure/clojurescript/commit/5d64c2a142e5b41a4e4390f563d4412502704e23 https://github.com/clojure/clojurescript/commit/5d64c2a142e5...
- orestis 6y agoWell, sure, for hello world! But these days anything you do with CLJS will involve the data structures, which is what brings in the dependencies :)
- didibus 6y agoBundle sizes have never been an issue for me. You're not really supposed to use ClojureScript for trivial JavaScript. So for anything non-trivial, bundle size of ClojureScript and pure JavaScript start to even out. Backend is Clojure off course , though ClojureScript on the backend is starting to shape up as well, in case you're already familiar with the Node standard library and ecosystem. It can be a good alternative. If you intend to only have trivial JS mixer in with your HTML, then better to go for a pure Clojure server side rendering with a few embedded JS snippets. Similar to what you'd do if using Ruby on Rails or Django.
- ethagnawl 6y agoThis is an exciting release. Congrats to the team for their continued efforts and for being such great stewards of the language and ecosystem. I did have one (orthogonal) issue when following along with the tutorial linked in the release notes and, since there's a decent chance someone here has worked through this same issue in the last few days, I'd like to float the question: Does anyone know of step-by-step instructions for getting fireplace.vim to evaluate ClojureScript code?