Fork me on GitHub
#clojurescript
<
2019-01-06
>
lspector01:01:23

Thanks @borkdude. Nightcode used to be fabulous and I taught with it, but recent versions, rather than supporting re-indentation, force use of parinfer. I think that all of the others in the JAXenter list are misses too. Emacs+CIDER is complicated to install and learn; Atom/Proto-REPL requires Java + leiningen or boot; Cursive is heavy weight and I think also requires that you're set up for Clojure; Counterclockwise, aside from being Java/Clojure based as well, hasn't been actively maintained for several years. I'm looking for a text editor with Clojure/script re-indentation, that could be used for Clojurescript by newbies without having to install or configure very much (and ideally not Java/leiningen/Clojure).

lilactown02:01:32

@lspector I would suggest VS Code. has decent Clojure indentation and plugins (one called “Calva”)

lilactown02:01:54

if all you want to do is do some editing with indentation and syntax highlighting, it’s pretty easy to get started

lilactown02:01:22

Calva is there when you want to jump into connecting your editor to a REPL and start doing more advanced things

lilactown02:01:22

I’m a bit confused about your Java + leiningen comments tho. that sounds like project dependencies, not editor

lspector02:01:14

Thanks @lilactown. I've been working with VS Code/Calva for Clojure work for bit now, but you need Java/Clojure/leiningen to get it to work. I'm now looking at the calva-fmt page though, and maybe one can indeed get re-indentation without installing the rest. I may need to find a machine without those other things installed to give it a try.

lilactown02:01:18

:thinking_face: I can’t imagine why you would need Java, Clojure or leiningen, unless your project needs it

lilactown02:01:27

it’s written in TypeScript/CLJS

lspector02:01:34

PS also there's currently an issue that Calva won't re-indent forms that aren't properly balanced, which is a problem

lspector02:01:46

I agree that one shouldn't need Java or leiningen for an editor! But a lot of the options assume you're writing/running Clojure and you do indeed need that stuff.

lspector02:01:14

Nightcode is a notable exception, but it forces parinfer.

lilactown02:01:35

well if you’re using an option that requires connecting to nREPL to evaluate code, then yes you will need an nREPL server. usually in your build tool, and AFAIK all of the common CLJS build tools use Java

lilactown02:01:24

I write all of my CLJS projects using either VS Code or Emacs, and all they use are shadow-cljs, which is a Java program

lilactown02:01:40

unless you’re building your code using one of the self-hosted compilers like lumo, which IMO is more advanced, your students probably need to have at least Java and Node.js installed

lspector02:01:58

My aim here is for a student with nothing related to programming on their computer initially, with as little installation as possible, to be able to follow the Quick Start instructions at https://clojurescript.org/guides/quick-start with one enhancement: in place of "your favorite editor" use an editor that supports Clojurescript re-indentation (and, actually, bracket-matching).

lspector02:01:12

Oh shoot! I'm only now realizing that those instructions require clj which means Java 😞

lilactown02:01:43

other than the bug that you encountered, I don’t see how VS Code wouldn’t fit that

lspector02:01:45

I was hoping there was a Java-free path here for someone to write and run Clojurescript

lilactown02:01:58

and yeah, almost all of the tools use Java

lilactown02:01:27

you could try using one of the self-hosted compilers… but that relies on having a JS runtime like Node.js installed

lilactown02:01:35

and is probably more advanced than you want

lspector02:01:52

Sigh. I've lost weeks at the beginnings of semesters getting Java/leiningen installed on student machines (usually it's Windows machines that are the biggest problem because I don't know Windows, but sometimes Macs have annoying problems with Java versions too). I was really hoping there was an on-ramp to Clojurescript programming that could bypass that.

lilactown02:01:28

leiningen I can see being a pain

lspector02:01:43

I've had students who failed to get leiningen running for the whole semester, which meant they could only work on our lab machines, which was a big drag

lilactown02:01:16

yeah. I’ve struggled to get lein installed on coworkers machines using Windows

lilactown02:01:47

we ended up using a slightly modified lein.bat through Cygwin ?? I don’t know, it was probably wrong but mostly worked

lilactown02:01:50

I think Java is a necessity. Clojure/Script is heavily invested in Java, you can’t get away from it IMO

lspector02:01:49

Makes sense for Clojure, but I thought we might be able to get around it for Clojurescript

lilactown02:01:13

well, you could try out one of the self-hosted compiler tools: https://github.com/anmonteiro/lumo

lspector02:01:20

I guess for working in Clojurescript, following the Quick Start page, we only need clj and not leiningen at least, right?

lilactown02:01:30

if you want to bet on Node.js vs. Java

lilactown02:01:57

right. for your macOS/Linux-using students, they’ll be able to use clj

lilactown02:01:35

for your Windows-using students, they’ll be able to download and run the cljs.jar

lspector02:01:30

huh... I'm not understanding all of this yet but I'm looking into lumo

lilactown02:01:06

the README for lumo might be a little out of date

lilactown02:01:50

it refers to some instructions: > Please reference its Quick Start and the Compiler Options. You can basically just replace the namespace with lumo.build.api on the clojurescript site that doesn’t exist anymore

lspector02:01:40

I was able to do the manual installation (the other options gave me lots of errors), and I can run it and get a cljs.user prompt. So that seems promising. But I don't yet see how to translate the stuff on the Clojurescript Quick Start page to use this.

lspector02:01:24

In other news I've just installed VS Code + Calva Clojure Formatter on my wife's machine, which doesn't have Java installed, and it runs, and goes into Clojure mode with a .clj file... but doesn't actually re-indent 😞

lilactown02:01:42

:thinking_face:

lilactown02:01:08

formatting doesn’t work at all? that’s weird

lspector02:01:53

Yeah, just stays unindented, and tab just adds spaces, regardless of the structure

lspector02:01:52

oh wait -- did a re-load of the extension and now it works!

lspector02:01:34

That's helpful. Still has Calva's problem of not working with unbalanced expressions, but this is getting somewhere: within Calva's constraints, VS Code + just the Calva formatter may be the simplest way to get some Clojure/script re-indenting behavior on a fresh/student machine.

lspector02:01:55

If I could figure out or get simple instructions for doing what it says on the Clojurescript Quick Start page but with lumo instead of clj, then I might be in business for a beginner setup that doesn't require installing Java

lilactown02:01:01

yep. VS Code is also a good editor for a lot of other languages, so it’s worth students getting familiar with it. the learning curve is much less steep than something like Emacs or IntelliJ tho

lilactown02:01:52

I’m not sure that you’ll be able to get a browser-connected REPL with lumo

lspector02:01:16

I don't think I need a browser-connected REPL for this. I'm just looking to have the code that the user writes in the editor run in the browser, like the example on the Quick Start page. Can lumo support that?

lspector03:01:06

FWIW if I could get something that did re-indenting for unbalanced expressions and bracket matching, even if it wasn't any good for any other languages or anything else, and was at least as easy to install and run as VS Code, then I'd prefer it. But VS Code/Calva is easy enough and the functionality is at least a lot better than no re-indenting at all.

lilactown03:01:48

I would suggest creating a github issue about that in the calva-fmt repo. I know that they’ve been doing a lot of new development on that recently

lilactown03:01:28

I’m sure lumo can support something like that. but my guess is that going with the status quo (install java, run the jar) will be the easier path

john03:01:55

I don't think lumo is going to support much of the cljworkflow that iirc the newer quickstart recommends.

john03:01:26

@lspector is the course content mostly about algorithms? I think https://maria.cloud could be a great educational tool, with minimal setup requirements.

lspector03:01:58

@john this would be for a couple of different kinds of courses. maria.cloud does indeed look cool, but my recollection from looking at it before is that it doesn't let you use libraries, build projects, etc.

lspector03:01:58

None of the courses would be about webdev though. They'd be on things like AI, genetic programming, ALife, etc.

lspector03:01:20

Lately I've been doing these in Clojure, mostly pure Clojure but sometimes with http://quil.info and often with AI/GP code/libraries that I provide.

lspector03:01:41

Moving to Clojurescript is attractive so that students can (I hope) easily put their running projects in web pages, and I thought also maybe avoid the setup hassles that we often have. Some of those were about Java, but maybe more were about leiningen, so if we can get by with just Java that'd be a step in the right direction

lilactown04:01:27

yeah. I do all of my personal development with the CLI tools and shadow-cljs

lilactown04:01:29

if they want to do live programming/hot-reloading with CLJS, they’ll need to use a tool like figwheel or shadow-cljs

lilactown04:01:15

shadow-cljs is practically equivalent to the combination of figwheel + CLI tools

lspector04:01:37

shadow-cljs is new to me... just checked it out and there's a lot that I don't understand, but since it requires Java too I guess I'll continue considering CLI tools as the approach

conan14:01:45

Can anyone recommend an http client library for use with node? I'm writing lambdas for AWS, and can't get kvlt or cljs-http working, as they seem to require npm dependencies, which I can't figure out how to do

conan14:01:42

full disclosure: i know very little about npm, i'm trying to learn as i go, so any help is greatly appreciated and will end up in a blog post to help others!

pesterhazy15:01:54

IMO no need to bother with cljs wrappers

pesterhazy15:01:11

They’re more trouble than they’re worth

conan15:01:20

oh that's interesting, thanks!

conan15:01:01

although ideally i'm trying to avoid using npm

pesterhazy15:01:03

You can include the node modules folder in the zip you send up to lambda

conan15:01:13

yeah, took me a long time to figure that out!

pesterhazy15:01:25

I wouldn’t try to avoid npm

conan15:01:33

can i ask a quick question - how do you know which npm dependencies you need to install for a cljs project?

pesterhazy15:01:35

Embrace the host

conan15:01:02

i've just had to go through all the errors one by one, but theres a very slow feedback loop when copying/zipping node_modules, uploading to AWS and running

pesterhazy15:01:30

you won't be able to avoid npm anyway

pesterhazy15:01:44

I don't understand the "npm dependencies" question

pesterhazy15:01:00

just add a package.json listing the requirements you need (e.g. node-fetch)

pesterhazy15:01:17

then use (def node-fetc (js/require "node-fetch")) and you're off to the races

conan15:01:54

what i mean is, how do i know what the npm dependencies of my cljs libraries are? the project i'm working on uses one library (kvlt) which has about 5 or 6 npm dependencies. but to find out what they are (so i can do an npm install on each), i have to package it all up and run it on AWS. it would be really useful to know when i add a library what its npm dependencies are

pesterhazy15:01:53

i think you must be misunderstanding something

pesterhazy15:01:20

the cljs libraries on cljsjs typically don't have any extra requirements - everything is contained in the jar

pesterhazy15:01:40

as a piece of advice i wouldn't play with non-standard cljs libraries (kvlt looks like it's unmaintained?) until you're more comfortable with the ecosystem

pesterhazy15:01:23

better to learn how the platform works (node, lambda) and how to interact with it using js interop - that allows you to do everything that a js programmer can do

pesterhazy15:01:36

cljs wrappers are at best the icing on the cake

richiardiandrea16:01:46

I personally use request-native-promise and it is as easy as it gets. Agree sometimes Cljs libs are less than ideal on node. It depends on the lib of course

lilactown17:01:38

@U053032QC AFAIR kvlt needs the request library

andy.fingerhut19:01:06

@lspector I suppose you have already considered the idea of having students run a VM on their personal machines, e.g. using VirtualBox, and you provide pre-installed versions of all software they will use inside of that VM?

andy.fingerhut19:01:40

That potentially leads to the learning curve of Linux, if the VM is Linux, though.

lspector19:01:34

@andy.fingerhut yes, I've considered that from time to time, but aside from the learning curve of the VM, and my learning curve of setting this up (alas, non-trivial), it's really a lot better if the students are using a thing that they can also do on their own, without being tied into the support system of a specific class

andy.fingerhut19:01:01

sure, makes sense.

lspector19:01:13

BTW the #calva-dev folks are really responsive and I'm thinking that VS Code + Calva Clojure Formatter + Clojure Warrior (for better bracket matching) might be the answer I've been looking for

cfleming22:01:31

@lspector I know you’ve rejected Cursive for other reasons, but FWIW it doesn’t require Java (it will use the JRE bundled with IntelliJ) and it will download lein automatically and put it in the right place etc, so you essentially don’t need to set up lein either.

cfleming22:01:32

Pretty much all CLJS paths require Clojure, which means you need Java somehow. Self-hosted is still tricky and considered relatively fringe AFAIK.

lspector23:01:37

Oooo @cfleming that's good to know about Cursive, to which I may some day return! For now, though, I think that that VS Code/Calva has a somewhat better beginner story. Appreciate the clarification of the bigger picture re: needing Java too

cfleming23:01:51

One day I may actually finish the standalone version!

❤️ 5
phill23:01:36

BTW what do Clojure Bridge do?

cfleming23:01:33

@phill It varies, I think - lots of them used to use NightCode or LightTable. I think a few use maria.cloud these days, but I haven’t kept up recently.

athomasoriginal23:01:01

I was reading through the Atom implementation details and I noticed that in the deftype Atom signature it is defined 4 four args. The 4th being watches. However, it seems that you cannot actually pass :watches ... to Atom https://github.com/clojure/clojurescript/blob/r1.10.439/src/main/cljs/cljs/core.cljs#L4423. They have to be passed in with add-watch. Curious what the reason is 🙂 (just for learning)