Fork me on GitHub
#calva
<
2022-04-20
>
leifericf08:04:56

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
pez08:04:31

I'm smiling like a crazy person here!

😁 1
leifericf08:04:53

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.

leifericf08:04:23

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

pez08:04:46

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
pez08:04:22

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

❤️ 1
awesome 1
leifericf08:04:03

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 https://en.wikipedia.org/wiki/Survivorship_bias. “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:

pez09:04:25

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
pez09:04:30

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
pez09:04:59

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
pez09:04:46

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
leifericf10:04:36

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!

pez10:04:54

> 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
leifericf10:04:02

Yeah, that’s a great feature!

emccue12:04:00

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
pez14:04:26

In https://www.youtube.com/watch?v=_-G9EKaAyuI @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
borkdude14:04:56

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

borkdude14:04:50

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

borkdude14:04:04

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

pez16:04:52

Dear Calva friends: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.269https://github.com/BetterThanTomorrow/calva/issues/1687 The How to use #nbb with Calva docs are updated. https://calva.io/nbb/ 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
pez18:04:02

Thanks for pointing me at this converter, @U8LB00QMD!

borkdude18:04:10

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

pez18:04:56

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

borkdude19:04:08

I think that project should also allow my April fool's joke in a way: https://twitter.com/borkdude/status/1509933579937226759

bringe19:04:21

(.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?

pez19:04:24

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.

borkdude19:04:26

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

mauricio.szabo19:04:54

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
👌 1
pez20:04:45

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

pez20:04:38

Here's the same for nodejs.

pez19:04:01

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
1
rayat19:04:30

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

pez19:04:13

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.

1
rayat21:04:13

What part of it is?

pez22:04:29

The vsls.getApi() promise misbehaves for some users. Me included. https://github.com/MicrosoftDocs/live-share/issues/4551

pez22:04:52

It's why I added a setting to enable the LiveShare support, because it hangs the repl connection when it happens. https://github.com/BetterThanTomorrow/calva/issues/1629

lilactown21:04:12

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

😞 1
lilactown21:04:27

mainly looking for easy ways to yank & paste sexps

pez21:04:26

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?

lilactown21:04:01

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

lilactown21:04:03

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

lilactown21:04:03

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

pez21:04:30

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

lilactown21:04:43

that's right

lilactown21:04:37

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

lilactown21:04:53

which uses all of calva & vs code's bindings

pez21:04:58

But in command mode the selection doesn't happen?

lilactown21:04:57

the selection happens but i cannot use vim's yank

lilactown21:04:37

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

pez21:04:12

What does it say? 😃

lilactown21:04:36

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

pez21:04:38

Sounds a bit like with Calva's Paredit.

lilactown21:04:59

rigth, i'm worried they'll conflict

pez21:04:43

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

pez21:04:32

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...

lilactown21:04:49

that works for me too

lilactown21:04:59

i can't use y or x though

lilactown21:04:06

anyway i can deal with that

lilactown21:04:20

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

lilactown21:04:46

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

lilactown21:04:12

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

lilactown21:04:19

no selection happens

pez21:04:40

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.

orestis03:04:02

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.

orestis03:04:41

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

orestis03:04:07

I always use paredit in insert mode only…