Fork me on GitHub

I am a total beginner to programming so please excuse if this question is very rudimentary. I am beginning to learn Clojure using the book Clojure for the brave and true. I have successfully installed Java, Clojure, and Leiningen. The first step is to run lein new app clojure-noob When I do so I get the following response from my terminal Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release. Generating a project called clojure-noob based on the 'app' template. Could not create directory /Users/Pascal/clojure-noob. Maybe it already exists? See also :force or --force according to the book I should be getting a response as follows | .gitignore | doc | | project.clj | | resources | src | clojure_noob | | | core.clj | test | | clojure_noob | | | core_test.clj Please any help would be appreciated. I am really excited to begin my coding journey.


You can ignore the "were deprecated" warning line, I think. Should be harmless.


The "Could not create directory ..." message I can only reproduce if I do the command twice -- the first time it succeeds, the second time it gives that error because the directory was already created by the first time I ran it.


I would suggest checking to see if there is a clojure-noob directory, and if there is, delete it. After you have confirmed you have deleted it, try the lein new app clojure-noob command again.


Thank you, not sure if that is because even try to create a file with a different name it says could not create a directory maybe it already exists


Perhaps it is a permissions issue and for some reason you don't have permissions (in your home directory?) to create new files. Are you on macOS or Linux? And what version of macOS? (they've been making it increasingly unfriendly to developers lately, IMO)


welcome to Clojurians, @U01JFA3F1A5! 🙂 judging by "/Users/Pascal/clojure-noob", you must be on macOS. in your home directory (which is "/Users/Pascal"), execute the following command and report back what you get in the output: lein new app clojure-noob --force && find clojure-noob

🙏 3

you should hopefully get an output that looks like the following and if you do, congratulations, you did it!

Generating a project called clojure-noob based on the 'app' template.


@diego559 If you have more questions, you can also consult #adventofcode


Is there a shorter way to write this? I know there is the & operator that gives all the rest of a list, but I cannot get it to work. Also google is really bad for the search of a single character

(->> (number-formatter "1234567890")
     (apply #(format "(%s) %s-%s" %1 %2 %3))) ;; &% instead of %1 %2 %3?

Max Deineko10:01:34

%& should do it


to be clear there are no operators in clojure, & is a destructuring syntax, and %& is a magic symbol inside #() that is translated into a destructured binding

👀 3

(I call it magic because % tokens inside #() don't even follow normal parsing rules)


Hi, shouldn't you replace the #() form with a (fn [& args) (apply format "(%s) %s-%s args)


I'm not sure to know what is number-formatter


custom funtion, that returns a list with three elements


I never think of the fn and always do #()


I'll try this


(defn number-formatter[str] (list 1 2 3)) (->> (number-formatter "1234567890") (apply (fn [& args] (apply format "(%s) %s-%s" args))))


it works here: "(1) 2-3"


Hm. Not sure if this is prettier:

(apply #(format "(%s) %s-%s" %1 %2 %3))
(apply (fn [& args] (apply format "(%s) %s-%s" args)


I must confess I share your point


another way is destructuring


I'm surprised there is no &% that I can just use to throw everything in that migth come.


you already found a better solution, but fwiw there's such a thing, just spelled backwards:

user=> (#(apply + %&) 1 2 3)


(apply format "(%s) %s-%s")


Now it's pretty. Thanks for the input, it made me think about what apply does


ah ok, I was wondering why you have that first level of apply


I understand now


What the hell does the brave book wants me to do here :

You used (comp :intelligence :attributes) to create a function that returns a character's intelligence. Create a new function, attr, that you can call like (attr :intelligence) and that does the same thing.


this is the example

(def character
  {:name "Smooches McCutes"
   :attributes {:intelligence 10
                :strength 4
                :dexterity 5}})
(def c-int (comp :intelligence :attributes))
(def c-str (comp :strength :attributes))
(def c-dex (comp :dexterity :attributes))

(c-int character)
; => 10

(c-str character)
; => 4

(c-dex character)
; => 5


so it looks to me I have to write a function that takes out a attribute and prints it Am I right ?


"Create a new function, attr, (...)" means that it wants you to create a new función with the name attr


My best guess is that's is the problem


so you have (c-int character) that takes a character and gives you that character’s intelligence


now it’s asking for you to make a function attr that takes the keyword of the attribute :intelligence and returns that number (attr :intelligence) => 10


@roelof: perhaps it wants you to parameterise one of the elements in the comp function (without giving the answer away)…

Old account11:01:18

is compojure, reitit and pedestal same sort of thing?


compojure and reitit are routers, pedestal I’m not sure of, I think it has some relation to interceptors


I guess pedestal is more like a framework, a bigger thing


@stebokas All three can be used to make web services. Pedestal has more stuff out of the box, but otherwise they’re quite comparable and a simple hello world example can be made in just a few lines of code in each of them. • Compojure uses the Ring handler model (functions wrapping functions) and a more traditionally Lispy way of defining routes using macros called GET, PUT, POST, etc. • Pedestal is a data-oriented library for making web services made by Cognitect (the company maintaining Clojure). It uses Clojure data for everything: defining routes, data for setting up servers, and data for defining its alternative to Ring handlers (interceptors). I like it a lot. • Reitit is sort of Metosin’s clone of the routing portion of Pedestal (with Metosin’s Sieppari being a clone of the interceptor chain). It is more actively maintained than Pedestal currently is and according to Metosin it’s slightly faster too, but currently not as feature complete - and not aiming to be - but unlike Pedestal it can be used in the frontend too (i.e. in ClojureScript). Obviously, there are other things to say about it too, but I haven’t used it myself.

👍 3

@schpaencoder Shhhh! We don’t use the F-word around here 😛

😮 3
😁 6
Old account12:01:15

fu-ction :face_with_hand_over_mouth: or is it f-mework 😄


what about fulcro?

😄 3
😅 3

The taboo is actually so strong that even fulcro doesn’t dare call itself a framework on its Github page. The F-word is used on the Fulcro website, but hidden away in a testimonial at the bottom of the page 😉


@stebokas it’s of course not function :)

😂 3
Old account15:01:12

but this taboo is ridiculous because for example ring calls users code :thinking_face:


thx @simongray, that kind of synthesis is not easy to find

🙏 3
Harley Waagmeester12:01:17

are there any performance or idiomatic concerns that would dictate choosing between using 'alter-var-root' or using atoms ?

Alex Miller (Clojure team)14:01:09

you should probably use atoms for most things where you might ask this question


I've usually seen alter-var-root done for monkey-patching, eg. for debugging / diagnostic purposes - agreed that atoms are the go-to for mutation


@U01EFUL1A8M is that the right link? I don't see alter-var-root mentioned at all


@U051SS2EU yes, but it seems to be a good primer or inspiration for atom/ref etc. usage. I didn’t even know alter-var-root existed until now. I guess it is used in very specific cases, while atoms (and the other constructs) are more typical.


Programming Clojure also has a nice section about these constructs if I remember correctly btw.

Harley Waagmeester17:01:05

@U01EFUL1A8M thanks, that's a great read

👍 3
Harley Waagmeester17:01:35

anyways, i'm considering transactions now


in practical usage transactions / refs / agents are special case tools and not what's commonly needed


the normal approach is an atom holding a hash map with all the related state


refs end up being an optimization when the contention of one atom is a bottleneck (rare)

Harley Waagmeester17:01:43

i'm using an internal database of atoms that are vectors that hold data, it works slick and cleans up spaghetti code by separating formatting and report generation from data acquisition which is difficult if i try to be immutably iodiomatic, i'd really like to be a clojure functional guru... but alas my roots are imperative from my C upbringing


the normal way to do this would be a single atom holding a hash map from some key to a vector


or better yet, to use a pipeline from data acquisition to report generation rather than storing the data in a place as program logic

Harley Waagmeester17:01:32

hmm.. i use a hash map of keys to the database atom s


atoms inside hash-maps is a code smell, a single atom holding that map is almost always better


(not to say there are no exceptions, but those are rare)

Harley Waagmeester17:01:32

sure, i can try it differently, i might like it better that way


functions like update / update-in when combined with swap! make this straightforward


(it's definitely clumsy without them)

Harley Waagmeester17:01:58

yes, the database gets re-populated often as it just holds information from external programs that are executed, so i actually have a loop construct that resets all the atoms, if have there is just one atom to reset that is far less clumsy, i always start out with a huge mess of code that i perfect when i finally realize what i am doing after someone tells me what i should do 🙂

Harley Waagmeester17:01:15

@U051SS2EU thank you, your insight is really impressive


shoulders of giants, years of suffering from my own mistakes, and all that 🍻


Hi folks. I've been slowly trying to put together a set-up for ClojureScript, and recently got a recommendation to go with the 'Clojure CLI tools'. I just got out of the long prerequisite step of installing WSL2 and Ubuntu and getting it to actually work, but now I'm having a hard time finding a guide on what to do next. None of the resources I've found on Clojure CLI tool installation mention anything about WSL2. What should I do next?


I think you will find better leverage by installing directly on windows as oppose to going through wsl


What setup are you looking towards having? Like what editor are you planning to use?


Oof. I had used Leiningen before, but then got steered in the direction of WSL2 and ClojureCLI. Just manually updated Windows (no idea why my computer said it was 'up to date' when it was two whole Windows version behind!), and got WSL2 with Ubuntu working. Are you saying I don't need any of it?


Actually, where do Clojure CLI tools get installed? Windows, or the Linux VM?


(and if the VM, then would it have to keep getting re-installed every time you run the VM??)


I'm abit unsure about clojurescript - I just remember my friend was able to get things working better through windows


actually ....


What are you looking to do with ClojureScript exactly?


@UH5SE3NM9 I think you might have been beating on the wrong bush. I think for set-up, what you should either be looking at is or

Alex Miller (Clojure team)14:01:43

but if you're doing WSL2, then just the normal linux instructions on are probably the right answer

👍 3

I did take a stab at using shadow-cljs in my second-latest attempt to into CLJS again a few months ago, but it went off the rails. The guide just started to make less sense. 😕


By the way, at that figwheel page you linked to, @UUSQHP535, it mentions Clojure CLI tools on an Apple machine only.


No mention of WSL(2) I can see at any of the links actually.


I don't know how I ended up with this to-do list: 1. Install WSL2 (which requires a huge Windows update) 2. Install Clojure CLI tools.


@seancorfield I think the recommendation came from you. What am I spacing out on?


Thanks for the help so far by the way, all.


I guess I might try again with Leiningen and/or shadow-cljs


What's your IDE?


I see the benefit using VS Code on the windows host and have all the code run on the wsl


but I know nothing about emacs, sorry


> (and if the VM, then would it have to keep getting re-installed every time you run the VM??) No, the data persists. Do you lose your data when you turn off your machine? It's the same thing. WSL is your best bet imho, for the sole reason that it offers a proper bash experience. Just fire up WSL and follow the clojure cli tools installation instruction for linux, like @U064X3EF3 said.


Neither do I. 😉 ...but with the many, many decisions to be made about the toolchain (is there a better term to use?) I've already settled on Doom Emacs + CIDER.


@UEQPKG7HQ Great to know (about the persistence). Thanks.


The thing about wsl is, that you have a command line linux right in your windows. You can even access all the files. With wsl2 you can even use the gpu for calculations


Here is a guide to use emacs on windows that runs from the wsl:


@U01E6385CN8 Thanks. I will take a look. I will have to find something that discusses Clojure at some point too. I did not even know I had to do separate reading on just getting Emacs and WSL2 to play nicely together, though!


By the way, I keep getting pulled away from the computer, but I will try to check in on this thread throughout the day. In any case I should be on more consistently this evening.


I hope I can stick with vs code and don't have to switch to emacs for some reason. learning a language is hard enough, I wouldn't want to learn a dwarf-fortress-y IDE on the side.#


If you do try it, we can talk. I'm a noob at that too. org-mode is amazing though. It alone is worth the the price of admission to some people, I hear.


I had just heard Emacs+CIDER was the best for Clojure.


After trying Emacs I didn't love the heavy use of key chording (with Shift/Ctrl/Alt) and could imagine RSI from it, so I looked a bit further and found Doom.


I also tried Vim and found it kind of mind-melting, but I'm game for short-term pain for long-term gain.


@UH5SE3NM9 You can always run emacs in terminal mode from within wsl (`emacs -nw`) if you don't need the GUI. You can also ask at the #emacs channel, I'm sure others before you have faced similar issues. @U01E6385CN8 switching from an IDE to emacs was definitely one of the best decisions I've made in recent years, for various reasons, but you're right. Trying to juggle learning emacs AND clojure would definitely have been hard.


@UEQPKG7HQ I have not tried the non-GUI Emacs yet, but Doom strips away the menus and even some of the info bar stuff (which I want to figure out how to get back!), so maybe terminal Emacs wouldn't be that bad.


Why exactly was the switch worthwhile to you? I'm committed to trying to learn it all at once, but it would still be good to know (and @U01E6385CN8 might want to know too. 😉


I'm all for learning it all at once but don't overdo it or you might get frustrated enough to quit both 😛 > Why exactly was the switch worthwhile to you? built-in ergonomics: • distraction-free environment/complete lack of annoying menus and sidebars • the keyboard is a first class citizen • much more lightweight than probably every fully-fledged IDE out there (advanced static analysis can be helpful but having it enabled all the time has its drawbacks; I was having memory issues with intellij/cursive on a machine with 16GB with just a couple of repls open and a browser) • extreme customizability (in lisp!) • version control your emacs.d directory and you have your emacs setup everywhere you go org-mode, magit, dired I could go on... I'm a new user too (~2 months in) but I don't think I could ever go back edit: multicursor has also been really useful so far! edit2: CIDER/clojure-mode too, obviously! ---------- Having a uniform environment is definitely a big deal. Everything is a buffer and interactive: magit status/diff, source/text files, directories. One major issue beginners (including me!) have with emacs is that you have to like learn 10 combos by heart to be even remotely productive but in the long term that's a good thing. Because the experience is consistent!


@UH5SE3NM9 people have suggested WSL2/Ubuntu because then all of the tutorials for macOS/Linux will apply -- I am using VS Code (on Windows, with the Remote-WSL2 extension) and everything Clojure-related runs on WSL2/Ubuntu, so I don't have to think about Windows at all: I can follow any tutorials out there. I'm just getting back to ClojureScript after a long absence, and I'm using the Clojure CLI and Figwheel Main (on WSL2) and just following the docs on and it all "just works".


I used Emacs on and off for years but switched to Atom about four years ago and then to VS Code in the last few months.


(I got tired of spending so much time caring and tending for my Emacs configuration and wanted something that "just worked" and kept itself up to date!)

👍 6

@UH5SE3NM9 I use doom emacs and cider. If you are new to emacs and are doing clojurescript. You will likely find better leverage using vscode! It can be quite daunting trying to pick up both a new language and emacs at the same time. And cider can be improved for ClojureScript support - also because ClojureScript just generally has more moving parts


I think you are referring to brew ? People mainly use it for apple. And while I personally don't use it. You can definitely use it in Linux and by extension wsl


If you do want to stick to emacs (which I have a feeling you will 😅) and have doom emacs specific questions i can try to help (there also a very helpful discord channel with the creator and there's a small telegram group if you are interested) tho I understand your main problem is wrt setting up for ClojureScript.


@UUSQHP535 Great. I have haunted the Discord channel with a few painfully nooby questions, but I might reach out to you about it too. I must say, it should be made impossible for anyone to install Doom Emacs without coming across huge bold text stating that reflex hits of [Ctrl]-[z] and even [Ctrl]-[v] will gaslight you. I hit C-v to try to paste something, saw what looked like horrible mangling of my text (just a page-down, but looks a lot like deleting a page of text), then hit C-z to reverse the changes only to have that not work and instead break some shortcuts and/or enable others (no idea it switched between normal shortcuts and evil/vim shortcuts), then just quit the program and lose work and curl up into a ball in the corner just to escape the insanity.


Yeahhhh ... thats why learning emacs and clojure might not be super ideal 😅 i use emacs bindings within doom emacs btw (non EVIL). I had a year of using emacs as my daily driver before, exploring clojure :x


@UH5SE3NM9 It's pretty fair to say that any Emacs distro in its default setup is going to have a very non-intuitive set of key bindings and that the "default, normal" key bindings people expect from every other editor in the (modern) world are going to do "Bad Things(tm)".


This is the doom emacs telegram group is @doomemacs btw


Oh, and I had to go through the process above multiple times before piecing together what exactly was going wrong---what 2 shortcut key combos that until Emacs had been universal and were at muscle-memory status were hijacked by Emacs/evil for other functions.


That's not really fair: Emacs has been around since long before modern editors standardized on different key bindings.


I did have a couple of 1- or 2-month bursts of using Emacs before, but never to do anything productive because the learning curve didn't allow for it.


@seancorfield Absolutely. I just mean they had been universal in my experience.


When Emacs appeared, there really were no conventions for copy/paste/etc. Emacs picked a set of keys and consistently kept them for many decades. I started using Emacs in the 17.x days in the mid-'80s. I stopped using it day-in, day-out in the 19.x days some time in the '90s. Then came back to it once I started doing Clojure (I think late 23.x days?).


The problem i guess was that emacs was consistent but keyboard layouts weren't 😅 thankfully i am using a split keyboard with thumb clusters


Also, Ctrl-v and Ctrl-z are baked right into the OS I'm using (Windows, and isn't that the case in at least most Linux distros too?), in addition to every program I'd ever used before, hence the 'hijacking' viewpoint, despite the history completely explaining it. 😉


I'm not writing Emacs off for it of course. If its the best I'll work for it. I battled typing like a 2-year-old to learn the Dvorak keyboard layout and I'll battle through this.


Should I maybe go with winner-mode, though? I kind of want to give Doom Emacs a good long try before thinking about changing anything, but...


@UH5SE3NM9 As I've said, I experimented with a bunch of editors when I learned Clojure -- including Emacs -- but happily switched to Atom and now VS Code. I think if you have experience already with an editor you like, you should just stick with it (as long as it supports Clojure).

👍 3

I honestly don't see any compelling reasons for folks to switch from their current editor to Emacs, unless they actually want to learn Emacs.


I can see it being hard to learn something when every other piece of software is a force in the opposite direction.


^ and in the learning emacs case oftentimes doing learning emacs and clojure simultaneously is a recipe for disaster 😅

👍 3

The only editors I've used have been Eclipse for Java and NotePad++ for HTML and CSS.


Ah, there used to be a pretty good plugin for Eclipse but sadly no more. IntelliJ/Cursive might be more familiar to you? (and more productive for learning)


I'm OK with not knowing how to perform a function and having to look it up the first 10 or 100 times. Unexpected effects are the only real problem. Maybe winner-mode would prevent most or all of that. I'm just afraid it might break something about Emacs or Doom.


I also thought it might rob me of the opportunity to get on board with the better Emacs way (of 'yank' etc)...but now that I write out the problem and no I'm not going to stop using C-v and C-z as usual just about everywhere else, I think I'm ready to figure out how to make just that one tweak to Emacs/Doom.


I believe there are Emacs modes that install "sane" (modern) key bindings for at least cut/copy/paste/undo -- but I've never tried them.


Are you getting confused about both vim and emacs keybindings? If you want to continue with emacs. Maybe spacemacs or emacs prelude (maintained by the creator of cider) might be better?


@seancorfield I think winner-mode does exactly that.


Theres also a emacs "distribution" which does that. Believe that was what he is referring to


I like that I can go between almost any macOS app and my editor and have the "same" key bindings, and also between any Windows app and my editor. And that I have the exact same key bindings in my editor on macOS and Windows for all the Clojure-related stuff.


Correction: I just looked it up and it does nothing like that. My mistake. winner-mode instead makes includes window manipulation actions accessible by the undo and redo commands. Also neat.


😅 yes ... I can be a pain when I leave emacs and keep trying to copy and paste with c-w and c-y

😂 3

@seancorfield What keybindings are you referring to?


Just the main 5? copy, cut, paste, undo, redo?


...and maybe select-all.


Since I stopped using Emacs four years ago, I no longer have to think about that :rolling_on_the_floor_laughing:


but are those the ones you were thinking about when you wrote that?


Pretty much all key bindings behave the same across all apps and my editor, on each platform (yes, those key bindings are different between macOS and Windows to some extent, but they are still "internally consistent").


ctrl-f = find (cmd-f on macOS). ctrl-g = find again (cmd-g on macOS), cut, copy, paste, undo, ctrl-s = save (cmd-s on macOS)... etc etc etc


Emacs throws that whole thing out the window... 😐 including terminology around "window" etc 🙂


Don't get me wrong: I totally understand the power of Emacs and its ecosystem -- it's pretty much an operating system all on its own, and it has an IRC package (which I used a lot in my early days with Clojure) and email and usenet (anyone remember that?) and org-mode (which I admit I never really "grokked") and so on.


And I might actually consider Emacs again if it had a decent socket REPL client for Clojure (it doesn't).


But I don't use/want CIDER or nREPL or any of that middleware etc. I want a plain socket REPL and I want sane key bindings for every action.


Then again, I guess I could take the plunge into vim bindings. I only tried out vim for a few hours once, but I heard it's so-o-o good eventually even though it's hard to begin with.


What's wrong with CIDER (he said, finally getting back on topic about Clojure/ClojureScript)?


I had heard Emacs+CIDER was the most popular and best choice for clj(s) development.


I used vi for years in "ancient times" but I never found it productive for anything beyond very simple text editing and I cannot use it for Clojure -- I tried (because it has a plain socket REPL integration via Conjure, at least for neovim).


Popular != best.


I think it's cargo-culting. A lot of early Clojure adopters used Emacs and slime and then cider became "a better slime" but foisting Emacs on new Clojure developers is actually holding Clojure back.


I fully agree that popular =/= best. I heard it was best and popular (and with the popularity comes easier-to-come-by help resources, I reasoned.


Over the years, Emacs usage has dropped in the Clojure community to 43% (from maybe 70% in the early days?)


IntelliJ/Cursive has grown to 32%


VS Code is next at 10%


Oh hey, I just stumbled upon one of your videos yesterday, I meant to mention! ...and in it you use Atom?


Yeah, those videos are Atom/Chlorine. I use VS Code/Clover now but it's pretty much identical.


I used REBL in those videos, I use Reveal now.


Looking back at State of Clojure over the years, back in 2014, Emacs was already down to 43%, but IntelliJ back then was only 14% with vim just behind it.


By 2020, vim had fallen behind VS Code.


(and Atom was only a few %)


Where is all this editor choice data from?


State of Clojure survey results through the years


2013 and earlier seem to have disappeared after Chas Emerick reorganized his website.


I'm not seeing that info. If I search for 'editor' on that page, or even on the page for 2020 linked to at the bottom, I get no survey results.


Nevermind...they used 'development environment'. People don't think about searchability enough...


I might try Cursive, but only after I've put together a working project with Emacs or if I really hate it before that point. Actually I will try it (but not until then). I won't know what I'm missing if I don't.


I just searched for emacs 🙂


Yeah, searching for 'emacs' was my 2nd approach


I hate Cursive more than Emacs -- but it's IntelliJ I hate really. I always have. I tried many versions -- IntelliJ even gave me free licenses (as a vocal blogger, hoping I would review it favorably). I just hate it 😞


Oh wow. I retract my earlier statement.


I guess I could try VSCode


They gave me free licenses for three different versions I think, over the years. I never wrote a negative review tho'. I just don't think that's fair. Editors are so very subjective.


What do you think of LightTable and...the other one whose name escapes me.




I quite liked Eclipse (but would never want to go back to it now). LightTable was great at the time but has been unmaintained for years.


Those are specifically for clojure, right?


NightCode is too simplistic to be useful for real projects.


I used LT for quite a while (switched from Emacs to LT but then switched back to Emacs).


I was thinking Emacs would be better because it can be used for more things, but maybe that's not how I should be thinking. I spend a long, long time trying to decide on the best language for me to learn (that could easily or at least plausibly run on desktop+mobile+web), and I've already committed to clojure(script), so I really should be open to clj(s)-centric editors.


I don't think there's any single "best" anything. It all depends on the trade offs you want to make.

👌 3

For me, in the context within which I work, VS Code is perfectly suitable (we're an Atlassian shop at work and the Jira/BitBucket extensions for VS Code are great; and git support in general is really good).


I'd like better parinfer/paredit support in VS Code (Atom was slightly better overall, but better in some areas and worse in others).


Not sure what adjective to use. I just wanted the best choice for me, my goals being to maybe program for all those platforms.


Magit in Emacs is pretty darn good. Paredit is obviously great in Emacs (but I don't know if there's a Parinfer package?)


So you went Emacs-LigtTable-Emacs-Atom-VSCode? Wow


Are paredit and parinfer in competition or would a person use both? I think the clojure...thing (not mode, but can't remember the term) for Doom Emacs has one of them by default...parinfer I think.


And I used several different things before that.


Lots of people use both parinfer and paredit


I change my editor setup quite often -- because I don't believe there is a single "best" and I think even the "best trade off" changes frequently over time.


Maybe I'll be tweaking Doom Emacs more than I thought, sooner than I thought. Sigh.


Trying to get back on track for now, though...I finally did get WSL2+Ubuntu working. It only took my spare time over almost a week. lol


Sorry 🙂 But at least that should only be a one-off task!


I'm trying to figure out how to install Clojure CLI tools, which I vaguely recall was to be the next step.


Have you installed linuxbrew on WSL2?


(type brew on Ubuntu and see what it says you should apt install)


Someone back in this thread mentioned that WSL2 instances of Ubuntu are persistent, so things can be installed there.


Absolutely, yes.


Is it persistent even through rebooting my laptop??


Almost everything on this Windows laptop is actually on WSL2.


Yes (I'm not sure what that is so surprising?).


Microsoft are very serious about bringing in developers by having WSL2 be really solid.


Well in the YouTube video I followed for installing WSL2, the person demonstrates the commands 'exit' and 'shutdown'. I thought for sure shutdown would wink the thing out of existence.


You might also want to install the new Microsoft Terminal (I think you can get preview builds from the Microsoft Store? I started with prerelease builds from GitHub)


You mean an updated cmd? or powershell?


It's a wrapper that provides a tabbed UI around any number of shells you want, including cmd, PS, and Ubuntu


The new tab menu in Microsoft Terminal:


I use lispy. Makes things much easier if you sit down to learn it


It is paraedit but with 1 key bindings


I'm stuck atm. Through this whole clojure set-up process I'm writing up the steps so I don't have to go through this pain again, and I'm doing it in Doom Emacs to learn it...but I can't figure out how to undo an accidental deletion of a bunch of my text


I'm even pressing the correct undo shortcut ('u'), but It just toggles between like latest state and the second-last state, like barebones Notepad!!!! This is crazy.


How about you remove evil mode for now ...


I might resort to loading a previous version of the file to grab that chunk of text. Unbelievable.


I do know I just hit C-z to toggle evil-mode on and off.


It might help to use undo tree ... you probably recursively undid stuff


but if I switch out of evil-mode I have to look up what the undo command is in plain emacs, and it's not as intuitive as 'u'. It's something more annoping.




Errrrrr but are you familiar with vim


At this point you are learning a hybrid of vim and emacs ... as you navigate clojure ... not sure how to describe how bad i feel this endeavour is 😅

👍 3

I'm not familiar with vim other than dd and u. lol


I do know Doom Emacs uses undo-tree


I just looked up the undo-tree webpage and my brain melted after the 1st paragraph.


I guess I'm just supposed to hammer 'u' potentially many times, even if it looks like it's not doing anything, because eventually it will get me back to where I want to be??


Yeahhh which I why i really suggest you pick either emacs or vim first 😅 and not both


Hey it worked! ...but I overshot the mark. Now to look up how to redo. Sigh.


Well I have used emacs in the past, just not a ton.


And for emacs, it might be good to use either or


I hadn't heard of prelude, but I did seriously consider spacemacs until i heard doom emacs was basically the same but better


Oh, and I'm not seeing the tree graphic shown on the undo-tree page. maybe it's something else


@seancorfield I'm about to give up on undo-redo and just reload my notes, and just install Windows Terminal. Is it a replacement for cmd and powershell and the WSL prompt??


Prelude is done by the creator of cider. It sticks with emacs defaults so it is less complicated


ARGH. I am following the directions here, but I can't get undo to reverse direction and redo. It just keeps eating away more of my text!!!!!


@UUSQHP535 Do you know how to redo?


Look at my config


My undo is C-/ and redo is C-/ with shift


@UH5SE3NM9 I answered that over half an hour ago: "It's a wrapper that provides a tabbed UI around any number of shells you want, including cmd, PS, and Ubuntu"


And that links to the Microsoft Store where you can install it (and the preview version).


BUT I just get the error message 'C-? is undefined'


Nothing is working to redo!


@seancorfield Sorry. I must have missed that older comment.


NP. It's a fast conversation 🙂


@UUSQHP535 Finally got rescued from my undo-redo fiasco thanks to a kind soul on the Doom Emacs Discord channel (and no thanks to answers on StackOverflow that did not work for Doom Emacs at least:


With Doom Emacs -- C-/ for undo works, but -- C-g C-/ for redo does just undoes more! and -- S-C-/ (i.e. C-?) for redo, required for spacemacs and prelude apparently, also does not just throws the error 'C-? is not defined'


With Doom Emacs, AFAICT you need to be in evil-mode (toggle in and out with 'C-z'), and then it's: -- 'u' for undo, and -- 'C-r' for redo ...pretty nice actually...once you know it!


Yeah S-C-/ is my own key binding


@UUSQHP535 Ahhh. I finally accomplished a tiny something (though not in clojurescript yet). I dusted off my StackExchange account I haven't used in years and posted the answer for Doom Emacs users I could have used a couple of hours ago at


@seancorfield Following your question about linuxbrew... I get: $ brew Command 'brew' not found, did you mean: command 'qbrew' from deb qbrew (0.4.1-8build1) command 'brec' from deb bplay (0.991-10build1) Try: sudo apt install <deb name>


I have not done anything to the VM yet.


I guess I'll just follow the Linux installation instructions here:


Oof. I guess I'm back to needing to install Java and everything, only a different installation procedure (for Linux) this time...


Actually since this thread is so long (and I've derailed it so many times), and to help make the info more findable, I think I'll start fresh. New post in main #beginners thread incoming...


For a bit of background, I went through the quick start guide a year or two ago and made an uber-simple webpage that used ClojureScript. I'm trying to get a more fleshed-out set-up ('toolchain'? what should I call it?), but am having a really hard time getting all the pieces together. After about 3 weeks of spare time spent on this I'm still not at the point of entering a single line of code and it's demoralizing.


@hobosarefriends @schpaencoder I have no clue that is why I asked here. Bummer that most of the challenges in learning book are so vague..


I’m certain it’s asking for a function named attr that takes in a keyword :intelligence and returns the attribute for that key.

(defn attr [k] ~your code here~)
(attr :intelligence)
=> 10


how to get the sub string of a string in clojure, ex- hello@word, i want string before @ expected output is hello ?


There are regex matching functions that can pull apart pieces of a string if you are familiar with regex matching, e.g. re-find and re-match.


If in this case you simply want to find the first @ character and get everything before that, there is the Java .indexOf method for looking for the first index of a paraticular character in a string, and the subs Clojure function for getting a substring of a string based on first index and number of characters.

andy.fingerhut14:01:41 has some examples of using those functions (except .indexOf, since it is a Java method, which you can do Google search for the API)


there’s also clojure.string/split if you want both the before and after of the @


(clojure.string/split "hello@word" #"@") => [“hello” “word”]


will try 🙂

👍 6

in my example index-of helped , Thanks 🙂


which channel can I use the best for web development questions ?


I’m not aware of a channel for web development existing specifically, there are however channels for most of the libraries you’d use. I’d recommend asking about general web stuff here or maybe even #clojure, and once you decide on what libraries/approach you’re going to take you can ask more specific questions in the channels for those libraries.


for a tutorial of a web related things, I believe I’ve seen people to point to and for an example springs to mind.


To be honest I haven’t looked much at either, maybe someone else has suggestions with more experience behind them.

Malik Kennedy15:01:26 Also has some Clojure and ClojureScript example/real-world web projects


was more thinking of tutorials to learn to make websites and choose my own parts


and if I then make such a layout with some reactive parts like going to the next page or showing some info


Why doesn't this work?


(map (take 2) [[1 2 3] [1 2 3]])


I know the right way is


(map #(take 2 %) [[1 2 3] [1 2 3]])


but (take 2) evaluates to a function


it returns a transducer, not a partial application of take

✔️ 3

Team I have a json structure , How can i fetch the data between { and }, Can that be possible in clojure regular expression ?

#json structure 1
  [json structure 2
    {json structure 3


Parse the json to edn then acces the subtree you want via get-in Regex generally not a good idea for this stuff.


output is json structure 3


if the json is restricted enough it's possible with regex, but the normal thing would be to use a json parsing library


clojure or cljs?


but how can give prefix and suffix to { and }


a json library eg. is simpler and less fragile than a regex


but to literally answer the question, you would need "\\{" and "\\}" to escape the special meaning {} have in regex


@popeyepwr but consider what happens when structure 3 has another } inside it


which is why we have actual parsers to construct real data structures, like data.json


yeah i understand that we should use data.json, but i get the text of file where i need to fetch those words


i'm not sure i follow that objection. data.json will parse text to return data structures


@seancorfield do you have some tutorials or pieces I can study so I can learn web development when I finish the brave book


Maybe start with James Reeves's talks listed here


@roelof I don't know what to recommend. I suspect the Web Development with Clojure book will be too advanced for you right now -- but that's normally what I recommend for people who've mastered the basics. I would suggest playing with and reading the code and making sure you understand how that all works before you buy that book.

Pavel Klavík19:01:32

Web Development with Clojure is ok book but ignore the first chapter since it introduces everything and explains it in subsequent chapters. There are a few difficulties you will have to tackle. Understanding web development in general (HTTP, HTML, CSS, JS, using DB). Understanding Clojure specific libraries. And learning how to put everything together. In my case, I just started with frontend, playing with React, Reagent and Re-frame. I added backend several months later, following Web Development book. I would recommend by building a small app and learning everything along the way.


☝️:skin-tone-2: Definitely this: start small (with perhaps just Ring if you're building a back end server-side rendered app, or just Re-frame if you're building a front end only app) and make sure you understand that before adding more things.


Web dev with Clojure is "simple" (in the Clojure sense) but it is definitely not "easy".


There is a lot of fragmentation and paths and variants and minutiae advantages to libs, it takes a long time to make a mental map of the landscape


first project I had in mind was to make a front and back-end app where I display some data from a external api


and I it is no problem that It takes a long time


and im willing to start very simple if needed


assuming you already grok http, my preferred path would be: start with & (get familiar with each middleware in ring-defaults), then, then maybe and - this be just the backend (api or classic html generation) for frontend / spa: & are established, then maybe

Pavel Klavík20:01:01

If you start with frontend, you can just mock-up some data and work on their visualization, maybe making it interactive. Later you can work on downloading data. Or you can flip it around and just write static HTML generator on backend using hiccup library.


for getting data from places: is great, for api calls is common


no, luminus or another framework ?


I will begin with the ring readme

👍 3

and play with that


for now GN


I think the next weeks/months I will studie and try to understand the path that @UCCHXTXV4 pointed out


but for now more chapters from the brave book on the menu


which is the best way to iterate on vector? I am trying with loop-recur, with 2 value,, so when i call (next v) it fail at the last

Pavel Klavík20:01:40

One rarely needs to use loop recur, instead using higher order functions such as map, filter, reduce, makes things more understandable.

Pavel Klavík20:01:10

If you want to do some computation with all pairs of values, you can first apply (partition 2 1 vect) to get all pairs.


@popeyepwr It depends what you're trying to do. What problem are you solving?


@popeyepwr (first) and (rest) not helpful?


Yeah I used some other way to find out my issue


(contains? (set (str/split "select abc" #" ")) #{"select"} ) is returning false, which function can be used to make sure values present in set is present in string..?


You're checking whether the set of words contains the singleton set #{"select"}. This will work:

  (set (str/split "select abc" #" "))
Although, perhaps might be what you want:
(str/includes? "select abc" "select")
Bear in mind that it doesn't do the exact same thing. For example, the both vary with the string "selecting abc".


evaluate just the (set (str/split ...)) and see what you get. and then consider if #{select"} is a member of that set


ya doing same? set can have multiple values #{"select" "insert"}


yes. and that set doesn't contain any sets. so (contains? #{"select" "insert"} #{"select"}) will be false. it has two elements "select" and "insert", not a set containing "select"


I have a bit of a weird question. Are people using logic programming to compose/render/validate interactive html forms? I’ve been doing web-dev for 8y but I’ve never encountered a way to handle them that wasn’t in some way painful or unsatisfactory at least. What’s important to me is not just validation, but also guiding the user as well as possible (UX) on one hand, but also having a declarative way to model them AKA a way that is closer to a specification that you can talk about with a domain expert / customer etc. than to “code”. Forms are painful by default already. I’d like to be more productive, easily correct and clear when doing them. Forms with sufficient amounts of complexity/rules have always bothered me. Simple tools like json-schema are not powerful enough to model them in a data-driven. declarative way. More powerful things like clojure.spec have caught my eye, but I’m wary of parsing spec forms (clojure expressions) or creating them dynamically (based on stored data etc.). So typically I write some ad-hoc recursive logic. Typically it goes like this: You make an effort to pin down the rules and constraints with a client, expert or based on an API etc. Then there is a huge gap. And then there is your form model, fields, validation, special cases, ui updates etc. pp When I was reading a bit about core.logic I immediately thought: Hey this is much closer to the initial specification of a (complex) form! Can it do this? Clojure has libraries for html data-structures (hiccup etc.) So my intuition is that there might be some way to unify (sic!) logic programming and modelling forms.


I’ll dive a bit more into core.logic and try to find a good book on the subject out of sheer interest anyway. I guess my question is: Is my intuition completely wrong?