Fork me on GitHub
#beginners
<
2018-11-09
>
randomm char03:11:55

how do you run the clojure jar/repl file use to be able to do bu typing java -jar clojure.jar but doesn't work for latest one

randomm char03:11:44

doent help they really need to update that site

seancorfield04:11:34

@mathpunk Did no one provide feedback on your questions about XML files? My recommendation would be to keep the reading separate from the processing -- so transformation functions should just take data as input and produce data as output.

seancorfield04:11:06

@andy100jones That site has been updated a lot recently and the Getting Started page in particular has been completely overhauled since Clojure 1.8 (which was when you could last just run the single clojure.jar file).

seancorfield04:11:19

Is there something specific you think is missing, or confusing?

randomm char05:11:23

java -jar clojure-1.9.0.jar with clojure 1.9 in the same directory its gives me tones of errors

randomm char05:11:44

I can get it to work with lein only after I manually installed lein

andy.fingerhut05:11:28

@andy100jones Did you find the command 'java -jar clojure-1.9.0.jar' on the page that Alex mentioned? https://clojure.org/guides/getting_started

andy.fingerhut05:11:31

I don't see it there.

andy.fingerhut05:11:55

Oh, maybe the one way near the bottom?

randomm char05:11:06

literally cut-n-pasted it changed version number

andy.fingerhut05:11:35

I'll try out that last one to be sure, but yeah, that one may be out of date.

andy.fingerhut05:11:48

The earlier ones look like better options to me.

seancorfield05:11:55

That's only for when you build Clojure from scratch locally, right?

seancorfield05:11:07

(pretty much no one does that, especially beginners)

seancorfield05:11:27

Try following the other options on that page. Clojure 1.8 was the last version where you could just take the single clojure.jar and run it like that.

andy.fingerhut05:11:54

That last one works, but only if you first do the 4 commands above it.

randomm char05:11:12

there is a way but cant remmerb fro thelife of me where I found the info

andy.fingerhut05:11:29

And as Sean mentioned, that is mainly useful if you want to make changes to Clojure and try those out. Most people use it as it is released using one of the earlier methods on that page.

seancorfield05:11:30

(1.8 was nearly three years ago)

seancorfield05:11:49

@andy100jones Are you on Windows, Mac, or Linux?

randomm char05:11:17

well the getting started page hasnt change since then πŸ˜›

seancorfield05:11:38

Yes, it has changed a lot.

seancorfield05:11:05

The Clojure Installer and CLI tools section at the top is all very recently added.

andy.fingerhut05:11:07

Yeah, as mentioned there Leiningen or Boot are probably better choices on a Windows system.

seancorfield05:11:42

If you're on Windows 10, you could always try the WSL (Windows Subsystem for Linux) -- that's how I run most Clojure stuff on Windows.

andy.fingerhut05:11:42

Or Sean has probably had success using WSL on Windows and the Unix methods.

randomm char05:11:45

well can get it working fine with lein after some finagling

seancorfield05:11:31

Otherwise, lein or boot are going to be your choices for Windows. A version of the new CLI tools is coming for Windows (via PowerShell) but it'll be a while.

andy.fingerhut05:11:30

Cool. Yeah, lein should get you going on Windows.

seancorfield05:11:48

I have a c:\tools folder in Windows and added it to my PATH, and I just put lein.bat in there, next to boot.exe πŸ™‚

randomm char06:11:59

woot found it gotta do java -cp clojure-1.9.0.jar;spec.alpha-0.2.176.jar;core.specs.alpha-0.2.44.jar clojure.main

seancorfield06:11:45

lein.bat repl or boot.exe repl would be easier πŸ™‚

randomm char06:11:22

so who ever maintains https://clojure.org/guides/getting_started where it says "Other ways to run Clojure " need to add some info in there

randomm char06:11:11

well 1.8 yeh didnt need to add the extra jar files

seancorfield06:11:13

@andy100jones The example with running clojure.jar is correct -- if you follow the actual steps shown.

randomm char06:11:53

where yeh get ant from?

seancorfield06:11:12

Andy tried the instructions, as written, and reported above that they do work.

seancorfield06:11:25

Searching for install ant windows gets me to this page https://ant.apache.org/manual/install.html

randomm char06:11:10

and yeh gotta intall git?

seancorfield06:11:19

That's why that section is way down the page -- and is only intended for people who want to build Clojure locally and run it. You've skipped over a lot of options to get to that point πŸ™‚

seancorfield06:11:42

I get your point tho'... I'm mostly just teasing.

randomm char06:11:54

yup was looking for simple and fast at the time just wanted to check it out

seancorfield06:11:04

It's unfortunate, but Windows has never been the favored platform for development with Clojure.

seancorfield06:11:31

Leiningen is definitely the easiest way to get up and running on Windows. Boot is also a good option.

seancorfield06:11:50

When the PowerShell version of the CLI tools is finished, that'll be a good option.

seancorfield06:11:08

Unless you're willing to use WSL on Windows 10 -- which gives you full access to all the Linux tools.

randomm char06:11:12

well at thie point think just t do a few test runs doing it on http://repl.it would be faster

randomm char06:11:05

was checking out wsl its interesting not sure I like it though just feels weird πŸ˜›

seancorfield06:11:59

Yeah, much will depend on your background. I grew up on Unix so Linux seems natural to me but it can feel pretty old-school for a lot of folks πŸ™‚

seancorfield06:11:16

I've had Macs since around '92 -- and, back then, it was all GUI so I used to run Tenon Intersystems BSD Unix on Macs as well, since that's how I did all my dev work. Until Windows 10 got WSL, I didn't find it easy to do dev work on Windows...

Amol06:11:43

It's also really hard to go back to windows after getting into linux

randomm char06:11:25

its all that control πŸ™‚

seancorfield06:11:45

FWIW, I do keep reminding Alex about the PowerShell version of the CLI tools because I would really like to use that natively on Windows, even tho' it's not my primary dev environment.

randomm char06:11:38

is there a reason there are 3 separate jar files why not put em all in one?

seancorfield06:11:45

So that spec and the core.specs can both develop on their own schedule, independent of Clojure itself.

seancorfield06:11:00

And that's likely to be the pattern for more parts of Clojure going forward I expect.

seancorfield06:11:33

Clojure itself tends to get a new release about once a year. spec (and core.specs) get releases much more often.

seancorfield06:11:01

We're seeing a similar arc with the CLI tools themselves and tools.deps (.alpha) which is getting new releases faster than even the prerelease builds of Clojure 1.10 -- or at least on a different schedule.

andy.fingerhut06:11:21

Yeah, I tried those instructions on my Mac laptop where java, ant, and git were already installed long ago.

randomm char06:11:38

oh well would of been nice had they put that info in the getting started page somewherer would of saved me llot of time "P

andy.fingerhut06:11:55

And I've submitted some patches that were accepted into Clojure's code, so have done lots of other weird things with that code, too πŸ™‚

andy.fingerhut06:11:08

I do think that perhaps that last section could perhaps have a slightly more of a warning that you need to install git, java, and ant first, and it isn't recommended unless you want to develop changes to Clojure itself.

andy.fingerhut06:11:07

and those instructions might not even work on Windows at all, without WSL

randomm char06:11:28

well most people probably already have java but unless your really into programing already git and ant not so many gonna have that

andy.fingerhut06:11:51

Either I am in a weird part of the programming world where git is as common as air (possible), or perhaps it has caught on in about half and there are large swaths that still haven't started using it yet.

andy.fingerhut06:11:06

ant is definitely more niche of those two tools.

randomm char06:11:14

programing is an off/on thing for me read about lots

randomm char06:11:41

I knew about apache but not ant just rread up on it

andy.fingerhut06:11:40

Thank you, Sean, for saving me 5-10 minutes of doing something like that πŸ™‚

seancorfield06:11:19

The Windows section should probably actually link to the Leiningen and Boot websites but my adoc chops are rusty πŸ™‚

randomm char06:11:04

well the java -jar still works just gotta grab 2 more jar files πŸ˜›

seancorfield06:11:40

Ah, it has them linked at the bottom of the page... I'll do a PR to have them linked above as well...

andy.fingerhut06:11:38

The jar created by those instructions includes the other 2 with it. The JAR you download from Maven does not.

andy.fingerhut06:11:44

There are multiple ways to build Clojure, with instructions on other (not getting started, but Clojure developer) pages that show you how to build it in the way used to create the JAR made available on Maven.

andy.fingerhut06:11:06

Not saying you want to try out all of these ways, just FYI in case you are wondering why those instructions work but not what you tried.

andy.fingerhut06:11:57

The Mac and Unix ways install a program that figures out for you what those 3 jars are, and downloads and puts them on the Java command line for you, so you don't need to know what all 3 are. It just hasn't been ported to non-WSL Windows yet.

andy.fingerhut06:11:16

Anyway, that is the too-long way of saying what Sean did earlier, paraphrasing as "Those instructions are not optimized for non-WSL Windows users, unless you follow the lein or boot ways, which it does recommend."

randomm char06:11:29

hey while I got a live person odd qquiestion

andy.fingerhut06:11:35

I have tried writing README's for installing some software tools that took multiple steps, and only used by about 100 to 150 people, where I work, and found that it was nearly impossible to write them in a way that someone didn't miss a step.

andy.fingerhut06:11:56

I guess the main lesson I learned is: if you can, make it take only 1 step, by writing an installer for them.

randomm char06:11:58

when running a repl how do you display a function like using (source map)

andy.fingerhut06:11:23

what happens at a repl when you type (source map) ?

seancorfield06:11:23

Yeah, that's why we ended up with a dev-from-bitbucket.sh shell script at work. We only onboard new developers once every few years but automating it is still worthwhile.

randomm char06:11:53

user created funnction meant

andy.fingerhut06:11:30

Ah, yes. I don't know, and haven't dug in to find if there is a way. Putting the function in a file and loading it from there should do it, though.

didibus06:11:31

Ya, just need to add more Jars to the classpath now. I do agree, it would be nice to have those instructions on that page. You could make a PR for it.

seancorfield06:11:31

@didibus I really don't think people should be encouraged to download the individual JARs and run them like that. It's far better to encourage people to use the CLI tools (on Mac/Linux) or Leiningen/Boot on Windows.

didibus06:11:41

Especially on Windows, even Lein does not always work. The lein bat file is outdated, and won't work on all Windows machine. They have a powershell script in the works also that hopefully will be better.

didibus06:11:54

Maybe boot works on Windows, but I've been having a lot of problem getting Lein to run on Windows for a while now. It seems you need to debug the bat file constantly, and manually fiddle with it. So I think on Windows, using 3 jars and java is actually the easiest way.

practicalli16:11:16

Running the Leiningen (unix script) in GitBash is the easiest way I found to use Clojure on windows

randomm char06:11:07

had to manula install lein to get it to work πŸ˜›

didibus06:11:43

Even when I do that, the bat file still can't launch it πŸ˜›

andy.fingerhut06:11:21

Just a curiosity question for me, do you do all your work on Windows? e.g. no Linux/Unix work?

didibus06:11:07

Windows and Linux for me

randomm char06:11:12

windows main system I use bside installing linux on my ersonal amchine

randomm char06:11:31

damm cant ttype

seancorfield06:11:38

@didibus Interesting. I've never touched the lein.bat since I downloaded it ages ago, and I've never had any problems with it. Certainly, Boot used to be absolutely awful on Windows (much like Leiningen did when it first appeared for Windows) but Boot is really pretty solid on Windows these days. Maybe you have old installs?

andy.fingerhut06:11:16

It is certainly possible develop in Clojure on Windows, even without WSL. Just realize that you are not on the most greased path there. If you can run WSL or Linux in a VM on top of Windows, and it doesn't cause you terrific annoyance to do so, you will see fewer build tooling issues.

randomm char06:11:20

literally just grabbed a copy from lein site and it didnt work

seancorfield06:11:46

Exactly what "didn't work"?

randomm char06:11:00

error dowload file

didibus06:11:25

I think the issue is with a recent version of Windows 10

didibus06:11:29

And latest Lein

randomm char06:11:32

when running lein install

seancorfield06:11:19

C:\Users\seanc>lein.bat version
Leiningen 2.8.1 on Java 1.8.0_191 Java HotSpot(TM) 64-Bit Server VM
C:\Users\seanc>
That's on the very latest Fast Ring Insiders Build of Windows 10 (18277).

seancorfield06:11:58

But maybe the .bat file is older and doesn't suffer from that bug.

randomm char06:11:11

hmmm gues Ishould install wget or curl πŸ˜›

didibus06:11:20

Not sure, all I know is I got a new laptop, and lein fails to install on it. And someone else at my work had the same issue on his windows laptop trying to get lein running.

didibus06:11:07

Possible something is a bit messed up with my Windows environment, but to me that's also an issue in that lein isn't very resilient

didibus06:11:21

the lein.bat specifically

andy.fingerhut06:11:09

Note that one of the developers in the issue you linked to said something like "I don't use Windows, except to investigate bugs in the Windows installation". Hence my statement above about "not on the greased path". Mac and Unix/Linux are heavily used and greased for Clojure.

seancorfield06:11:18

@andy100jones When you installed Leiningen on Windows, did you go to http://leiningen.org and get to this script https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein.bat and just save that down locally as lein.bat and put it on your path?

randomm char06:11:58

used the link on the front page

seancorfield06:11:17

(that's also kind of a question for you @didibus -- I'm curious as to how folks are installing Leiningen on Windows)

seancorfield06:11:54

@andy100jones That is linked from this text "Download the lein script (or on Windows lein.bat)" on the front page.

didibus07:11:38

Yup, I save it to my home/bin/lein.bat which is already on my path, then I run chmod a+x on it using git bash which has chmod. I think right click, properties, and clicking on unlock would also work to allow it to run, then I go in cmd.exe and run lein.bat self-install

didibus07:11:46

Where I get the download failure

seancorfield07:11:16

OK, so if I delete the .lein folder I should be able to repro?

randomm char07:11:38

derp think the link in the lein.bat files needs to be updated gives a 505 error

didibus07:11:47

Which you can get around by disabling TLS on wget. Oh ya, you need to make sure you've got curl or wget on windows, but I already had that. But after that, even once Lein is installed, I get an error when I run lein, System can not find path. And I remember having that on my old laptop also, and I needed to hack around in the .bat to fix it. This time around I could not be bottered

seancorfield07:11:13

@didibus FYI

C:\Users\seanc\clojure>lein.bat self-install
Downloading Leiningen now...

C:\Users\seanc\clojure>lein.bat repl
nREPL server started on port 54407 on host 127.0.0.1 - 
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_191-b12
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=>
That was after deleting the .lein folder. Sorry I can't repro 😞

didibus07:11:23

Hum, ya most likely. Or just re-running the self-install

didibus07:11:02

Ya, I don't know. The whole windows command line and environment is a huge mess to be honest.

randomm char07:11:33

nm getting tired πŸ˜›

didibus07:11:45

I wondered if it's actually because I install MSys and git bash,and I know that does some things to the windows environment to be bale to simulate some of the unix commands on windows. Maybe that breaks some other stuff lein.bat relies on

didibus07:11:01

Also, this is a corporate windows machine, and it has custom policies. So I can see maybe it being due to a policy forcing a newer version of TLS, which makes the download of lein fail.

seancorfield07:11:25

Ah, MSys... yeah, I've heard of problems with that. I do have Git Bash installed but only the minimal version that is not supposed to interfere with the regular CMD prompt.

seancorfield07:11:54

Maybe Boot really is the easier way to get up and running with Clojure on Windows these days?

didibus07:11:28

Ya, I'll give it a try tmr. Left that laptop at work today

seancorfield07:11:40

(I've been on a Mac for 26 years but my next desktop dev machine will be Windows so...)

didibus07:11:10

Oh ya, why the switch?

seancorfield07:11:37

Tired of Apple not innovating and also breaking dev machine setup with nearly every O/S upgrade.

Lennart Buit07:11:06

hmm, what were you experiencing that breaks

seancorfield07:11:14

Plus not having a good touch screen story. I love my touch screen Windows laptop. I get so frustrated my 27" iMac doesn't have a touch screen!

Lennart Buit07:11:15

the only thing I need to do is keep updating xcode somehow

Lennart Buit07:11:42

all brew-installed software is left as-is

seancorfield07:11:59

@lennart.buit Oh, macOS upgrades randomly overwrite /Developer, or break Apache, or various other things. It's driven me nuts over the years.

Lennart Buit07:11:12

great :’)

seancorfield07:11:36

Like I say, 26 years on Mac and I'm just tired of it.

Lennart Buit07:11:46

I think my companies security software has a chance of breaking my system every update

didibus07:11:02

I've gone full Linux on my personal computers (except my gaming PC). Did that switch 2 years ago, and I'm loving it. openSuse Tumbleweed, rolling release, real solid. It's just the best for doing dev work.

Lennart Buit07:11:11

I got sick of having to maintain my ArchLinux system, I want a dev machine, unix based, for work that just works^tm.

didibus07:11:17

At least for the last 2 years, openSuse Tumbleweed has been rock solid for me. Not a single upgrade broke my system.

Lennart Buit07:11:34

The command line story on windows is just bad, Path variables still scare me and not having a package manager that works is just bad

Lennart Buit07:11:27

Yeah arch is pretty stable as well, it was mostly windows fucking up and breaking my bootloader or NVIDIAs driver hack failing

didibus07:11:45

Its impossible honestly. I tried every trick in the game. Using git bash with MSYS. Installing alternate terminal apps. Using powershell. Scoop is pretty nice, but still, its just not the same.

Lennart Buit07:11:06

but that stuff always happens on that one moment you cannot handle it

didibus07:11:35

Ya, it works like that lol

didibus07:11:41

What I do now. At work, I have a windows laptop, and a cloud dev desktop running Linux. And I use thinlinc [https://www.cendio.com/thinlinc/what-is-thinlinc] as a remote desktop tool (I tried all of them, this one is flawless and hands down the best). At home, I have a gaming PC where I game, and a laptop with Linux for my personal stuff + side project dev work.

didibus07:11:18

If it wasn't for Office + Gaming, I'd be off windows and on Linux everywhere.

Lennart Buit07:11:49

Yeah I have a macbook for work and a windows machine for gaming

didibus07:11:08

I haven't tried mac in a long time. Last time I used it, I think brew wasn't around. And I was annoyed about the fact you could not maximize windows πŸ˜›

Lennart Buit07:11:39

I get so annoyed when coworkers have their windows unmaximised

didibus07:11:40

But I've been tempted to switch my windows laptop at work for a mac one, since the Office tools were updated for it.

Lennart Buit07:11:49

β€œdammit please use your entire screen”

didibus07:11:09

YES! Thank you!

didibus07:11:32

Spectacle looks like what I would have wanted years ago when I had a mac πŸ˜›

Lennart Buit07:11:41

the default mac-maximise is great tho if you are not using multiple screens

didibus07:11:11

I think they changed it though. I just remember it used to maximize but keep the ratio fixed. So as soon as either the horizontal or vertical width was maxed out it would stop. I'd have to manually fiddle to get the other borders maximized also.

Lennart Buit07:11:37

well if you do really maximise now you get sort of a workspace with that app. So when you are just working on the builtin screen you can swipe three fingers to swap between workspaces and therefore apps

didibus07:11:44

That was like 12 years ago or something

Lennart Buit07:11:11

it also hides the status bar thing on top, and the window border

didibus07:11:18

Oh, I see. So its like fullscreen, but you can switch workspace?

Lennart Buit07:11:35

yeah, its basically like iOS apps, but with easier switching

didibus07:11:37

I do that often in linux actually

didibus07:11:44

That's not bad

Lennart Buit07:11:09

not when you are on a single screen. On multiple I get confused

didibus07:11:23

Ya, I can see that

randomm char07:11:35

I think the link to the file in lein.bat is off

didibus07:11:37

I used to be all windows before, even used to work at a Windows dev shop πŸ˜›

seancorfield07:11:23

I've never been satisfied with the desktop experience on Linux so I've always preferred Mac which sort of gives the best of both worlds. And now Windows offers that via WSL so you can actually get a standard Linux (like Ubuntu) rather than Apple's weird Darwin build.

seancorfield07:11:50

@didibus Aye, I've used every version of Windows since 3.11 (WfWG).

seancorfield07:11:17

And I've been an Insider for years, starting with prerelease builds of 8 or 8.1 I think.

didibus07:11:44

I havn't tried WSL yet. But I heard it can be pretty slow. I do have to say, KDE Plasma, is the best Linux desktop in forever, that I have used. I think I actually like it better then Windows 10.

randomm char07:11:45

I hate how MS move stuff around really get annoying from one version to another

seancorfield07:11:48

(WSL was horribly flaky when they first flighted it -- but, build 18272 aside, it's been really solid lately)

seancorfield07:11:17

Re: slow -- true, the I/O is pretty bad. It's good enough for dev but nothing heavy on I/O.

didibus07:11:42

Compared to running a VM?

seancorfield07:11:10

OK, bedtime. Got a long drive tomorrow πŸ™‚ Enjoy your weekends!

didibus07:11:24

Thx, you 2

randomm char07:11:52

till next time gotta catch some zzzz'z before they catch me πŸ˜›

Hadi09:11:56

do you think its normal for having output like that?

didibus19:11:35

It's a bit strange for sure. But Clojure doesn't guarantee logical output for garbage input. The syntax of get-in takes a vector of keys.

didibus19:11:57

Maybe this is something that could be fixed though. The question is, would changing the behavior break anyone?

jaju10:11:36

Yes - it does stump, but then it begs the question - what is a better return value in the get-in case when the key-seq is nil? What if it were () in case of nil? get-in ends up calling seq on the last argument, which evaluates to the same value for both nil and an empty sequence. Since get-in takes a /path/ to project, an empty path returning the original, /top level/ value is a justifiable choice.

jaju10:11:36

But just to be clear - a nil value as a result would have been less of a stump, with an empty path returning the original/top-level value making more sense. It’s probably a result of using seq and depending on its semantics.

Braden Shepherdson17:11:17

I keep finding myself wanting to (update-in {:foo {:bar [a b c {:d 7}]}} [:foo :bar :peek :d] + 3)

Braden Shepherdson17:11:28

that is, I want a magic key that means "last place in the vector"

schmee17:11:33

with Specter: (transform [:foo :bar LAST :d] #(+ % 3) {:foo {:bar [a b c {:d 7}]}})

Braden Shepherdson17:11:40

(though I wish the input data was in the first position, not the last, so it would fit in with update-in and friends. I suppose I can write a macro if I need it.)

lispers-anonymous18:11:38

Is it possible to attach a docstring to a defmulti?

lispers-anonymous18:11:58

I think I see now way down in the documentation (defmulti check-me-out "this is the docstring" (fn [x] x))

macrobartfast18:11:03

what exactly about clojure enables the live coding experience via the repl?

macrobartfast18:11:19

I'm assuming it's not possible in the same way with C# or Java.

noisesmith18:11:13

everything is constructed in such a way as to expect new code to be compiled at any arbitrary time

noisesmith18:11:49

(or recompiled and replaced with a new definition - but there's some clojure warts there with eg. protocols and multimethods)

macrobartfast18:11:43

I've been telling people clj has a special ability in this area, and they usually counter that their language does the same...

macrobartfast18:11:12

but at that point I don't really proceed in the conversation as I don't know presumably what I'm talking about.

macrobartfast18:11:36

I use the repl via cider and love it, that's for sure.

seancorfield18:11:03

@macrobartfast I'll give an example of my workflow: I start a REPL and connect my editor to it, then as I write code, I use a hotkey to evaluate it into the REPL from the editor (so I always write code in the editor, not in the REPL). The magic comes when you start your app from inside the REPL and can live code into the running application. Change the code, hotkey, app is updated while it is running.

seancorfield18:11:29

We also sometimes start our apps on production with a Socket REPL enabled so, again, we can connect to them from an editor (or command line REPL elsewhere) and run diagnostic code inside the live, running production app. We have even applied patches that way occasionally. Just eval a new function definition into the live, running app and the patch is applied with zero downtime.

seancorfield18:11:24

Stu Halloway has a couple of great talks about this sort of workflow: REPL-Driven Development (for the Chicago Clojure group) and more recently Running With Scissors from Strange Loop this year.

macrobartfast18:11:07

well, I'm super into it myself... I mean, I'm sold on it, for sure...

seancorfield18:11:33

Those two talks should really help explain why Clojure's REPL workflow is truly different.

macrobartfast18:11:43

but I always wonder what it is about clojure that enables this... or, put it another way, could, say, a java or c# developer tweak their setup into a similar arrangement, and, if not, why?

didibus19:11:25

1) Clojure can compile itself at runtime. Java and C# need to have a compilation pass first. 2) Clojure can load new code into an existing process at runtime. Java/C# must be restarted to do do so. 3) Almost every construct in Clojure can be reified. That is, swapped out and in at runtime. Not the case in Java and C#. 4) Clojure's syntax is short, concise, non ceremonial, and can be one lined. Making a REPL practical. In Java or C#, you'd go crazy. 5) Clojure defaults to immutable state and favors pure functions. This helps a lot when swapping things in and out, since it is often possible to do so without making a mess of the runtime state.

macrobartfast18:11:18

and thank you for the cool description and validation of the workflow and the video links, @seancorfield!

jaawerth18:11:23

it's a combination of the dynamism, the concise syntax. and how relatively friendly clojure is to reloading a namespace. if Java were more dynamic than it currently is, having to define classes for everything would get in the way of a good REPL experience. Clojure's tooling also lends itself to this in thanks to nrepl and CIDER, which lets you run a REPL and interact with it remotely from your editor in a way that goes far beyond mere code evaluation

seancorfield18:11:19

Clojure's natural compilation process is based on forms. The REPL works just like the compiler: read a form, compile it, evaluate it (define a function, compute a value). Other languages tend to have an interpreter for their REPL or some bolted-on process -- Stu actually talks about that in the RDD talk, as I recall.

jaawerth18:11:24

for example, I often do significant work from the Node.JS repl, and my editor is even set up to let me send code to it, but re-declaring a let or const causes an error, and reloading a module requires hacking into node's module cache

jaawerth18:11:07

and while javascript has a similar dynamism, lisp forms lend themselves better to a REPL than js syntax

jaawerth18:11:20

I guess what it comes down to is that while it's doable in other languages/runtimes (some more than others), clojure and its ecosystem is REPL-forward

seancorfield18:11:53

As Stu says in one of those talks (maybe both of them?), you don't really need source files or anything other than the code: you could just feed one big transcript of Lisp forms into the REPL and that would be your running program.

macrobartfast18:11:19

ok... so it's largely a tooling/approach thing.

seancorfield18:11:28

It's that inherently "baked-in" aspect of the REPL that enables the workflow.

macrobartfast18:11:31

or... emphasis in the language and tooling.

jaawerth18:11:03

largely. the namespaces are a big deal though. with other repls, re-declaring things through a repl's context gets hairier and you have less access to what's going on in your modules

seancorfield18:11:08

Other languages have a fundamentally different compilation and/or evaluation model so it's much harder to have a REPL-based workflow.

seancorfield18:11:52

Stu compares Clojure and Java specifically in one of those talks (since Java has a "REPL" now -- but it's not like Clojure's REPL).

andy.fingerhut18:11:16

I have found that Python interactive sessions are not terribly far from a Clojure REPL, but I suspect even with Python, there might be something missing from that experience vs. Clojure.

jaawerth18:11:03

another example of how clojure is built with this in mind is some of the stuff we're getting in 1.10, namely pREPL, which gives you a REPL with structured output, ideal for (e.g.) socket communication, which is going to lead to even more elegant tooling for building rich REPL experiences

andy.fingerhut18:11:11

e.g. I don't know if anyone take a running Python application and connects to it via an interactive session while it is running

lispers-anonymous21:11:21

I think this is possible in hy http://docs.hylang.org/en/stable/ Which is just lisp dialect written directly on top of python’s AST. That makes me think it may be possible with python.

jaawerth18:11:13

another example: say I'm editing some - in neovim, I use vim-fireplace to connect to cider-nrepl, so I might finish my changes and then run :%Eval from vim - now if I go to the REPL, changes to the namespace I just re-evaluated will be reflected there, and if I call a function in a different namespace that uses the one I edited, those changes will be reflected

jaawerth18:11:45

in node, if I tried to do the same thing, I'd need to nuke the node module cache of not only the module I just edited but also any dependent ones, and then re-require

jaawerth18:11:36

not sure how that'd look with python. python at least gives a friendly REPL experience with ipython so it's a step above many other langs right there. I still find its repl limited in surprising and annoying ways

jaawerth18:11:10

some of it comes back to syntax - python relying on indentation can lead to silly mistakes in a REPL that force you to re-enter things

jaawerth18:11:19

with lisp, you just gotta balance your parens and you're good

macrobartfast18:11:33

well, that's all helpful... so now I understand it's just that repl driven dev is a first class citizen in clojure, but with other languages it's possible, but difficult, and possibly limited.

macrobartfast18:11:36

speaking of repl driven development, I seem to recall getting a ring server started and stopped from the buffer... is it possible to just skip the ring plugin altogether?

macrobartfast18:11:14

configuring project.clj with the plugin seems crufty and also it's hard to start/stop the server then, afaik, without restarting the repl, etc.

macrobartfast18:11:32

this might be a question for the main clojure channel, possibly.

macrobartfast18:11:44

also, you've already been generous with all your time on my other question.

jaawerth19:11:20

I don't think I've ever used the ring plugin - others will probably have better answers on that front, but you could just have a start/stop function in some namespace and call them from the repl - or have it start automatically and then call stop or restart from the repl as needed. Some of this depends on your exact usecase though - sometimes it's nice to let things like that automatically reload for you when you make changes

jaawerth19:11:43

I'm still a journeyman on this stuff myself though πŸ˜‰

macrobartfast19:11:11

cool... that's affirming of my approach... πŸ˜‰

seancorfield19:11:03

I've never used the Ring plugin either. I just have a (comment ...) form at the bottom of several files containing common code I use when developing (Stu called these "Rich Comment Forms" in the Scissors talk -- because Rich does this too). I have stuff like

(comment
  (def system (component/start (build-system)))
...
  (component/stop system))
So I can just put the cursor on a form and evaluate it into the REPL. component/start will start my Ring app (and set up DB connections etc etc).

seancorfield19:11:49

You could also do it with a defonce for your system and alter-var-root to start/stop it.

macrobartfast19:11:50

omg lol... ok... I was using the comment approach on my own (feeling smart all of a sudden ;-D )...

jaawerth19:11:05

"Rich Comment Forms" lol

macrobartfast19:11:05

and I thought it was probably some total anti-pattern.

macrobartfast19:11:27

like, all these comment areas in my code I was using.

jaawerth19:11:30

if there is ever an official Clojure IDE it should be called a Rich Text Editor

macrobartfast19:11:17

because before I used comment areas, I would litter my code with function calls, forget about them, and restart the repl with interesting results.

didibus19:11:39

You can also use the #_ form

Dormo19:11:39

Quick question: I shouldn't have to worry about doing a lein clean or closing down my repls lein repl and lein figwheel before doing a lein uberjar, right?

noisesmith19:11:49

the uberjar task should implicitly clean

noisesmith19:11:07

a gotcha is that sometimes you can define a cljs output target that clean doesn't recognize

noisesmith19:11:18

but I prefer to fix that in clean-targets

Dormo19:11:02

will the implicit clean ever screw with my development environment?

Dormo19:11:42

I haven't ran into an issue yet, i don't think, but i want to deploy several times while developing (test with people, fix stuff, repeat)

noisesmith19:11:44

it should wipe out your js output from cljs, since it would likely reflect a different build

noisesmith19:11:07

with a careful setup you could maybe put unoptimized (dev-time) output in a place that uberjar doesn't wipe out...

noisesmith19:11:30

but I tend to consider uberjar for release a "shut everything down and clean slate" moment, for sanity sake if nothing else

Dormo19:11:12

That's how I was initially treating it, too. Just because I didn't like the idea of deploying something not built from a clean slate.

Dormo19:11:11

Nothing seems to break, though...so shrug

macrobartfast19:11:41

for a minimal rest server, do you use compojure, or just ring?

noisesmith19:11:32

you'd want some router

noisesmith19:11:53

there are good routers that aren't compojure, but ring alone doesn't get you any routing at all

noisesmith19:11:20

bidi is pretty cool, I worked on another one called polaris

macrobartfast19:11:54

ok... probably go with compojure, but will have to wrestle with figuring out how to run it from the code as earlier discussed... have ring now running that way, which is cool.

macrobartfast19:11:11

the compojure docs are highly ring plugin oriented.

macrobartfast20:11:59

I often restart the repl from cider to clear out everything I've defined and get a fresh start... is there a way to do that from within cider without a repl restart?

macrobartfast20:11:40

I mean, I restart the repl from the terminal I start it in.

macrobartfast20:11:48

(I connect to it from cider usually)

noisesmith20:11:04

this is what stuartsierra/component is explicitly for

dpsutton20:11:05

hit , (comma) to get a nice menu. there is refresh which might work for your needs and also restart if you need a bit more

noisesmith20:11:44

right - but your code needs to be written in a way that refresh or restart work properly, which is why component etc. exist

didibus20:11:32

It doesn't, if you're trying to simulate repl restart. Component is when you want to do so while re-initializing things automatically and potentially preserving state.

didibus20:11:44

As far as I know

noisesmith20:11:49

@didibus for example, it can't shut down a server that owns a port

didibus07:11:16

Oh that's true. Cleaning up of resources is a good one.

didibus07:11:02

I do feel though that a lot of beginners get lured into these reloaded frameworks when they don't meed them. And are just looking for cider-refresh like functionality. Not all project and setup need to initialized and cleanup resources on refresh.

noisesmith20:11:00

(you can also do it by hand without those of course)

macrobartfast20:11:06

@dpsutton I'm using emacs in terminal, so the , doesn't work

dpsutton20:11:23

really? that's surprising

macrobartfast20:11:33

what function is it bound to?

dpsutton20:11:45

i have no idea

dpsutton20:11:58

cider-repl-handle-shortcut

dpsutton20:11:34

but i'm surprised that doesn't work in terminal

macrobartfast20:11:01

well, I have a lot of things in my emacs, lol, so the problem is likely on this side.

noisesmith20:11:02

the comma prefix is an evil / spacemacs thing right?

dpsutton20:11:26

no. it's watched for in the repl and if it sees , it shows a little menu

dpsutton20:11:36

vestiges of common lisp, slime, etc

macrobartfast20:11:38

I'm guessing it's a spacemacs thing.

dpsutton20:11:45

CIDER thing

dpsutton20:11:06

it's defined in the cider-repl-mode-map

macrobartfast20:11:29

this discusses the component approach too.

didibus20:11:37

You don't need component. Cider-refresh will unload everything and reload, as if you had started a fresh REPL.

dpsutton20:11:42

the comma works for me in terminal mode. emacs -nw and when i hit , in a CIDER repl i'm given a quite nice menu

dpsutton20:11:11

lol. and "hsata la vista" means quit

pablore20:11:28

I’m trying to connect mount with ring’s run-jetty, but when I start it, the repl hangs indefinitely. This is my code:

(defstate Server
   :start (run-jetty handler {:port port})
   :stop (.stop Server))

pablore20:11:47

(I don’t even know if a jetty server has the stop method)

manutter5120:11:11

Try adding :join false in the options to run-jetty

manutter5120:11:47

:join defaults to true, and blocks until the server exits.

dpsutton20:11:24

might be some inspiration here

pablore20:11:03

Thanks for the tip @manutter51 but the repl is still hanging for some reason… @dpsutton thanks for the inspiration! So stop and join must be called to stop the server….

pablore20:11:52

Ohhh it was :join? ! As the official documentation says: https://ring-clojure.github.io/ring/ring.adapter.jetty.html

manutter5120:11:54

Whoops, sorry, should have cut and pasted

pablore20:11:25

no prob, thanks for the help