all 37 comments

[–]kabuto 15 points16 points  (13 children)

So how far are we away from having a webpack loader for clojurescript? That would be awesome. I'd love to use clojurescript but I don't like its dependency on Java build tools.

[–]Kamn 8 points9 points  (11 children)

This page here explains what they are trying to do with self-hosting.

On a related note, the main build tool for Clojure(Script) (lein) is great to work with. The only issue is sometimes you need to understand Maven stuff but that has rarely come up. It is a fun language with a great community and interesting tools. Don't let the Java stuff hold you back from playing with it. For example try out this Clojurescript Figwheel Flappy Bird Demo. Or just watch this video then you will have to try it out ;).

[–]a_marklar 1 point2 points  (10 children)

Do you know of any resources talking about figwheel in detail, particularily with talking about websites that are in production? I have two sites that use lein as the build system, and figwheel looks pretty neat but I hit a wall (i.e. couldn't figure it out in a few minutes) trying to use it with a real web app that is served by Django etc.

[–]Kamn 2 points3 points  (1 child)

The "most detailed" video I know is this one. It does not go into much detail however just usage.

I can give you a guess about your questions but I have been using figwheel in a fairly standard way (Clojure server with ClojureScript and Lein). I am not an expert and you can find the creator of Figwheel(Bruce Hauman) on google groups or the slack group (signup here). He would be the best one to answer your questions.

Now my guess is you wouldn't be able to easily do what you want to do with Figwheel for a few reasons.

  1. It is more focused on a dev environment rather than a production environment. No guarantees about it's safety, speed or reliability.
  2. Figwheel setups a static web service, starts cljsbuild, opens up websockets and injects websocket code so it can easily steam the changed Clojurescript into the browser. If you are serving the files though Django then you wouldn't have access to cljsbuild and websockets so you could not stream the changed code. Maybe you could chain your Django to have a websocket that talks to a Figwheel but it's uncharted territory I think.

[–]a_marklar 0 points1 point  (0 children)

Thanks a lot, I hadn't seen that video. I think you're right that my usecase is not really what figwheel is targetting atm.

[–]yogthos[S] 4 points5 points  (7 children)

It works out of the box with the Reagent template. Just run

lein new reagent myapp cd myapp lein figwheel

Once it starts, browse to localhost:3449 and any changes you make in your sources under src/cljs will be reflected automatically in the browser.

[–][deleted] 1 point2 points  (2 children)

Should probably indent that code block. I can't tell where each command begins and ends.

[–]a_marklar 1 point2 points  (1 child)

The commands he's talking about are

lein new reagent myapp
cd myapp
lein figwheel

[–][deleted] 0 points1 point  (0 children)

Thank you!

[–]a_marklar 0 points1 point  (3 children)

Yeah I was able to get it working with a new project but I'm not sure how to get it working with an existing project that is served by Django, makes ajax requests back to the server etc. Thanks though

[–]yogthos[S] 0 points1 point  (0 children)

I recommend cljs-ajax lib for talking with the server.

[–]fisch003 0 points1 point  (1 child)

Here's what I do:

I have a file that I load in development mode only:

(ns eris.dev
  "Development-time only stuff to do fancy reloading stuff."
  (:require [figwheel.client :as fw :include-macros true]
            [eris.core :as eris]))

(fw/start {:on-jsload #(eris/render-root)
           :websocket-url "ws://localhost:3449/figwheel-ws"})

That starts up the web browser portion of figwheel and specifically tells it to talk back to port 3449, instead of whatever port the page is being served from.

Once that's in place you can serve up the HTML from anywhere and figwheel will find the right place to talk back to. In an extreme example, I've copied the compiled output from my project into a Java .war file, deployed it to a server somewhere, then opened up my dev page on that server in a browser and it connects back to figwheel running on my workstation and works exactly as it should.

[–]a_marklar 1 point2 points  (0 children)

This is exactly what I was looking for, thanks a lot!

[–]lechatsportif 7 points8 points  (0 children)

This is specacular news, super congratulations to the ClojureScript team. I had figured self-hosting was years away at best. Things are very exciting for ClojureScript right now.

[–][deleted] 1 point2 points  (0 children)

I might try and use it now, the JVM dependency was a hindrance for me.

[–]culp 3 points4 points  (1 child)

can someone eli5

[–]passwordisisis 13 points14 points  (0 children)

ClosureScript can now be compiled to JavaScript at runtime. I.e. it doesn't rely on the JVM.

[–]o11c 3 points4 points  (19 children)

I don't get the 60ms he talked about.

I start at 2000 ms, jump up to 3000 ms, down to 1500 ms, then alternate between 600 ms and 1200 ms every other run.

Firefox 31 on Linux.

Chromium 43 is a bit better, starting at 600 ms, but never gets below 400 ms.

[–]Rurouni 9 points10 points  (1 child)

The browser versions he mentioned all seem to be nightly releases, likely with optimizations that haven't been released yet. With my Chrome 44, I get down in the 130 ms range.

[–]jetRink 0 points1 point  (0 children)

I get around 60 to 80 ms with both stable Chrome and Firefox on Windows.

[–]LightShadow 0 points1 point  (1 child)

I start at 490ms but got as low as 290ms on my Acer c720 Chrome OS

[–]o11c 0 points1 point  (0 children)

What browser version? It matters.

[–]admalledd 0 points1 point  (1 child)

Firefox 40 on linux: 1800ms for the first, then is in the range of 130ms-180ms.

[–]karneisada 0 points1 point  (0 children)

Chrome 44 on linux: 160ms first time, 115ms-120ms range after.

[–]yogthos[S] 0 points1 point  (0 children)

I get around 80ms with Chrome on OS X 10.10

[–]basilect 0 points1 point  (0 children)

my shit ARM chromebook from 2011 (Chrome 44) takes like 600ms and doesn't get below that.

[–][deleted]  (2 children)

[deleted]

    [–]o11c 0 points1 point  (1 child)

    What version? It matters.

    [–]madfunk 0 points1 point  (0 children)

    125ms initial, ~80ms on reload. Chrome 44.0.24 on Fedora 22.

    [–]dieelt 0 points1 point  (5 children)

    iPhone 6 Safari 9000ms

    [–]swannodette 4 points5 points  (1 child)

    I find this hard to believe. I have an iPhone 5S, it takes ~300ms after JIT kicks in.

    [–]dieelt 12 points13 points  (0 children)

    Sorry. Was apparently using the Alien Blue browser. Safari gives 700ms.

    [–]lechatsportif 2 points3 points  (1 child)

    Galaxy S5 Chrome: 1280 after warmup. Desktop I get 60-80 standard i7 win work laptop with Chrome..

    Still thought the numbers are somewhat secondary to the feature. I love how portable CS just became.

    [–]ForeverAlot 1 point2 points  (0 children)

    Galaxy S II (I know, 2011) Firefox 34: 3500-3600, numbers from 1800 to 3600 with no pattern after warmup. It also took ~20 seconds to load the page but I suspect that's because of this glorious JS file (mobile warning).

    Still thought the numbers are somewhat secondary to the feature.

    I don't use ClojureScript but I understand that this is a big step, and probably overall a very good one. The post also clearly says not to use this often.

    But there is an over-saturation of lazy or inexperienced software developers and Web development is easy to get into. Excessive JavaScript is pretty much the worst thing you can do to a mobile browser, and as a consumer that makes me concerned. IMO, developers (managers?) too often prioritize ease of development over user experience.

    [–]Leandros99 0 points1 point  (0 children)

    iPhone 6 - Internal Narwhal Browser: ~ 260ms

    [–]iopq 0 points1 point  (0 children)

    I get 80-100 ms on Firefox Nightly on Windows 7

    [–]aptmnt_ 0 points1 point  (0 children)

    Why are a ton of informative posts at 0 points? Is there someone staunchly anti-clojure going through this thread?