clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
steveb8n 2021-05-11T00:53:22.227900Z

Q: I want to use core.cache in a nodejs server. I’m pretty sure that somebody partially ported the jvm project to cljs but I can’t find it. Am I remembering incorrectly?

Jakob Durstberger 2021-05-11T06:27:04.228100Z

Promesa looks very cool. Might come in handy if things get more complex

Pepijn de Vos 2021-05-11T10:56:00.233100Z

Ohai, it's been.... a few years since I looked at ClojureScript. How are things going? http://clojurescript.org is not a great look tbh, linking prominently to several projects that are no longer maintained.

p-himik 2021-05-11T11:21:44.233200Z

You mean https://clojurescript.org/community/companies ? Oh what projects do you mean exactly?

Pepijn de Vos 2021-05-11T11:23:05.233400Z

https://clojurescript.org/guides/project-templates for example

Pepijn de Vos 2021-05-11T11:24:56.233600Z

https://clojurescript.org/community/libraries als lists stuff that is no longer maintained such as Om

p-himik 2021-05-11T11:26:36.233800Z

I wouldn't change anything. Those libraries that exist, are written in ClojureScript, and work. http://clojurescript.org is one, the libraries are many - maintaining flags for each an every one is unfeasible IMO.

Pepijn de Vos 2021-05-11T11:28:26.234Z

Sure they work, but wouldn't you want to direct people to the good stuff... Clicking through and seeing a bunch of deprecation notices makes the ecosystem seem pretty dead.

p-himik 2021-05-11T11:31:19.234200Z

How do you define "good stuff"? In the Clojure world, there's a lot of properly working libraries that haven't received a single change in years, because they just work. Some of them are even archived on GitHub - again, because there's nothing to fix, nothing to add, nothing to change.

Pepijn de Vos 2021-05-11T11:32:57.234400Z

A project that straight up tells you to go use something else is a pretty low bar to clear.

p-himik 2021-05-11T11:36:32.234600Z

Issues and PRs are welcome! https://github.com/clojure/clojurescript-site

Adrian Smith 2021-05-11T11:37:12.234900Z

I agree the website could use updating of links and guides, there is a repo somewhere to issue PRs to do updates, if you've been away for a couple of years, then check out clj-kondo, figwheel-main, shadow-cljs, reframe/reagent are still quite good for React

p-himik 2021-05-11T11:37:49.235100Z

Just because there's dust somewhere in my house doesn't mean that nobody lives there or even that nobody maintains it. :)

Pepijn de Vos 2021-05-11T11:38:45.235400Z

Thanks 🙂 yea I eventually made it from the deprecated figwheel to the maintained one, which seems pretty lively.

Pepijn de Vos 2021-05-11T13:22:50.236Z

Huh, so I installed cljsjs/plotly but can't figure out how to use it

Pepijn de Vos 2021-05-11T13:23:12.236400Z

(require '[cljsjs.plotly :as plotly]) works but after that plotly is not define

Pepijn de Vos 2021-05-11T13:29:10.237200Z

heyyy (.newPlot js/Plotly) does something. So seems like require doesn't work quite the same...

thheller 2021-05-11T13:32:40.237900Z

cljsjs packages work a bit different yes, most of them just provide some global variable you can work with

thheller 2021-05-11T13:33:02.238200Z

some newer packages work properly but not everything has been updated to that style

dnolen 2021-05-11T14:02:28.239Z

@pepijndevos we could probably eliminate the Project Templates page though it hasn't really been called out before - so I dunno

dnolen 2021-05-11T14:02:55.239600Z

It not clear to me that people are even looking for Project Templates any more - tools-deps was a pretty serious simplification

dnolen 2021-05-11T14:03:05.239900Z

the number of things to remember kind of collapsed

Pepijn de Vos 2021-05-11T14:03:40.240400Z

Hi David, good to see you're still around :)))

dnolen 2021-05-11T14:05:17.241700Z

ClojureScript is alive and kicking and doing lot more stuff since the last time you were around 🙂

🙂 1
Pepijn de Vos 2021-05-11T14:05:54.241900Z

I'm not aware of tools-deps. I was just looking how to set up a project, and from there eventually found figwheel-main-template

dnolen 2021-05-11T14:06:05.242200Z

you don't need to setup projects

dnolen 2021-05-11T14:06:24.242700Z

Clojure is more like Node.js - deps.edn is like package.json minus the bad stuff

dnolen 2021-05-11T14:07:14.242900Z

https://clojurescript.org/guides/quick-start

dnolen 2021-05-11T14:07:43.243500Z

after that you just use whatever you want - ClojureScript by itself, figwheel-main, shadow-cljs etc.

dnolen 2021-05-11T14:08:39.244300Z

Leiningen is still supported - but it's definitely a thing people reach less and less for if you're starting something new

Pepijn de Vos 2021-05-11T14:08:45.244600Z

huh

dnolen 2021-05-11T14:08:53.244800Z

interop between Leiningen and tools-deps exists

dnolen 2021-05-11T14:09:57.245700Z

for example I and the folks I work with just use ClojureScript directly

dnolen 2021-05-11T14:10:09.246Z

the days of build scripts, templates, long long gone

dnolen 2021-05-11T14:10:30.246500Z

ClojureScript now has a cljs.main which replicates clojure.main and takes almost all the same arguments

dnolen 2021-05-11T14:11:05.247200Z

many "tools" out there now work via CLI arguments and require no further setup

dnolen 2021-05-11T14:11:39.247400Z

i.e. no more plugins

dnolen 2021-05-11T14:11:48.247600Z

which wasn't ever a good idea

Pepijn de Vos 2021-05-11T14:12:50.247900Z

It's a whole new world...

dnolen 2021-05-11T14:14:18.248400Z

editor integration story is still a bit messy IMO

dnolen 2021-05-11T14:14:24.248600Z

if you want to use whatever you want

dnolen 2021-05-11T14:14:48.249500Z

Intellj + Cursive works great if you use Clojure for work and integrates well with standard REPLs

dnolen 2021-05-11T14:15:18.250600Z

(and nREPL too but it has less value in that context in my opinion, the only extra you get is macroexpand from I what I can tell)

dnolen 2021-05-11T14:15:29.251Z

but don't write macros - that hasn't changed

Pepijn de Vos 2021-05-11T14:15:34.251200Z

lol I tried to install some vscode thing and it yelled at me for using vim mode 😞

dnolen 2021-05-11T14:17:51.251600Z

oh using random JS libraries got simpler too

dnolen 2021-05-11T14:18:06.252100Z

from NPM, CLJSJS is not needed anymore

2021-05-11T14:19:06.253100Z

@dnolen Why would you say that nREPL has less value for work? Isn’t there pretty much feature-parity?

dnolen 2021-05-11T14:19:40.253800Z

I've been around since before nREPL

dnolen 2021-05-11T14:20:09.254700Z

nREPL obfuscates the behavior of the standard REPL which is just a very simple I/O thing

dnolen 2021-05-11T14:20:47.255200Z

I've had to support it off/on for ClojureScript because it was primary tool

dnolen 2021-05-11T14:20:53.255600Z

and dealing w/ it was hell

dnolen 2021-05-11T14:21:20.256200Z

I have a very low opinion of it - regardless of it's utility

2021-05-11T14:21:27.256500Z

Ahh, OK.. I was thinking I was missing out maybe on some features in Cursive

dnolen 2021-05-11T14:21:28.256600Z

too many bad experiences

dnolen 2021-05-11T14:22:19.257400Z

and again, it's my opinion every single editor integration should start with the standard REPLs first

dnolen 2021-05-11T14:22:24.257700Z

and nREPL as a second order thing

2021-05-11T14:22:47.258100Z

I’ve had a few of those bad experiences myself, but it’s been more stable as of late

dnolen 2021-05-11T14:23:00.258600Z

I've lived through a decade of instability

dnolen 2021-05-11T14:23:06.258800Z

so I'm done

Ruy Valle 2021-05-11T14:35:23.261900Z

@dnolen have you or someone written about this? I would be curious to learn about how you set up your projects, your workflow, and how this has been impacted by nREPL instability and other such issues that may not be obvious to beginners

dnolen 2021-05-11T14:37:55.262600Z

I haven't written up anything describing it - but there's a reason why ClojureScript works the way that it does

dnolen 2021-05-11T14:38:38.263300Z

I generally do not want to rely on too much tooling stuff based on past experiences

dnolen 2021-05-11T14:39:20.264100Z

ClojureScript is designed to be perfectly productive by itself and now exposes quite a few hooks so people don't need to write "mega-tools"

dnolen 2021-05-11T14:39:43.264600Z

that's why I wrote Krell - I was tired of stuff that does N things instead of the one thing I care about

dnolen 2021-05-11T14:40:38.266200Z

tired of reading docs too, tired or looking at how everything did something slightly differently for no good reason other than the questionable one of "taste"

💯 1
🎯 3
dnolen 2021-05-11T14:42:30.268100Z

factor in the problems of the JS ecosystem and the whole thing felt like it was on the verge of collapse

dnolen 2021-05-11T14:43:25.269400Z

so IMO ClojureScript should be self-sufficient and all the gross stuff which can't fix is kept somewhat at bay

🎯 2
Ruy Valle 2021-05-11T14:46:03.271500Z

very interesting, thank you. I am relatively new to Clojure and very new to Clojurescript. I've been setting up my first project in the last few days and have had to make what seem like arbitrary choices. I wanted to go with Krell at first but then I ended up going with shadow-cljs + Expo because it seemed like I could avoid dealing with XCode that way. yesterday I read that Calva works better with figwheel so now I'm wondering whether I should use that, and I've been reading the shadow-cljs docs to figure out what the three REPLs I can connect to are, and apparently there is something wrong with my setup because the node REPL keeps saying there is no JS runtime available. also I thought it was interesting that currently I am not using tools.deps... hence my curiosity

dnolen 2021-05-11T14:52:41.272500Z

all the secondary tools are great - after one understands how to use the fundamental thing

💯 2
dnolen 2021-05-11T14:52:51.272700Z

this really applies to everything

dnolen 2021-05-11T14:53:19.273400Z

I don't know Expo - but to me - trying to shove Android / XCode under a rug - I just don't believe in it

dnolen 2021-05-11T14:53:55.274100Z

these are all variations on starting in the wrong place w/ the hope that somehow the problems can be deferred

2021-05-11T15:12:06.275500Z

I get no js runtime errors in shadow cljs until i go to page im browser. Localhost:8080. Then it works

pez 2021-05-11T15:16:04.278Z

If Expo offers what you need to get your app done, then indeed it can be used to avoid dealing with Android SDK and XCode. Expo has a lot going for it, especially when it comes to distributing test versions of the app quickly.

pez 2021-05-11T15:17:00.278500Z

What @qmstuart says. Do you have the app running in your browser or simulator/device?

lilactown 2021-05-11T15:18:28.280200Z

if you’re running the literal Node REPL then it should automatically start the runtime, but it might depend on how you start it. cant’ quite remember the details

lilactown 2021-05-11T15:18:54.281Z

if you’re running a node-script build, then you’ll need to start the node script as a separate process

lilactown 2021-05-11T15:20:07.282800Z

what exactly are you trying to REPL into? like pez said, if you want to connect to the code running on your device, then you’ll want to make sure the device is running your app and you’re connecting to the right build

lilactown 2021-05-11T15:21:20.283600Z

I used nREPL because it’s what CIDER uses, and all of my editor config Just Works(tm) with CIDER atm

lilactown 2021-05-11T15:22:33.285100Z

I use spacemacs with the Clojure layer, and I’m learning #calva rn to help our new intern. both seem to rely on CIDER

thheller 2021-05-11T15:24:13.286400Z

nrepl is basically a requirement if you want basic tool support for code completion etc

thheller 2021-05-11T15:24:38.287500Z

regular stream based repls are pretty hostile towards tools in general, as soon as you want more than text in/out at least

lilactown 2021-05-11T15:24:53.288Z

I know there is inf-clojure and other extensions that I can use some combo of prepl(?) + compliment and other libs but I’m not interested in figuring that out rn

dpsutton 2021-05-11T15:25:53.290200Z

i've been quite happy with inf-clojure connected to socket repls and clojure-lsp. It's basically an open source version of Cursive from my experience

lilactown 2021-05-11T15:26:21.291100Z

funnily I turned off code completion because it was causing perf issues in emacs

Aron 2021-05-11T15:26:31.291400Z

even conjure went to nrepl instead of socket repl

raspasov 2021-05-11T15:26:43.291800Z

@thheller Is that a historical accident? I mean, IntelliJ does autocompletion somehow, for all sorts of languages, without a REPL… (I am not underestimating the scope of the task, which is probably BIG). Just curious what you think.

thheller 2021-05-11T15:27:52.292200Z

cursive does code completion based mostly on code analysis, not by asking the runtime for data

flowthing 2021-05-11T15:27:54.292400Z

I don't see how that's true. You can have different channels for editor tooling and evals.

thheller 2021-05-11T15:28:57.293600Z

I didn't mean nrepl specifically. I do not like nrepl at all, I mean a nrepl like message based protocol. not just text stream in/out, some structure

raspasov 2021-05-11T15:29:05.293900Z

Got it.

dnolen 2021-05-11T15:29:11.294300Z

there is an alternative - why is a REPL necessary for code completion - what about analysis?

raspasov 2021-05-11T15:29:19.294600Z

Yes… But it also I believe it uses nREPL when you’re in the repl window. That way you can get, for example, autocompletion (on the JVM) for example with, say, vars that you declare dynamically at runtime.

dnolen 2021-05-11T15:29:35.295300Z

if you start packing all this analysis stuff into a REPL doesn't mean that REPL becomes harder to maintain - harder to understand

raspasov 2021-05-11T15:29:40.295600Z

But that’s not a huge part of the benefit of autocompletion. It’s like 2%.

dnolen 2021-05-11T15:29:44.296100Z

and less focused on what it's actually supposed to do

flowthing 2021-05-11T15:30:33.297600Z

While we're on the topic... I've been working on ClojureScript editor auto-completion recently. Most of it has been relatively straightforward, but I haven't been able to figure out how to get a hold of the compiler environment in a tooling-independent manner.

dnolen 2021-05-11T15:30:41.297900Z

one of the very first things Rich demoed w/ Datomic was just parsing Clojure code into Datomic

dnolen 2021-05-11T15:30:46.298100Z

it was like 500 lines of code, no REPL involved

dnolen 2021-05-11T15:31:15.298700Z

but somehow everybody coalesced around this more obfuscated way of doing things

dnolen 2021-05-11T15:31:20.299Z

and REPLs that are difficult to maintain

flowthing 2021-05-11T15:31:50.299300Z

You can certainly get more leverage out of REPL-powered auto-completion than 2%, IMO.

flowthing 2021-05-11T15:32:29.299500Z

Oh, I guess you meant the Cursive REPL window specifically. 🙂

thheller 2021-05-11T15:32:42.299700Z

I can live without repl powered code completion completely. I was just using that as a basic example. there are many things a REPL may want to ask the runtime dynamically

raspasov 2021-05-11T15:33:20.299900Z

I use expo in a “bare” mode. I still use XCode, Android, etc. But I get to use their “curated” libraries which are pretty high quality. For example: https://docs.expo.io/versions/latest/sdk/in-app-purchases/ and all the others.

p-himik 2021-05-11T15:33:41.300100Z

You can't really do that for macro-generated code, so there's at least one reason.

flowthing 2021-05-11T15:34:23.300600Z

That's true, but you can have one socket for the streaming REPL and another one for editor tooling.

raspasov 2021-05-11T15:34:54.300800Z

So far, I haven’t experienced any drawbacks with the “bare” approach. It is really like pure React Native (which I’ve also done multiple times).

Ruy Valle 2021-05-11T15:35:27.301Z

I am exploring, reading and trying to understand things. I saw there were three REPLs, or rather 2 + one per build if I understand correctly, and I am still not 100% clear on what the differences are. What I saw is that when I connected to the Node REPL (not the one for my build nor the browser one), I would get a message saying there is no JS runtime. I am doing a "regular" jack-in.

thheller 2021-05-11T15:35:36.301200Z

point is that streaming REPLs suck for tools because of the stream nature

raspasov 2021-05-11T15:35:42.301400Z

I 100% agree that going with a fully managed Expo approach, at least at the moment, is questionable. A lot of limitations it seems (and they are pretty open about them).

Ruy Valle 2021-05-11T15:36:00.301600Z

and no I didn't have the app running on my browser or my device at that moment, although if I am understanding correctly that is separate from the Node REPL?

thheller 2021-05-11T15:36:01.301800Z

random prints somewhere can totally mess everything up

flowthing 2021-05-11T15:36:37.302Z

Yeah, you do want structured output, like in prepl.

raspasov 2021-05-11T15:36:43.302200Z

Mmm is that a fact? Or it’s just harder?

flowthing 2021-05-11T15:36:54.302400Z

Input can be streaming, though, and that's all that matters, really.

thheller 2021-05-11T15:36:54.302600Z

prepl was the fix for that yes, but it also gave up most of its power in the process

thheller 2021-05-11T15:37:06.303Z

good luck starting a CLJS REPL from a CLJ prepl

dnolen 2021-05-11T15:37:24.303400Z

I already said above macroexpansion is the one thing you can't do in Cursive with standard REPLs

thheller 2021-05-11T15:37:39.303800Z

so instead just use a proper message based protocol from the start and all problems are solved

flowthing 2021-05-11T15:37:41.304100Z

What's the problem there? It works fine as far as I can tell.

dnolen 2021-05-11T15:37:58.304800Z

but I not desired macroexpansion in all this time

thheller 2021-05-11T15:38:01.305Z

it does not work, feel free to try it

dnolen 2021-05-11T15:38:08.305400Z

because the first bad idea is writing a macro that needs any kind of debugging

dnolen 2021-05-11T15:38:51.306500Z

(beyond writing some unit tests)

flowthing 2021-05-11T15:39:06.306800Z

I have. We might have different definitions of "works", I guess. 🙂

raspasov 2021-05-11T15:39:15.307100Z

Yeah… I jump to a JVM runtime in Cursive if I need to write a .cljc macro for ClojureScript.

raspasov 2021-05-11T15:39:25.307300Z

(usually something basic)

dnolen 2021-05-11T15:39:48.307800Z

IMO - if a macro is not blindingly obvious it should not be written

👌 1
thheller 2021-05-11T15:40:01.308200Z

what did you try? I'm talking about starting a CLJS REPL from a prepl

dnolen 2021-05-11T15:40:03.308400Z

if it's blindingly obvious why do you need tooling support

dnolen 2021-05-11T15:40:14.308700Z

then why do you need your REPL to do this

flowthing 2021-05-11T15:40:15.308900Z

I've only taken the first steps there, though, so there might definitely be things that don't work.

thheller 2021-05-11T15:40:16.309100Z

any REPL will take over the *in* and print to *out*

dnolen 2021-05-11T15:40:23.309400Z

what happens if you unpack all these assumptions

pez 2021-05-11T15:40:29.309500Z

Indeed, but I don’t think there is a node process running when you are building a mobile app. I could be wrong about this. Starting the app on your simulator is necessary to have your REPL connected to the app.

thheller 2021-05-11T15:40:52.309700Z

but in case of prepl the *out* is captured, so all "results" from the CLJS REPL will end up as regular out messages, not actual results

thheller 2021-05-11T15:41:34.309900Z

so prepl only really works if you never rebind in/out

Ruy Valle 2021-05-11T15:41:52.310100Z

I see. So when the target is react-native, the node repl is not started? And if I understand correctly I can start it manually from another terminal and then connect to it from my build's REPL? I think I read this in the shadow-cljs docs

pez 2021-05-11T15:41:54.310300Z

That would be true for Figwheel Main as well, so I say stick with shadow-cljs for now, it is an awesome tool.

thheller 2021-05-11T15:42:24.310600Z

(which is fine, nrepl has the same problem really)

p-himik 2021-05-11T15:42:37.310800Z

You can't tell what the generated code is without actually running the macro code. That's a fact.

flowthing 2021-05-11T15:42:44.311Z

Oh, gotcha. That doesn't really make it unusable as far as I'm concerned, though -- it just means I don't get syntax highlighting on my results. Which is a shame, of course.

pez 2021-05-11T15:42:49.311200Z

I’ll try to see what happens if I try to connect to a plain node repl, just a minute…

thheller 2021-05-11T15:42:55.311400Z

but again .. start with a proper message based protocol and a REPL that is aware of that and you'll never have that problem

thheller 2021-05-11T15:43:34.311600Z

but if you lose features you might as well skip prepl entirely ... that is my whole point

thheller 2021-05-11T15:43:46.311800Z

nobody is doing this anyways so it really doesn't matter

thheller 2021-05-11T15:44:33.312Z

but from a tool perspective that makes prepl unattractive. it is also the whole reason why nrepl sucks to much for CLJS. nrepl was designed for CLJ, not CLJS and it shows.

raspasov 2021-05-11T15:44:50.312200Z

Sure, yes. I was trying to say that it’s probably possible to include a language “runtime” in the editor/IDE and run it “behind the scenes”. You don’t need to talk to a live REPL to do it, per-se.

Ruy Valle 2021-05-11T15:45:18.312400Z

thank you!

thheller 2021-05-11T15:46:07.313Z

so you are saying the core.async go macro shouldn't have been written? 😛

thheller 2021-05-11T15:46:35.313900Z

there are definitely a few macros that aren't blindingly obvious and need proper debugging

flowthing 2021-05-11T15:46:45.314Z

I am. 😛 But yeah, like most things, it's a tradeoff. For example, I start a prepl-like thing on top of a socket REPL, which means I can do make do with zero dependencies. Also, since it's a streaming REPL, starting sub-REPLs is straightforward.

p-himik 2021-05-11T15:47:02.314500Z

Impossible in the general case. Hence, impossible at all because the editor can't know if a macro is a general case or not. A macro can be an impure function.

raspasov 2021-05-11T15:47:25.314900Z

Every rule has (a few) exceptions, I guess :lightsaber:😃

pez 2021-05-11T15:47:44.315Z

Actually I can connect to the node-repl… I guess that makes sense, it has just never struck me that it is there.

pez 2021-05-11T15:49:00.315200Z

What do you see in the Calva Jack-in Terminal pane?

thheller 2021-05-11T15:49:26.315400Z

sure .. just don't start another sub-repl from your code 😉

pez 2021-05-11T15:49:45.315600Z

Mine has

shadow-cljs - server version: 2.12.5 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 55194
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (146 files, 0 compiled, 0 warnings, 2,28s)
After jack-in.

raspasov 2021-05-11T15:50:22.315800Z

Hmmm ok. I thought of macros as just functions that do data transformations which take some data and return valid code (data). But perhaps I’m misunderstanding. Impure function as in… writes to a file or a database at expansion time? That would be quite the macro 🙂

pez 2021-05-11T15:50:36.316100Z

Have you started from a template or something like that?

p-himik 2021-05-11T15:52:51.316500Z

A macro that uses System/getenv. Or reads a config file from CWD. Or looks at the time. Or uses (random). Or a million other things.

flowthing 2021-05-11T15:52:59.316700Z

https://tutkain.flowthing.me/sub-repl.mov You mean like this?

Pepijn de Vos 2021-05-11T15:54:59.317400Z

So far what I really like is that cljs seems to have great JS interop while not having to touch most of the JS ecosystem.

raspasov 2021-05-11T15:55:28.317500Z

Ah, understood. Sure. I guess I never felt/had the need to write such macros which would do those things at expansion time…

thheller 2021-05-11T15:55:57.318100Z

no, that is cheating. you are starting a REPL that is aware of your messaging protocol. which is my entire point.

raspasov 2021-05-11T15:56:16.318600Z

Do you have examples of such macros in the wild? (curious to look at them)

thheller 2021-05-11T15:56:28.319100Z

if you design REPLs from the ground up to be aware of this all the problems go away

thheller 2021-05-11T15:58:34.319400Z

or have your editor send a auto complete request while it is in a (break)

flowthing 2021-05-11T15:59:02.319600Z

That works — auto-completion requests are sent over a different channel.

thheller 2021-05-11T15:59:22.319800Z

but how can it then auto-complete the local context?

dnolen 2021-05-11T16:00:36.320600Z

@thheller or the macros written in Clojure(Script) - should people be writing these kinds of macros often outside of the foundation?

thheller 2021-05-11T16:00:41.320800Z

but as you said .. you already built your own protocol on top of the socket repl

thheller 2021-05-11T16:00:46.321100Z

so you are using what I suggested already ...

dnolen 2021-05-11T16:00:58.321500Z

I'd say no, I never feel the need to this kind of macro writing in applications

flowthing 2021-05-11T16:01:17.322100Z

I'm not sure what "local context" entails here. If you mean e.g. the function parameters, it currently can't -- my plan at the moment is to implement completely inside the editor.

dnolen 2021-05-11T16:01:23.322300Z

so why focus on a feature of REPLs that is needed 0.01% of the time?

flowthing 2021-05-11T16:01:33.322400Z

The protocol I have is 99% prepl.

flowthing 2021-05-11T16:01:54.323400Z

Unstructured (streaming) input, structured output.

dnolen 2021-05-11T16:03:42.326600Z

to me the funny result of history is that Rich attempted to fix the static analysis / REPL thing in ClojureScript - partly because it's necessary but there other benefits from decomplecting

thheller 2021-05-11T16:03:49.327100Z

I've written a couple fairly complex macros too and I have needed any of the nrepl specific features for it. I'm not trying to defend nrepl in any way, it is completely terrible for CLJS. just saying that the socket REPL isnt perfect either.

dnolen 2021-05-11T16:04:10.327600Z

yet then people try to turn the split around and shove back into this old way where the REPL does everything

dnolen 2021-05-11T16:04:31.328100Z

I'm not defending socket REPL here

dpsutton 2021-05-11T16:04:36.328400Z

> Rich attempted to fix the static analysis / REPL thing in ClojureScript what are you referring to here?

dnolen 2021-05-11T16:04:38.328500Z

I'm just talking about the funny state of things

dnolen 2021-05-11T16:05:08.329300Z

ClojureScript compiler is more like a library - the AST is in EDN

👍 1
dnolen 2021-05-11T16:05:49.330200Z

so analysis is separated from this magic feature of the REPL capturing some var metadata

flowthing 2021-05-11T16:06:04.330500Z

> you are starting a REPL that is aware of your messaging protocol. which is my entire point. Not sure what you mean by this. The REPL break starts isn't aware of anything. Anyway, yes, it does print results in stdout, which is a shame, but it doesn't mean it's unusable.

dnolen 2021-05-11T16:06:26.330900Z

so in ClojureScript you get two non-intertwined useful things

thheller 2021-05-11T16:07:11.331Z

never said it was unusable, just limited

flowthing 2021-05-11T16:07:41.331700Z

You said "it does not work". 🙂

dnolen 2021-05-11T16:07:52.332Z

to me if everything went this direction you're just less likely to go wrong - because each tools is only focused on what it needs to do

dnolen 2021-05-11T16:08:29.332700Z

you can see this in the ClojureScript REPLs - there only a few touch points generally to call into analysis / compilation etc.

flowthing 2021-05-11T16:08:52.332900Z

But yes, I believe it's limited.

thheller 2021-05-11T16:10:23.333100Z

well yeah it doesn't work as intended, showing up as output is a good fallback but thats not the intended result

p-himik 2021-05-11T16:12:31.333800Z

Yep, cljs.test/deftest. It defines something if and only if cljs.analyzer/*load-tests* is true during macro expansion.

👌 1
flowthing 2021-05-11T16:13:08.334Z

Yeah, it's not optimal. I guess one possible approach to explore might be to start a ClojureScript socket REPL in a different port and connect to that, instead of having both operate over the same connection.

p-himik 2021-05-11T16:18:05.334200Z

And you can still mess things up when evaluation is required, in your own code:

(if (= (System/getenv "DEBUG") "true")
  (defn do-stuff [arg1 arg2] "some docstring" ...)
  (defn do-stuff [_ _] "noop" ...))

Ruy Valle 2021-05-11T16:19:13.334400Z

I get this when connecting to the node REPL:

shadow-cljs - server version: 2.12.5 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 65015
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (94 files, 0 compiled, 0 warnings, 4.33s)
and no, I started from scratch. I created an Expo project then created a shadow-cljs project and kind of glued them together.

flowthing 2021-05-11T16:26:54.334600Z

Anyway, if certain bits of my output not having syntax highlighting is the price I have to pay to work with zero dependencies, it's one I'll gladly pay. 🙂 It seems very unlikely that Clojure ever gets an RPC-type of thing. Of course, it's entirely possible (probably likely) there are other downsides I just haven't come across yet, of course.

pez 2021-05-11T16:32:39.334900Z

And now if you start the app on your simulator, can you connect the REPL to it?

Ruy Valle 2021-05-11T16:33:24.335100Z

I can connect the node REPL to the device? or do you mean the build's REPL?

pez 2021-05-11T16:33:52.335300Z

I mean the build’s REPL.

pez 2021-05-11T16:35:41.335500Z

That is the important one, to get the Clojure experience in being able to modify the app you are building as it is running.

pez 2021-05-11T16:37:09.335700Z

Of course, if you can’t connect Calva to the node-repl, then something is not configured as it should and that is a symptom. But the goal here should be to connect to the REPL running inside your app.

flowthing 2021-05-11T16:43:37.335900Z

Good thing we had this discussion, though -- it motivated me to come up with at least one possible solution to the syntax highlighting problem. 🙂 https://tutkain.flowthing.me/sub-repl-2.mov Obviously not ideal, but it's something. 😛 If nothing else, I can use it myself (and in possible sub-REPLs built into my editor plugin).

lilactown 2021-05-11T17:59:49.336800Z

Node REPL in shadow-cljs parlance is a standalone REPL separate from your app

lilactown 2021-05-11T18:00:37.337700Z

reading through this exchange, it’s a bit confusing. it sounds like Ray just wants to connect to the standalone Node REPL, and isn’t able to

lilactown 2021-05-11T18:00:58.338200Z

the Node REPL shouldn’t require a build running or anything running on a device or browser

lilactown 2021-05-11T18:02:13.340Z

@ruyvalle it might be worth asking in #shadow-cljs, but I’m sure that thheller will ask you how you are starting the Node REPL. I haven’t seen how you’re attempting to start and connect to it mentioned in this thread

flowthing 2021-05-11T18:11:49.340200Z

Hopefully this approach covers most of my own use cases, at least: https://tutkain.flowthing.me/sub-repl.png Very glad that this topic came up. :)

Ruy Valle 2021-05-11T20:10:09.340700Z

@pez I can connect to my app while it is running. I don't think I've configured things properly to re-evaluate forms in my editor and have the result show up in the app, but when I save it reloads twice: once by shadow-cljs (super fast!) and once by expo. so I think this is ok. @lilactown I think what you both have said tells me what I was looking for. I'm getting the sense that there is no practical reason to connect to the Node REPL in a React Native project. And if I want to do so I need to get the Node REPL to connect to an actual Node instance which I start myself. Am I getting this? Thank you both for your input by the way!

pez 2021-05-11T20:40:36.342200Z

You'll want to disable Expo/react native Fast Refresh. From the dev menu of your app.

Ruy Valle 2021-05-11T22:22:26.342800Z

yes!