Hacker News new | past | comments | ask | show | jobs | submit login

I do Clojure and Clojurescript full time. Love the ideas, but we as a community need to step up our game when it comes to how easy and fun it is to get started. Setting up a Clojurescript project is even worse than "modern javascript".

The only worthwhile way is using Martin Klepsch's "Tenzing" template, but using a template is not a solution.

https://github.com/martinklepsch/tenzing

I worry about this since the power of Lisp and Clojure is how easy it is to experiment. Starting a C project is just doing a basic Makefile, a javascript project is just `npm init`.




I appreciate Racket's huge emphasis on making it easy to get started. Not relying on complicated tooling (but making it possible for advanced users to do so) makes Racket an incredible way to begin learning Lisp.

Follow along, hacker news comment reader! This only takes a second!

1. Download and install http://racket-lang.org/

2. Open Racket

3. Type the following into the top text box and click "Run":

    #lang web-server/insta
    ;; A "hello world" web server
    (define (start request)
      (response/xexpr
       '(html
         (body "Hello World"))))
4. Read about the webapp you just wrote: https://docs.racket-lang.org/continue/index.html

Everything builds off of that.

No need to putz with the command line (but you can $ racket that-file.rkt if you want to). No need to fight with Homebrew and Racket's package manager (but there is a package manager if you want it). No need to install support for your own text editor (but if you don't want to use DrRacket, you are more than welcome to Emacs-Major-Mode it up if you want).


Racket does it so well! I presume Clojure can't, because it is for good and bad tied to the JVM platform, and has to be bothered with classpaths, classes & methods and what I call "the java mindset" of crazy XML-heavy mazes.


Yes!

I've tried so many times to get started with Clojure and Clojurescript, and when I'm trying to set up the environment from scratch (because to learn it I have to understand how all pieces fit together) I just get hopelessly lost. Broken deps, files to edit to make the Emacs REPL work correctly, snippets of code I have to add here and there to create a simple project.

And last time I checked, now there's this Boot tool to learn, to choose and to understand (and to debug its stacktraces) instead of Leiningein -- ARGH.

I grok a fair share of languages but there's nothing like Clojure, ClojureScript and Javascript to make me feel like an _idiot_. I don't like that feeling.

For the love of $DEITY, language designers, learn from Go: they have an up-to-date spec, an up-to-date "Effective $LANG" document and one (1) simple, official and maintained build tool. Otherwise you're just, as we'd say in Italy, brushing dolls.


Please have a look at this video: https://www.livecoding.tv/sveri/videos/wrnL1-clojure-closp-w...

I made it to show how easy it is to get started with clj / cljs web development. It uses closp, which covers everyhting from configuration to front / backend work, migration, tests, selenium tests, template generation and so on. Also have a look at the intro: http://closp.net/pages/closp-intro/ which shows how you can get started with 5 commands in the console (given you have leiningen / jdk installed, which would be two more steps, if not).

There is also the possibility to run lein uberjar from the project and get a standalone jar with webserver and compiled clojurescript generated.

Then there is luminus which is somewhat similar and provides much of the same featureset and has a great documentation: http://luminusweb.net

Regarding boot I agree with you, its confusing to have two build tools. It adds some features that leiningen does not provide and for which there was a need. That said, the number one build tool is still leiningen.

Stacktraces are aweful, agreed too, there is no satisfying solution to it that I know.

Well, Go, does it have generics? :D


Comparing C and Makefiles and `npm init` just doesn't make any sense to me. For something in style of the former (i.e. no real dependency management) you have the ClojureScript Quick Start - download a JAR & make a build script, done. For the later I just don't see how `npm init` is any easier / different than `lein new mies easy`? And doing anything serious with Node requires reading up on a far more dizzying array of choices than the Clojure(Script) ecosystem offers.

I'm happy to hear why you believe otherwise.


This. I've trimmed down severely on my use of Clojure(Script) because setting things up for kicking off small projects is just too time consuming, and large projects I dip into use other languages.

Where it regards ClojureScript specifically, doing a simple MVP/PoC web project or a Cordova app is just way faster to get going in vanilla JavaScript.

As to Clojure, every time I have to invoke lein it feels very much like this:

https://www.youtube.com/watch?v=x_2E6nlnMPU&t=1m0s


It seems to me that setting up clojurescript project is extremely easy. Basically you need to know only one "build" system(leiningen/boot), as for javascript you would have to know at least few(broccoli/npm/bower/gulp etc). And with leiningen you can do `lein new` as well, although I prefer boot and creating my own files:

  ├── README.md
  ├── build.boot
  ├── resources
  │   ├── index.html
  ├── src
  │   └── cljs
  │       ├── sample
  │       │   ├── core.cljs
  │       └── main.cljs.edn
  └── test
      └── cljs
          └── sample
              └── core_test.cljs


As an (embedded at the moment, but I've been around) C and sometimes C++ developer, considering that tree to be "easy" just seems absurd.

I'm sure everybody knows this, but here's "hello world" on the command line using GCC in e.g. Linux:

    $ echo -e '#include <stdio.h>\nint main(void) { printf("hello, world!\\n"); return 0; }' > hello.c && gcc -o hello hello.c && ./hello
The most complicated thing here is probably the bash quoting/escaping (which explains the double backslash inside printf()'s arguments).

The above command line spawns two processes, one of which is a full C compiler, and it runs in 3 milliseconds on my embarassingly old home laptop (Core-I5 M480 at 2.7 GHz).

I'm not trying to be the old fart claiming that everything was better back in the day, but this (to me) almost makes C seem as approachable as BASIC on the old 8-bit machines, when looking at the relative complexity.


Compiling trivial programs with ClojureScript is equally trivial:

    java -cp cljs.jar clojure.main -e '(require (quote [cljs.build.api :as b])) (b/build (quote [(ns foo) (js/console.log "Hello world!")]) {:optimizations :advanced})'
But I'm not sure this is actually telling us anything.


I think comparing the compilation of a C hello world program to a web-project, with inbuilt test scaffolding, serving of generated content, communication across a network and safe multi-threading of the network stack is a little bit of a mismatch. If you build a C project with all of that in it, I think that it would be a bit more than a 1 liner, and it would take a little while longer to compile. Sure not as long as the clojure project to compile but not 3 milliseconds.


Except when you want to add a dependency. Then things will not look nearly that simple...


Boot is great. I'm not an idiot developer, and have accomplished quite a few things with code that I'm proud of. But please don't ask me how to setup nrepl with boot+cljsbuild and have the repl run in a browser or on node.

I am heavily thinking of implementing a language that is inspired by Clojure, but native to the JS land. It would use npm, Mori for data structures and browserify (if not on Node.js) under the hood for requiring libraries. Basically a transpiler from Lisp style code to JS, with better data structures.


That sounds like it would be an awesome language! I love cljs but often share the feeling that its implementation is too heavy and too far removed from JS.


But then you at least want Figwheel in there, and it's not necessarily easy to know how vastly better your life will be with it if you've never done cljs before. It would be neato with a cljs IDE for approachability. An MVP could be lein + cljs + figwheel + lein ancient, editor + webkit viewer.


I'm late to the party but since the poster only showed us the tree we don't know what else is going on in that build.boot. boot-http, boot-cljs, boot-cljs-repl, and boot-reload

Provide all the features of lein-ring, lein-figwheel, and lein-cljsbuild with a simpler setup and no clojure neccessary in a clojurescript project.

Serving compiled clojurescript, reloading cljs and css, with a browser repl, is really simple in boot. The boot tools work together better than the leiningen tools do.

If you look at the Tenzing template's build.boot, which doesn't have a lot going on, you'll see how straightforward the meat of it is, without ending up with other JVMs.

https://github.com/martinklepsch/tenzing/blob/master/resourc...

    lein new tenzing some-project
    emacs some-project/build.boot
    M-x cider-jack-in
    // switch to repl:
    (boot (dev))
    M-x cider-replicate-connection
    // switch to new repl
    (start-repl)
That's it. The first repl gives you feedback on the dev server and reloading. The second repl gives you a browser repl. Cider has also levelled up, such that when the browser repl connects it gets picked up by nrepl and just works. All of this with one JVM... and no Clojure sources in your ClojureScript only application.

I stress again that the template really doesn't do a heck of a lot and the build.boot, the filesystem layout, and the way boot works is really the whole of the story. I wish Boot were better documented/marketted, so I could've switched to it long ago.


That looks very hard like it's trying to be a Maven project.


It only looks scary until you devote to setting up a project by hands a day or two, learning lots of useful things on the way.


Also fix clojure startup time please. I want to be able to run it like fast Unix style commands such as ls and grep.


I think you're missing the point if you want this. Boot once, leave running, swap in new code, interact. A clj process (like most lisps) is alive and dynamic in more ways than you might be used to. There's no need to be constantly booting it.


Try Planck if you're on OS X: https://github.com/mfikes/planck


Thanks, but i also need my applications to be portable :S


Alright, how about running it on Node then? I assume this is mostly for scripting, as long running servers and the like wouldn't need to be concerned with start-up times.


That might be a solution, yes. But Node is a single-threaded engine, so I'm not sure if I can run parts of Clojure which use multiple threads, or if there are other restrictions.


Anything that uses the JVM will never (at least for a long time) achieve the startup time of cpython, cruby or node, less of ls and grep, so don't get your hopes up :) - that said, most of clojure's startup problems lie in clojure itself and not the JVM.


On modern hardware Clojure starts in under a second. I write simple support scripts in Clojure all the time.


lein figwheel new? lein devcards new?

Depending on your definition of experiment I think Clojure has a MUCH better story for getting to a good beginner setup with live reloading than webpack/react




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: