no, I doubt anyone is using logic programming for that, I don't think it is a good fit
it sounds like you want to model a process over time, which, I think the gold standard for is still a finite state machine
e.g. if you are in state S0 you can do E1, E2, or E3, if you do E1 or E2 you move to state S1 where you can do E4, and if you do E3 you move to S2 where you can do E5 or E6, etc
what are describing is very similar to something like session types as well, which are usually built on a fsm
one way to describe that kind of thing would be for each state give a set of valid json-schemas, and what state to transition to given a schema match
ubf's schema language is kind of an example of that, but doesn't use json schema (https://ubf.github.io/ubf/ubf-user-guide.en.html)
Right. I’m half embarrassed that I never thought of this. I use FSMs for all sorts of things in GUIs already….
A visualized FSM would be super easy to communicate with as well
I dunno, specifying process behavior vs. just specifying messages processes exchange still seems very bleeding edge.
it is an area of interest, but I haven't seen a lot of it used in practice
I think maybe because most exposed public apis tend to be "stateless" rest things
fulcro has a story about state machines, but I didn’t find the time to study the framework in full so far
(a UI framework for clojure)
https://gist.github.com/hiredman/60e5e6f0025cb38c8a7739d21f5a8ce6#file-scratch-clj-L124 is a ubf kind of schema built on top of spec
once you have a finite state machine as data, that is a kind of relational thing, so there might be interesting things you can do querying the fsm with something like core.logic
Dammit I wanted so sleep early tonight. But thanks a lot @hiredman!❤️
Hi Everyone, I've been trying to look for a good way to parse KML (XML for GIS) into dataframe format or to export as a CSV Am considering on making my own library for this. I understand there is data.zip and data.xml. Are there any good examples for the usage of these libraries? And does making my own library to do this make sense? Or is the best/own way to make use of data.xml/zip and modify it accordingly to parameters of the kml?
Right the HTML is part of the specification https://docs.fileformat.com/gis/kml/
@factorhengineering 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.
Converting XML to CSV is very straightforward in Clojure, you can definitely use existing libraries. About “dataframes”: in Clojure those are generally unnecessary as the language itself provides plenty of simple abstractions to process data that exceeds available memory. But if you need to interop with other tools that require them, then that’s another case. Curious to know more details and we can discuss further.
Hmmm am doing a data science project with my friends. And for their sake am trying to convert KML into CSV so it is easily for them to manipulate it from there. (They are using python.) Usually people use a command line tool called ogr2ogr for this. But the description (one of the columns) is left as an xml string. Was trying to see if I can do the processing for them within clojyee
Do you have an example of the XML you’re trying to convert to CSV? Is it 2 dimensional?
Was using this as a test example https://data.gov.sg/dataset/dengue-cases it is a zip file with 5 datasets of the same format
I believe it is 2-dimensional(?)
Ok 1 sec
@zackteo 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
@factorhengineering 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?).
(ns scratch
(:require [clojure.data.xml :refer :all :as x])
(:import (<http://java.io|java.io> StringReader)))
(let [input-xml (StringReader. (slurp "/Users/raspasov/Downloads/dengue-cases/dengue-cases-central-kml.kml"))]
(x/parse input-xml))
From here on, you can extract whatever you need from the XML data tree.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. 😉
Via regular Clojure functions like map, filter, get-in, etc
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...
@factorhengineering 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).
I did exactly that actually. Guess I need to manually explore the data hahaha. The hierarchical nature of the xml can be quite daunting
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 😅
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)
Thanks for your help though :)
Yea… I was just looking at it, it looks messy this one, if the xml has some sort of a data spec or fields listed, that can help
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
@seancorfield What keybindings are you referring to?
Just the main 5? copy, cut, paste, undo, redo?
...and maybe select-all.
I'm not sure if I just picked a horribly confusing dataset or if that's just kml specifications in general
Thats why I was considering a wrapper to skip some of that
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.
Aha! Found it: cua-mode (https://www.emacswiki.org/emacs/CuaMode)
Yea if there’s anything like that, perhaps worth a look; but it does look confusing (especially if it lacks explanation/specification)
I even see HTML tables in there! Doesn’t look very clean 🙂
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
https://clojure.org/news/2020/02/20/state-of-clojure-2020 (older ones linked at the bottom)
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.
?
NightCode
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.
*spent
I don't think there's any single "best" anything. It all depends on the trade offs you want to make.
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.
Ahhhh okay thats html and not xml right right
Yeahhhh ... the government datasets are not very clean ...
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 ... https://github.com/zackteo/.doom.d
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.
*annoying
Errrrrr but are you familiar with vim
It is XML, but there were some HTML strings I saw
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 😅
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 https://www.spacemacs.org/ or https://github.com/bbatsov/prelude
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!!!!! http://ergoemacs.org/emacs/emacs_best_redo_mode.html
@zackteo Do you know how to redo?
Look at my config
My undo is C-/ and redo is C-/ with shift
@factorhengineering 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"
https://github.com/Microsoft/Terminal is the GitHub repo for the project.
And that links to the Microsoft Store where you can install it (and the preview version).
@zackteo I found the 3rd or so answer here, which agrees with what you said: https://stackoverflow.com/questions/3527142/how-do-you-redo-changes-after-undo-with-emacs
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 🙂
@zackteo 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: https://stackoverflow.com/questions/3527142/how-do-you-redo-changes-after-undo-with-emacs
With Doom Emacs -- C-/ for undo works, but -- C-g C-/ for redo does not...it just undoes more! and -- S-C-/ (i.e. C-?) for redo, required for spacemacs and prelude apparently, also does not work...it 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
@zackteo 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 https://stackoverflow.com/questions/3527142/how-do-you-redo-changes-after-undo-with-emacs
@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: https://clojure.org/guides/getting_started
Oof. I guess I'm back to needing to install Java and everything, only a different installation procedure (for Linux) this time...
https://linoxide.com/ubuntu-how-to/install-java-ubuntu-20-04/
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...
I'm trying to follow the guide for installing Clojure CLI tools on a WSL2 Ubuntu-20.04 VM (Linux within Windows): https://clojure.org/guides/getting_started
Right away I'm seeing Java, but the command
sudo apt-get install openjdk-8-jre
specified here for Ubuntu does not work
https://openjdk.java.net/install/
Not sure what's wrong with the suggested command. May also need help with the rest of the installations.
Well, Java 8 is ancient. Install 14 at least.
(11 if you must)
apt-get may not be there by default, newer ubuntu versions tend to use apt install
I posted a link in that long thread that basically said: sudo apt install default-jdk
which I would assume would install a more modern version.
(personally, I go to the Adopt OpenJDK site and install specific versions from there -- and I usually have three or four JDK versions installed)
also you probably don't need a full jdk (a jvm works fine until you are writing java code) and the default jvm (at one point at least) is a headless one with no gui or image processing classes included, you might not want that either
Hmm, I hadn't even thought about that. I've always installed a JDK rather than a JRE for years... maybe even for decades...
once upon a time it was a popular way to make a server leaner, nowadays space is cheaper haha
(both using a jre rather than jdk, and using a jre that doesn't include any gui or graphics code are in that category of "optimization" I think)
I'm sure I came across something about using Java 8. 😕
...but if 11 is LTS then maybe OK?
LTS only matters for the Oracle JVM.
We use 11 on QA/production but 14 or 15 on dev. We're close to using 16 at thing point.
The next (Oracle) LTS is 17.
OK. I'll try sudo apt install default-jdk
...thought I just installed 8 on Windows a couple of weeks ago, before I knew I was going to do it all over again in Linux. lol
Wait...will that command install the open-jdk or the oracle one?
apt won't have any proprietary packages unless you configure / add them
8 was EOL'd years ago, right?
I tried installing one of the other dependencies, rlwrap, using 'sudo apt install' earlier and it did not work, by the way.
$ rlwrap Command 'rlwrap' not found, but can be installed with: sudo apt install rlwrap $ sudo apt install rlwrap Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package rlwrap
@factorhengineering are you sure you are doing this on Ubuntu 20.x?
yes
seanc@DESKTOP-30ICA76:~/oss$ sudo apt install rlwrap
[sudo] password for seanc:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
gvfs-bin
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
rlwrap
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 98.2 kB of archives.
After this operation, 309 kB of additional disk space will be used.
Get:1 <http://archive.ubuntu.com/ubuntu> focal/universe amd64 rlwrap amd64 0.43-1build3 [98.2 kB]
Fetched 98.2 kB in 1s (113 kB/s)
Selecting previously unselected package rlwrap.
(Reading database ... 80478 files and directories currently installed.)
Preparing to unpack .../rlwrap_0.43-1build3_amd64.deb ...
Unpacking rlwrap (0.43-1build3) ...
Setting up rlwrap (0.43-1build3) ...
update-alternatives: using /usr/bin/rlwrap to provide /usr/bin/readline-editor (readline-editor) in auto mode
Processing triggers for man-db (2.9.1-1) ...
seanc@DESKTOP-30ICA76:~/oss$
Have you done sudo apt update
?
no. I had just tried running commands for each of the 4 dependencies listed.
Now I did that and it did a lot. 39 'Get' lines and it reports 154 things can be upgraded
....and this time the rlwrap installation worked. I'm not sure how I ever would have guessed that.
I mean not guessed, but found out about.
Thank you.
I dunno. It's hard to know what beginners don't know. I don't remember where I learned sudo apt update
but it was a long time ago 😐
I guess I thought the system told you to run that command sometimes...
I have minimal linux command line experience. I know it uses 'ls' instead of 'dir', and I made a script once for scraping all the filenames from each of a series of inserted optical disks and appending them to a file. That's about it.
At least now you should be able to install brew for Linux and then the Clojure CLI 🙂
I'm not there yet....
I started with Unix back in... 1979 I guess?
I aborted the java install because I want to double check. This looks a bit much: $ sudo apt install default-jdk Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: at-spi2-core ca-certificates-java default-jdk-headless default-jre default-jre-headless fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libgif7 libice-dev libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcsclite1 libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev Suggested packages: cups-common libice-doc liblcms2-utils pcscd libsm-doc libx11-doc libxcb-doc libxt-doc openjdk-11-demo openjdk-11-source visualvm libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei fonts-indic The following NEW packages will be installed: at-spi2-core ca-certificates-java default-jdk default-jdk-headless default-jre default-jre-headless fonts-dejavu-extra java-common libatk-bridge2.0-0 libatk-wrapper-java libatk-wrapper-java-jni libatk1.0-0 libatk1.0-data libatspi2.0-0 libavahi-client3 libavahi-common-data libavahi-common3 libcups2 libgif7 libice-dev libjpeg-turbo8 libjpeg8 liblcms2-2 libnspr4 libnss3 libpcsclite1 libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev 0 upgraded, 41 newly installed, 0 to remove and 0 not upgraded. Need to get 266 MB of archives. After this operation, 426 MB of additional disk space will be used. Do you want to continue? [Y/n] n Abort.
Huh? Looks fine to me.
You have a new system. It's missing a lot of stuff you need for development work.
OK. Something about having multiple 'jre' and multiple 'jdk' and multiple 'headless' looked fishy.
Why?
No great reason...just seemed excessive. Ha ha.
This all looks like perfectly reasonable dependencies to me...
I notice it's V11, by the way. Older than you were hoping for?
11 is fine.
You can install 14 or 15 later.
As long as you're past 9 you're mostly fine 🙂
The installation guide only refers to 'brew' for mac, not linux.
Under Linux the next step it lists is:
To install with the Linux script installer:
1. Ensure that the following dependencies are installed: bash
, curl
, rlwrap
, and Java
.
2. Use the linux-install
script to download and run the install, which will create the executables /usr/local/bin/clj
, /usr/local/bin/clojure
, and the directory /usr/local/lib/clojure
:
curl -O <https://download.clojure.org/install/linux-install-1.10.1.763.sh>
chmod +x linux-install-1.10.1.763.sh
sudo ./linux-install-1.10.1.763.sh
So what? Once you have brew
installed on Linux, you're golden.
Why would it list two different ways if the same way can be used for both OSs? Not disputing you, just wondering why they would complicate things like that.
Because they didn't think to list brew
as a way to do it on Linux.
$ sudo apt install brew Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package brew ;?
😕
The Linux instructions mean every single update is manual and you have to repeat the process for every new version.
I posted this link earlier https://docs.brew.sh/Homebrew-on-Linux
and I don't get what the text of step 2 means. Does it just mean run the 3 commands listed under it, or is it a separate command I'm supposed to know how to piece together from the text?
What are you talking about? What's "step 2"
"Use the linux-install script to download and run the install, which will create the executables.........
Just curious
Stop following those instructions. Read https://docs.brew.sh/Homebrew-on-Linux
So for the brew method, I need to run:
/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"
?What? That's not on the page I posted is it?
From that page: "Install Instructions for a supported install of Homebrew on Linux are on the https://brew.sh."
....then on that page: "Install Homebrew
/bin/bash -c "$(curl -fsSL <https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh>)"
Paste that in a macOS Terminal or Linux shell prompt."I don't remember. I installed this stuff so long ago. Just do whatever it says.
It's all a one-off. Once you're done with this, keeping stuff up to date is easy.
(which is why no one remembers exactly what steps are involved -- we do this once per system and forget it!)
While I wait for this to install, I'm marvelling again at the sheer number of steps it takes to get going with clojure/clojurescript. At this point I'm not even letting it bother me, and just laughing at it.
Now that the effort put into setting up the VM is getting higher, I should ask: What, if anything, would cause it to be wiped?
'exit' and 'shutdown' are safe, but is there anything to be wary of?
Wow this is a huge installation...5 minutes and counting I think.
Honestly I did 2 full install last month. From blank system to clojurescript reframe running. It was 2 hours on mac book. Full install with word and nas setup... dont feel it heavy
It's not fair to clojure to conflate different things together. WSL, brew, emacs, the linux shell in general have nothing to do with clojure in particular, they're just tools that might make you more productive with it. After all, for most of us it all builds up organically. I don't think many try to do it all at once like you did. First you become accustomed to the linux shell Then you start playing with clojure Finally you consider switching to a different editor In no particular order. This process might even span years.
Let me tell you about that time when I tried installing Gentoo Linux on a 85 MHz Sparcstation 5. After 7 straight days (iirc) of compiling the bootstrap environment the hardware finally gave up 🙂
brew installed. noticed this error: Warning: /home/linuxbrew/.linuxbrew/bin is not in your PATH.
Agreed. I started with a system that was already setup for Java development: Clojure was almost nothing on top of that.
How does HW give up? Blue smoke?
I think it was the SCSI controller on the motherboard that broke. Wouldn't access the disk anymore 😢
@factorhengineering right, follow the instructions on the link I provided to adjust your path based on whatever shell you're using.
Again, I don't remember this because it was a one-off ages ago and you never have to worry about it again.
I don't think this is a "sheer number of steps" because it's just getting a bare system to a baseline that you can do anything useful with it. Neither Windows, nor macOS, nor Linux come setup to do JVM-based development.
Systems aren't designed for developers, they're designed for consumers. Developers always have to go through a setup process.
I just got through the main installation and running all the suggested commands at the end of it. (4 more commands, for installing build-essential, for setting the path suggested, and for installing gcc)
When you can do clojure -Sdescribe
you'll be done 🙂
And now I've finished running
brew install clojure/tools/clojure
I just ran 'clojure' expecting a short message describing options or something. Instead it did a bunch of downloads and I'm into what looks like a REPL
(+ 1 1)
2
Yay!
Congrats!
Do I need to mess with the path, like you were mentioning?
(! 532)-> clojure -Sdescribe
{:version "1.10.1.763"
:config-files ["/usr/local/Cellar/clojure@1.10.1.763/1.10.1.763/deps.edn" "/Users/sean/.clojure/deps.edn" ]
:config-user "/Users/sean/.clojure/deps.edn"
:config-project "deps.edn"
:install-dir "/usr/local/Cellar/clojure@1.10.1.763/1.10.1.763"
:config-dir "/Users/sean/.clojure"
:cache-dir "/Users/sean/.clojure/.cpcache"
:force false
:repro false
:main-aliases ""
:repl-aliases ""}
...or I guess brew's defaults were fine?
If that works, apparently not.
How do I get out of the REPL? I'm sure 'exit' worked in Windows
control-d
That would have been my 117th guess. 😕
(that's end of file in everything -- except Windows where it is control-z for some bizarre reason)
Windows breaks everything 😞
I did try Ctrl-c
Here's my Sdescribe: $ clojure -Sdescribe {:version "1.10.1.763" :config-files ["/home/linuxbrew/.linuxbrew/Cellar/clojure/1.10.1.763/deps.edn" "/home/a/.clojure/deps.edn" ] :config-user "/home/a/.clojure/deps.edn" :config-project "deps.edn" :install-dir "/home/linuxbrew/.linuxbrew/Cellar/clojure/1.10.1.763" :config-dir "/home/a/.clojure" :cache-dir "/home/a/.clojure/.cpcache" :force false :repro false :main-aliases "" :repl-aliases ""}
Welcome to Clojure!
Well, the kids will be up in 3 hours, so this seems like a good pausing point for a couple of reasons!
Thanks again for the help, Sean et al.
Glad to get you this far. Sorry it's been a painful process.
Oh...again. Anything that would make my VM forget all this installations? ...things I should avoid?
Don't worry about it.
Ok. Will restart my computer with abandon going forward.
Have a good night!
Seriously, I've been developing this way for months, rebooting my laptop whenever it needs it. It's fine.
I always pictures VMs as ephemeral. Shows what I know...
I don't know where people get that idea?
I think I picture a RAMdisk actually.
Really? That feels so... '90s... to me 🙂
(which is kinda weird since I've been doing "this" since the very early '80s)
Or virtual memory...which I guess is more permanent than normal memory. I don't know...
These days I just sort of expect the "cloud" to stay around until I delete it...
A virtual reality headset comes off easily?
I'm too old for VR 🙂
and I'm never continuing a game when I put it back on? I'm always starting a new one. It would feel kind of weird to 'pause' a VR game, but maybe that's just because all the ones I have are short-burst ones.
No no no. Try it!
Beat Saber is amazing, fun, and good for you!! Not many other places in life you can get that deal.
I'm 58. I've never played video games or computer games. Except Myst for a while.
(I even bought Myst for my iPhone at one point -- such a beautiful game!)
We'll have to talk about that another time. I haven't seen that one. Goodnight!
then im not the oldest person here. IM 53 🙂
I feel clojurian are older than on other language. Do we have statistics ?
When I say older, I say wiser, experimented !!
I'm 54. I've just started clojure and I think I'm now a better programmer than I've ever been
LIke I said im 53 and tried several times clojure and I hope it will click this time
Anyway I came here to ask a real question: in c# or JavaScript if I want to say if (widget != null && widget.InStock)
I can abbreviate it to if (widget?.InStock
. - c# calls it "null conditional" and js calls it "optional chaining". In clojure I'm doing (if (and widget (widget :in-stock)))
. is there any shorter way of expressing that?
Maybe can do (get widget :in-stock)
? works with nil.
There's also some->
and some->>
.
or even (if-let [foo (get widget :in-stock)] foo-is-there foo-isnt-there)
I believe just (if (:in-stock widget)
would work too? (widget :in-stock)
throws when widget is nil
but the other way round you get nil on a nil map (same as with get
)
yes if you just want to check the existence (:in-stock widget)
would be the shortest, if you'd like to do something with the result, can use if-let
. As you noticed, you cannot call a nil value, the other way is fine. using get
just makes it consistent and safer 🙂
wow thanks. As always there are several different ways of expressing the same thing 🙂 As a beginner I find I usually start by writing something that works but is bulky using the methods I know, then learn new ways to express it better
May the REPL be with you 🙏:skin-tone-3:
I am assuming that widget is suppose to be a map or nil. Then the following works:
(if (:in-stock widget)
...)
I am always using the form (:key m) instead of (m :key) since the latter fails when m is nil. But the former just returns nil.
Ok, actually posted above already 🙂 didn't notice before.
Hi, I come from Java and I have learnt a little bit of Clojure reading “Living Clojure” book. I would like to study the web stack now, in order to get chance to be hired as Clojure dev. I was thinking to buy this book, do you think it’s a good idea? Thanks https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/
yes
Hello, there is a way un clojure to get the key looking up by the value?
quickly, no. you can walk through the map entries to find a match, or use something like https://clojuredocs.org/clojure.set/map-invert to invert the map then do the lookup (probably better if you're going to do that more than once)
I bet somebody has a bimap implementation if you need to go both ways throughout the lifetime of the collection (if not guava has one https://guava.dev/releases/19.0/api/docs/com/google/common/collect/BiMap.html )
this exists but I can't vouch for it https://gist.github.com/semperos/3835417
Guava's is of course mutable
Thanks alex
a bimap is a sign you want a structure indexed by more than one field, less like a map, more like a database
If I have 2 lists, and want to combine them like below, what's the best way to do it?
(1 2) + (3 4) => (1 2 3 4)
The best I've found is (into (vec list-1) list-2)
which seems convoluted. I don't really care about the final collection type (it's getting serialized to json)
I guess I should add, for my use case, the ordering is important, and that's what Im trying to avoid spoiling(concat l1 l2)
should give you what you want.
concat
oh... duh...
thanks
forgot about concat
thanks. i can't believe i forgot about concat. i guess i've been playing with transducers and using into too much 😕
(into [1 2 3] [4 5 6])
[1 2 3 4 5 6]
Into probably better than concat... assuming this still stands https://stuartsierra.com/2015/04/26/clojure-donts-concat
concat is totally fine for the original case (and what I would prefer there)
user=> (time (dotimes [_ 10000] (concat '(1 2 3) '(4 5 6))))
"Elapsed time: 1.036309 msecs"
user=> (time (dotimes [_ 10000] (into [1 2 3] [4 5 6])))
"Elapsed time: 5.810941 msecs"
Is there a way to print all the aliases that a project has, using Clojure cli?
hi, this is probably trivial: Its more convenient for me to evaluate (clojure.repl/doc seq?) with C-c C-c from a file/buffer than to type it in the REPL, but I only get nil in the buffer with the file and I don’t want to keep another buffer open just for the outputs (I prefer to use a single small screen right). How do you do it? Are there other users that like repl driven development but not have an actual repl buffer open all the time?
this still stands, it's just contextual to how you're using concat. definitely something to be aware of in a loop but as a single thing, no worries
I use lispy with Emacs and it shows the result of the evaluation inline
if you eval (source source)
you'll see that it prints the source. this causes a side effect of printing and returns nil
I think to make it work using C-c C-c
you should wrap your form in a comment
form
things to note - into uses conj and conj on lists prepends, so (into '(1 2 3) '(4 5 6))
is not the same. and secondly, the timings here depend on laziness of concat.
(as an aside, i love recommending (source source)
or (doc doc)
)
hmm for me (comment (clojure.repl/doc seq?) )
still => nil
sure, but the side effect is not displayed inline in cider.. maybe I should have started with that
C-c C-d d
will bring up the docs
yes. output will end up in the repl. there are several commands inside the cider-doc menu. C-c C-d
and then c
for clojuredocs, d
for the docstring, a
for apropos, e
for apropos documentation, j
for javadoc
Hey, gang--Ralph here! I just wanted to thank you all for providing this Slack as an avenue for those with only a few months' experience with Clojure under their belts (Me.). PS: This is my first time ever using Slack; I hope this is an alright spot to send along my personal introduction. 😅
Since deps.edn
is "just" an EDN file, you can slurp
it in, run clojure.edn/read-string
on it and get a hash map, and then select :aliases
from that and print the keys
of that.
whoa I forgot how many features CIDER has
But bear in mind that any running program started from the CLI could actually have been started with any aliases from either the system deps.edn
file or the user deps.edn
file.
Sweet, thanks!
thans
yeah there's a ton. and they are quite nice
of course
there's also #cider for cider specific questions in the future
I really like the convert the thread-first
happy to help you explore the other features
I have to check it out
joining now
You're welcome here I guess. I am pretty new here and in clojure. But it seems to be a quiet place to discuss with polite people. I must confess I did not introduce as you did ! Welcome, guys are more than helpful here !
If you want to also get at the content of those, you're going to need to use tools.deps.alpha
as a library to compute the full project basis. Take a look at how depstar does it: https://github.com/seancorfield/depstar/blob/develop/src/hf/depstar/uberjar.clj#L305-L328
(you would only need the t/find-edn-maps
and t/merge-edns
parts)
Nearly all editor integrations for Clojure provide a way to get the docs for the symbol your cursor is on, without needing to actually eval a clojure.repl/doc
form.
Most editor integrations also have a similar way to get the source for a symbol.
Thank you very much for taking the time answering all these stuff!
Out of curiosity, what is the coma ,
on this line https://github.com/seancorfield/depstar/blob/develop/src/hf/depstar/uberjar.clj#L328
Welcome! 🙂
Commas are whitespace in Clojure and the comma here just causes my editor's paren management plugin to leave the )
on that line instead of "correcting" it to the end of the line above, which makes it easier to put the cursor at the end of the form on the previous line so it is easier to eval to the REPL.
Otherwise I'd have to either put my cursor at the start of the form or ensure it was placed correctly relative to what would be ))
at the end of the form (to ensure the nested form was eval'd and not the enclosing comment
form which would produce nil
instead).
just for reference I set Cider Prompt For Symbol to be dwim so I don’t have to confirm
Oh I see, that’s a good tip. Thanks!
Hi Ralph! I too have barely 3 months of time with Clojure, and what a fun few months it's been!
Hello everyone,
Lets supose i have this var:
(def m {:username "sally"
:profile {:name "Sally Clojurian"
:address {:city "Austin" :state "TX"}}})
Why when i try to evaluate the following function doesn't return "TX"?
(:state (:adress (:profile m)))
=> nil
Thanks
Hi Maybe the mispell of adress / address ?
Yes I ve just copy paste in repl in case I miss something. But no, its working with good spelling
Hi guys! I don't know if it's the right section to write this but, I d like to learn Clojure. I'm a Java developer and I'm going to try a functional language. I had to chose between elixir and Clojure and I think that as Java Dev could have sense to try Clojure. I will start to read "Clojure for the brave and true", is it a good book to start? And what about web development (frameworks, libraries...) and the future of clojure in the industry? Thank you very much
I am a beginner with Clojure and have read Getting Clojure and am much of the way through Living Clojure - both great introductory books to Clojure. I think Getting Clojure does a great job of helping you understand the 'essence' of Clojure and each of it's individual 'features'. Living Clojure is a bit out of date now - the chapter on web dev with clojurescript doesn't really work any more - that was the only chapter that hasn't worked for me though - the rest all still works and it provides you with a training program to get better at clojure programming which I thought is interesting and cool, though if you are confident you can easily build your own training program.
@mircoporetti Welcome! Lots of questions there so let's try to answer them all one at a time... since you're used to the JVM, Clojure makes sense: you can even use it from your existing Java apps (we introduced Clojure at work a decade ago and initially used it as a "library" and wrote lots of new code in Clojure but used it from our legacy apps -- and gradually Clojure has taken over). That said, the mental shift from Java's OOP model, based on mutable state, to Clojure's pure immutable data can be a long haul -- so expect to get frustrated and confused and be prepared to spend quite a long time learning "functional thinking" (or, perhaps, unlearning OOP thinking)...
I think a lot of people start off with Brave/True but it may make sense for you to continue with your existing editor, if it has a good Clojure integration, rather than trying to learn Emacs (which is what Brave/True suggests). What editor/IDE are you using for Java?
Thanks Sean for your suggestions 🙂. I have another question. I already bought the book Brave/true and I would try to read it because it's here on my desk. Can I do it using Intellij or does this book oblige you to use Emacs? If you tell me that this book is not good to start I will sell it and I will buy Living Clojure or another. Thanks
It's a perfectly good book and I'm sure you can just ignore the Emacs stuff and follow along and do the exercises in Cursive/IntelliJ. There's a #cursive channel if you need help with that.
Thank you! I'll start soon
Clojure from the Ground Up is another online resource you might like. Good books to get started include Living Clojure and Getting Clojure. There are lots of good "second books" once you start to find your feet.
@mircoporetti here is the link to Clojure from the Ground Up: https://aphyr.com/tags/Clojure-from-the-ground-up
As far as web development, Clojure mostly eschews frameworks in favor of composing libraries. Almost all server-side web apps are built, ultimately, on top of Ring. There are several options for routing libraries (mapping URLs to handler functions) with the most popular being Compojure and Reitit I think. For HTML page generation, folks mostly either go with Hiccup (you write your HTML as Clojure data structures and Hiccup transforms them to actual HTML text) or Selmer (you write your HTML as Django-style templates and Selmer substitutes variables and handles conditionals and loops in the templates).
I would prefer to start using it only server side returning JSON like I usually do with Spring. So I imagine that exists also a library like Jackson for java?
@mircoporetti org.clojure/data.json
, Cheshire, jsonista are the three that come to mind. The former is pure Clojure, the latter two both wrap Jackson.
I tend to point beginners at https://github.com/seancorfield/usermanager-example as an example of a handful of simple libraries composed together to produce a small web app that uses a database and generates HTML server-side.
There's a whole separate world of front end development with ClojureScript (that I can't comment on much yet, but I'm started to learn that side now -- after using Clojure on the JVM for a decade 🙂 ).
As for Clojure's future, it is and will always be a niche language. But it has seen slow, steady growth ever since its introduction and it is extremely stable, and changes are made in a very conservative, careful fashion.
and.. does Phoenix put Elixir on the map?
Elixir seems pretty niche to me.
StackOverFlow 2019 survey had Elixir and Clojure usage on par: Elixir 1.4% Clojure 1.4%
I don't know how much of that small usage is driven by Phoenix or not. And maybe Phoenix could push Elixir past Clojure in the future, that's really hard to predict
Clear, I hope that clojure will grow on 2021, I'm waiting for official statistics
Given that most of the Clojure community uses either Zulip or Slack instead of StackOverflow, you have to wonder how representative the Stack Overflow survey is for Clojure. It would be useful to get stats from Maven central and Clojars to see how often jars are downloaded. For myself, the question is never about popularity or usage, but is the language sustainable? As far as London is concerned, Clojure is certainly sustainable in terms of jobs and community. As we've all gone online then that easily extends to the whole of the UK. And there seems to be a regular stream of new companies advertising in the jobs channel. I started looking on Tuesday for a new job and found 6 Clojure roles straight away (I may have just been lucky). There seems to be more and more communities around the world too, especially over the last few years. So Clojure is still growing. We have also seen a big boost in numbers in the London Clojurians, over 2,000 members now. There are only 7,000 in the London Java Community, so there is certainly a lot of enthusiasm for Clojure.
That's a good point about the user groups -- I was surprised to see one pop up in Provo, Utah and it's pretty active (it's done well since we all went online and it can get speakers and attendees from all over the place). I've attended that a couple of times now, and the Los Angeles group. And both San Francisco and Seattle are trying to get themselves restarted as online meetups.
Jar downloads for clojure itself could be an interesting stat to plot. If somehow it could even unique over IPs 😅
As for me, I agree with others, I don't really need Clojure to be more popular as long as it continues to be well maintained and supported. The ecosystem is healthy now, there's nothing really that I'm "in need of" or "missing". I have all the tooling and libraries/framework I need. And the language already has more features then I even know what to do with haha.
The only exception I'd say is job prospects. I would like to see it grow there. The more opportunity to work in Clojure at more places on more varied applications the better chance I can use my favorite language at work for the foreseeable future.
Thanks guys, I will start today to read something of Brain/True. I'm happy to see that all Clojurians are enthusiastic and positive about the growth of the language. I think that it will be for me a good experience to start programming with a different approach. About jobs, we will see 🙂 I believe in functional languages and their communities
All the companies I taked to this week are looking to hire more Clojure engineers this year. Location is still somewhat a factor, although mostly due to the pandemic that location is now more about the same country or economic region rather than city. There are not the same numbers of jobs as say Java or JavaScript, but the jobs I have seen in Clojure tend to be more engaging and slightly better paid.
@mircoporetti You will also probably find this site very useful as a learning resource: https://practicalli.github.io/clojure/
I think @jr0cket is also developing material about web development but I don't have a link handy for that.
I heard good things about Getting Clojure, Programming Clojure and Elements of Clojure. I also think they complement each other, from what I heard. Getting Clojure is more introduction, Programming Clojure goes in more details, and Elements of Clojure is more phylosophical (design/structure of code). That said haven’t read them. I do personally recommend Clojure, The Essential Reference. It might not be best to learn Clojure at first, but once you know it somewhat, it’s great for deep diving further into every aspect of the core language. I also really recommend at some point you read through the official Clojure overview, reference and guides: https://clojure.org/about/rationale https://clojure.org/reference/reader https://clojure.org/guides/getting_started And as a super quick intro like I want to get going in 30 minutes, I recommend the following small blog series: https://aphyr.com/tags/Clojure-from-the-ground-up https://kimh.github.io/clojure-by-example/#about