Fork me on GitHub

Yesterday, I used Calva to help a non-technical businessperson. And now they also want to learn it! Here’s a tiny success story 🙂

👍 4
❤️ 3
metal 4
calva 3

I'm smiling like a crazy person here!

😁 1

Haha, yeah—Me too when it happened. It’s easy for us to forget how little “outsiders” understand programming in general and how easily impressed people are by things we might consider trivialities. It dawned on me yesterday that, ironically, it might be easier to “sell” Clojure via Visual Studio Code and Calva to non-technical business people than to software developers in our IT department.


By the way, before this person approached me yesterday, they had been trying in vain to do the same thing in Excel.


At the job where I first met Clojure. The lead dev was always explaining trivial and complex (we where building a bank) calculations using the Clojure REPL. He was using Emacs, and didn't know about the eval-to-point family of commands, so it didn't get as easy to follow as with your example. But anyway, very effective and I am sure it helped with the management buy-in on Clojure.

💡 1

That lead dev, btw: @UQY3M3F6D. I'm forever grateful for his patience with me when I was learning Clojure.

❤️ 1
awesome 1

Most people want to solve surface-level problems like the ones in my example. They don’t care about the “deeper” stuff, which we programming language enthusiasts obsess over. I suspect the Clojure community on Slack is influenced by “In here,” we engage in meta-discussions about the tools themselves, while others “out there” are busy using the tools to solve business problems and build stuff. I wonder how many Clojure users exist “out there” who are not engaged in meta-discussions, library development, etc. Are we the “vocal minority” in this situation? :man-shrugging:


We certainly are. I think Clojure attracts people who primarily want to solve problems in a larger share than most languages do. Clojure is extremely practical and lets you go straight at your problem w/o interfering. And your solutions get to be almost 1:1 matches of the problem they solve.

👍 1

I'm curious why you get that floating point intermediate results. Had to try it myself, and the results are then as I would expect them to be...

👀 1

Also a somewhat funny definition of response-rate. I'd say that that is 3/446. 😃

;; First, we need to find the response rate.

(defn get-response-rate [surveys responses]
  (/ responses surveys))

;; Then, we can use the response rate to figure out how many surveys you need to send.

(defn get-required-surveys [response-rate desired-responses]
  (/ desired-responses response-rate))

;; When we combine those steps with your numbers, we find the answer.

(-> (get-response-rate 223000 1500) ; => 3/446
    (get-required-surveys 250) ; => 111500/3
    (float) ; => 37166.668
    (int)) ; => 37166

👍 1

However, displaying things in fractions can distract in this case, so maybe quickly move to floating points:

(-> (get-response-rate 223000 1500) ; => 3/446
    (float) ; => 0.0067264573
    (get-required-surveys 250) ; => 37166.668
    (int)) ; => 37166

👍 1

Ah! An astute observation. I made a copy/paste error in the comment I added behind that line. When I evaluate the line (get-required-surveys 250), it also shows the fraction 111500/3 (not the decimal number). Sorry for adding confusion. And I agree that 3/446 makes more sense than 446/3, but Clojure outputs the latter. It certainly reads more naturally in English to say, “3 out of 446 customers responded to the survey.” As for the line (get-required-surveys 250), I think it’s more intuitive for humans to read it as a decimal number than a fraction. And I believe fractions, in most situations, are more intuitive than percentages. I love the fact that Clojure has first-class support for fractions!


> but Clojure outputs the latter Well, as you can see in my example, if you ask Clojure to output the ”correct” ratio, then ask it to do so. You were dividing surveys/responses and got that. 😃

👍 1

Yeah, that’s a great feature!


My non calva version of this story - one of my friends from high school needed a laptop for school for a month and I loaned them my non-work one. I left Visual Studio code open with a little note and a folder for them to put stuff. Apparently a normal text editor with basic stuff like tab to indent and matching indent when you start a newline is a revolutionary tool for them to take notes

❤️ 3

In @borkdude says: > We should have a JavaScript to ClojureScript converter And @danielamber2 agrees. Turns out that @mauricio.szabo has created one! I've been playing with it today and it looks like so in my dev Calva now. A bit orthogonal to Calva, maybe, but I will include it! 😃 I'm going to need it when writing the tons of #nbb scripts I am planning to write.

wow 3

Nice, but is it possible to convert import to (ns ... (:require ...)) or just (require ..)? :)


Anyway, good progress :) @mauricio.szabo is there also a web version available? this will be quite nice for general usage


Nice :) I should mentioned that on the #nbb README


Dear Calva friends: The How to use #nbb with Calva docs are updated. Not sure where in the docs it fits otherwise, I will have to figure.

Bobbi Towers17:04:21

As a Clojure-first self-learner, I actually need this quite often when trying to port things

metal 2

Thanks for pointing me at this converter, @U8LB00QMD!


And before @mauricio.szabo who wrote this as a tinkering project knew it, it was running in prod ;)


From what I've heard he is using it in prod. 😃


I think that project should also allow my April fool's joke in a way:


(.log console "Hello," who) Is js/ not required before console? It seems to be in my react native repl, but maybe it’s different in the browser?


I think you might be right. You want an issue about it, @mauricio.szabo? It's not the end of the world to fix it after the conversion.


yes, it is required, but the translator is probably not aware of what "console" means


Hahaha, yeah, I was using it at prod. About console, maybe I can add some "reserved words" that are common in JS world, like console, document, window, fetch, etc... The only trouble is that it's quite hard to map all of these. I was thinking about adding some kind of "automatic detector" - something like "if a var is not on local scope and was not part of js/require, then prefix it with js/. But for now, a list of words will do 🙂

👌 1

I used some clj-suitable internals to enumerate the js/window object. Maybe this map can be cleaned up and be of use?


Here's the same for nodejs.


Are there any Calva friends that would like to huddle a bit next Wednesday (April 27)? I will be able to do it form most of the ”work”-day here (putting in quotes because it will be a Calva day for me and that really does not feel like work for me). I'm thinking we can just chat and share screens. Showing each other Calva bugs, tricks, ideas, whatever. I live in Stockholm Sweden, which is CET. We would just start the huddle and then see who wants to join. A bit like that Gather room we used a few times back. (Which resulted in some super great sessions, but it is a bit detached, in a way that huddles aren't.) Huddles are mostly about voice and screen sharing, so not so much of a video call as in zoom. For better or for worse. Just slap any emoji on this post if you think it is interesting (no obligation to actually join).

catjam 4

It might be an interesting opportunity to explore Live Share in the clojure world too


Yes, that too. Though right now it is a bit broken I think. Unless the VS Code team has fixed it since I last checked.


What part of it is?


The vsls.getApi() promise misbehaves for some users. Me included.


It's why I added a setting to enable the LiveShare support, because it hangs the repl connection when it happens.


anyone do a lot of paredit stuff with vscode-neovim?

😞 1

mainly looking for easy ways to yank & paste sexps


How does that work? Is it neovim's paredit engine that is used then, or does Calva's Paredit edits/navigations somehow get sent to neovim?


idk, haven't gotten that far yet. i tried invoking a couple of calva's paredit functions and it didn't seem to work yet


ah it works when i'm in insert mode and use vs code's copy/paste


maybe i'll try neovim's paredit/sexp plugins so i can use it in normal mode with neovims text selection


OK, so that indicates that Calva's paredit was used, right? If you didn't have neovim plugin for it installed, I mean.


that's right


in insert mode, i can invoke e.g. ctrl-shift-right, then cmd-x to cut and cmd-v to paste


which uses all of calva & vs code's bindings


But in command mode the selection doesn't happen?


the selection happens but i cannot use vim's yank


hmm i'm worried that adding the vim-sexp plugin is going to end up with conflict based on what it says it does in insert mode


What does it say? 😃


> Vim-sexp does intelligent bracket and double quote insertion like Unlike ParEdit, deletion of brackets that would cause an imbalance is not prevented, except in the limited case of <BS> below.


Sounds a bit like with Calva's Paredit.


rigth, i'm worried they'll conflict


You can set Calva's Paredit keymap to none. Then you shouldn't get any conflict, I think.


I tried with Neovim now. I can do cmd+c and cmd+v also in command mode. Maybe there is something special with ctrl+c...


that works for me too


i can't use y or x though


anyway i can deal with that


the next problem I'm having is getting ctrl-w to work


I've remapped c-w to nop in my init.vim file


now when i press ctrl-w in a clojure file, it deletes the word up to the cursor 😕


no selection happens


ctrl+w is bound by the neovim extension. Bring up the keyboard shortcuts editor and rebinding it should work. Or rebind Calva's grow selection command.


I think neovim completely detaches when you go to insert mode, and it's pure VSCode. Also, visual mode and selections are not synced - it's confusing.


I just use vim commands for paredit, ie dab yab, p


I always use paredit in insert mode only…