Fork me on GitHub
#clojure-europe
<
2022-04-01
>
agigao04:04:22

Morning folks ☀️ I started writing code pretty early today and not sure if waking up at 5:55 turned off my mind but would like to ask for assistance to verify or refute my thinking. The problem at hand is to validate a token, which obviously contains 4-5 checks along the the way before we say it’s valid. My current approach (not exactly charming):

(-> token
      check-1
      check-2
      …
      ;; if all is true then confirm validity of token
  )

(defn check-1 [token]
   (when ... m))

(defn check-2 [token] ...)
Basically, when predicate of each functions yields true for token then I pass it to the next and so on. The major problem I see is lack of abstraction here and tests for each function are very very specific. Please, feel free to throw in other problems as well or perhaps completely refute the approach morning

Jakub Holý (HolyJak)07:04:43

could you elaborate on > lack of abstraction here and tests for each function are very very specific. What abstraction do you feel you need? For the chain of checks? @U04V5VAUN idea is excellent here IMO What tests are very specific? Unit tests? They need to test the very specific condition the predicate is checking so they need to be specific? I overlook the problem you obviously see...

agigao04:04:06

Apologies for delayed response, spend some time in the hospital. every-pred is definitely a very good idea that will let me build a nice pipeline. Regarding tests:

(defn f [{:keys [x]}]
  ...)

(defn g [{:keys [x]}]
  ...)
I mean the function very much depends on the provided data because I’m destructuring arguments, instead of providing a specific data the function needs. I’m not thinking too clearly but I guess it’s my thinking process right now. Getting a token in a proper shape takes a couple of procedures, so if I want to test f and g , either I couple them together under a single deftest or run procedures 2 times for each function deftest.

slipset05:04:24

every-pred?

❤️ 2
slipset05:04:06

This year has so far been a year of rewriting old js to new ts. I'm not complaining, I've chosen it myself, and,I actually quite enjoy it. The thing is. Last time I dis any serious js work was probably around 2016. At that point in time there was no hot reloading, no storybook, no functional react components, there was barely react. Whereas now, if you start a new ts/react project, you only have to squint a wee bit and it looks just like Clojurescript. So where am I going with all this? I guess I'm wondering if the ts/react ecosystem has adopted so many of the ideas that made cljs great so there isn't really a good reason to choose cljs anymore? For me, the biggest differentiator is the syntax, I really like editing code with paredit, and that “we” use hiccup rather than tsx. Thoughts?

pez05:04:22

I've not tried web frontend development in TS or JS in a long time, so can't really comment on that part. It makes me happy to hear about these improvements! When hacking on Calva, which is mostly TypeScript, I find the lack of a REPL being the big difference. It is just so much more efficient and more fun to work with the ClojureScript parts of Calva because there I have the REPL. With it I can modify and inspect Calva by evaluating some piece of code. With the TypeScript parts of Calva this can't be done, afaik. The closest I get is modifying units covered by unit tests, but that is much inferior from using the extension as it is being modified.

slipset06:04:05

Deffo a thing when working on non-web’y things.

borkdude07:04:21

If you need to develop a script for Node.js in a REPL, take a look at #nbb

jackrusher07:04:58

nbb is definitely the most civilized way to work with Node! OTOH, there is still no great browser experience for CLJS 😕

😬 1
Jakub Holý (HolyJak)07:04:24

I would not exchange #fulcro for a TS framework and cljs is a big part of it. Why? • REPL! Yes, I need it far less then in clj due to hot reloading but it is great for troubleshooting, exploring the app state and simulating user actions without touching the damn ui 🙂 Also. tap> and Shadow Inspect! • Awesome core fns for transforming and "changing" sequences and maps • The pure beauty of a lisp rich • Occasionally the distinction between def and defonce is very handy. Not sure what TS does for that that should/not survive a reload • Of course sharing code, specs between FE and BE (you wouldn't write your BE in TS, would you? would you?!!! troll ) Also transit/edn >> json

pez07:04:23

I started my Clojure endeavor with ClojureScript for web dev and then with mobile dev. Hot reload is fine, but I tend to use the REPL more. Many files stay unsaved for hours while I modify the running app. A part of me dies without the REPL.

borkdude07:04:48

> Many files stay unsaved for hours Living on the edge... I tend to commit my files every few minutes to a wip branch :)

🦾 1
genRaiy08:04:08

For me, CLJS is a tool that I - who knows CLJ - can use to get a simple UI up and running much easier than JS/TS ... cos I don't have to learn all of that. Not a great reason for sure but I'm putting it out there all the same.

borkdude08:04:52

Same for me. I didn't touch JS/front-end stuff until CLJS

slipset08:04:54

Fair enough for us who know CLJ, but imagine you wanted to sell CLJS to the TS crowd. In 2016, there were some really good arguments, but now the TS crowd has adopted much of that.

genRaiy08:04:51

yeah I think that's also the point of @U07SQTAEM - it's not a good enough experience to break through. And MS have a lot more money than Nubank who, afaik, don't care about CLJS. Maybe I'm wrong about that .... would love to be.

Jakub Holý (HolyJak)08:04:42

The great thing about cljs is that you do not have to change your framework and tooling every few months 😹

slipset09:04:22

Not necessarily true, as any non-trivial CLJS app will be relying on the TS/JS ecosystem.

👍 1
borkdude09:04:59

I talked to a Clojure person recently who has been trying to get his colleagues to use Clojure in the past 7 years. He gave up on using Clojure now because he's tired of trying to convince and is now making an interactive browser dev environment in JS. 🤷

borkdude09:04:32

For other companies CLJS is a huge success: penpot, whimsical, roam research, etc. If you buy into the mindset and everybody is on board then it works wonders.

orestis11:04:39

Don't get fooled by the fluff of TS. You're still dealing with mutable data at the core. Every library you use depends on that. Also, the JS standard library is still crap/severely lacks features.

❤️ 1
Jakub Holý (HolyJak)11:04:22

I also gave up on persuading my colleagues to change language and changed colleagues instead 🙂

💯 4
simongray11:04:54

There are some overarching “types”—or maybe traits—that sort of make sense, e.g. whether a data structure is sequential, associative, etc. that I sort of wish you could statically define in Clojure instead of relying on predicate functions, but other than that I’m with Rich on types: it’s a trade-off and most of the time you’re exchanging velocity for what is essentially security theatre.

simongray11:04:38

The Clojure—and by extension CLJS—core API is focused on what matters the most: clear and mostly consistent naming of functions and inputs, preferably as generic as possible to cover the broadest possible range of inputs. To me, that’s the holy grail, not the specificity that static type checking brings. Adding type checking doesn’t just add ceremony and extra lines of code, it also removes the operational clarity of the code. The beauty of well-written Clojure code is that it’s possible to write it in such a way that it is almost at the point where you can’t even remove a single character without removing functionality. I haven’t found that quality in other general purpose programming languages, only in DSLs.

❤️ 2
lread15:04:41

CC @U02N27RK69K who, might have some thoughts to share on TypeScript?

lread15:04:53

Ya, thought of you and your expertise @U02N27RK69K when I saw this TypeScript discussion. simple_smile

lread15:04:23

(in other words I had nothing to add to the discussion but you)

💜 2
Cora (she/her)15:04:59

I love typescript on the frontend. frontends are volatile places with constantly changing structures and requirements, much much muuuuuch churn, and so having a type system makes things so much more solid and lets you know where changes spider out and affect other things

Cora (she/her)15:04:26

plus you're interacting with tons of browser APIs which have very non-clojure-y interfaces. the editor assist on these in typescript is chef_kiss

❤️ 1
borkdude15:04:15

strangely I never really miss that, as I just inspect things in the browser console when I need to

borkdude15:04:50

but I'm probably weird cause I also tend to write Java in emacs without any IDE assistance and just look up the javadocs ;)

Cora (she/her)15:04:54

I remember really disliking typescript when I first started using it and then eventually loving all the affordances. so yes, I didn't really miss it until I got used to it and now when I don't have it it's painful.

Cora (she/her)15:04:20

it's trade-offs all the way down as usual, though 🙃

borkdude15:04:30

yeah, when you switch to an IDE you become kind of addicted to those things

Cora (she/her)15:04:15

the same with the clojure repl

☝️ 1
Cora (she/her)15:04:16

I do wish there was a better SSR story with clojurescript. especially for mostly static sites it makes a big difference

Cora (she/her)15:04:38

and also I wish there were more compact and complete ways to describe data structures in clojure(script) like you get in typescript

pez15:04:07

Being addicted to the repl is like being addicted to food. Addiction to types more like being addicted to pictures of food. 😀

😅 1
lread15:04:14

Is the rumour that Rich Hickey’s IDE is Notepad true?

Cora (she/her)15:04:29

and that there was a community practice to describe input and output structures consistently and verifiably so that when you're looking at functions in isolation it's clear what they take and what they return

Cora (she/her)15:04:54

nobody: me: sooo what if clojure but typed

borkdude15:04:57

@UE21H2HHD Notepad: probably not, who told you that? He was using Aquamacs back in the day (emacs port for macos)

borkdude15:04:55

(that was just one version of a typed clojure at one point in time, things might have changed)

Cora (she/her)15:04:54

mostly that just sounds like the problems of a language not built with types from the start. bolting on types can be messy

borkdude15:04:07

says a TypeScript user ;)

😂 1
Cora (she/her)15:04:22

it caaaaan be :D

Cora (she/her)15:04:36

typescript has come a long, long way and it definitely doesn't take 2 minutes to type check a single namespace

pez15:04:36

I love that Clojure is un-typed. Never missed it.

lread16:04:21

I love that this community can bring up the word “type” without it devolving into some sort of gongshow. 🙂

Jakub Holý (HolyJak)16:04:39

Thanks a lot for sharing your experience, @U02N27RK69K!

💜 2
lread17:04:24

Ah maybe it was Alex and notepad I was thinking of… https://clojurians.slack.com/archives/C03RZGPG3/p1522725461000220

orestis18:04:03

The thing that turns me off in TS is that it still feels "not done". That is, I first tried it back in 2016? 2017? and it was a good improvement over writing "naked" ES6 JS -- but 5-6 years later, the amount of change in how you can type things is mind boggling. I suggest going through their release notes and see if you're comfortable with such churn.

orestis18:04:11

The idea of TS comes from a good place: JS is a wild west where undefined can spring at you from many places, and have catastrophic effects. Having a compiler guard you from that makes sense. The implementation, hm, well, up for debate.

Cora (she/her)18:04:56

the increase in expressiveness with each version is nice but honestly not something I use all that often

Cora (she/her)18:04:35

mostly it's just "this is a map with these fields and these possible values for each"

Cora (she/her)18:04:14

that's like 90% of my use of it

orestis18:04:20

Gary Bernhardt is/was on a quest to fully type everything. A very interesting Twitter feed. Everything as: • results of SQL queries • routes • serialisation so reusing types between frontend/backend etc The idea being that if say you rename a column in your DB, your frontend doesn't compile because the reference is broken.

Cora (she/her)19:04:19

that's the dream

borkdude19:04:14

for some people it's a nightmare

Cora (she/her)19:04:18

what is a nightmare but a bad dream 😴

borkdude19:04:57

like, "hmm, we have a problem figuring out this type and we don't care, but now we can't deploy, hmm, and this customer is waiting" situation

Cora (she/her)19:04:45

there are escape hatches! you can tell typescript to ignore things :)

Cora (she/her)19:04:26

but also I've never been in that situation and I never tell typescript to ignore things

Cora (she/her)19:04:01

well, no, now I can remember a couple

borkdude19:04:11

not yet, but I mean, that system-wide-typing thing sounds scary and impractical to me :)

Cora (she/her)19:04:08

I've found a lot of type systems painful to use but typescript's is pretty chill. I get that for a lot of people they have scars around this stuff

borkdude19:04:07

When I first saw TypeScript years ago my initial reaction was: why the hell would anyone write Java in the browser

Cora (she/her)19:04:10

mostly it catches things I forget about. like if I change a string to a map and forget to handle it some place, it tells me where

Cora (she/her)19:04:44

it doesn't feel anything like java

borkdude19:04:21

maybe I should give it go, well actually I'm using it in two very tiny spots (extension.js for a couple of vscode plugins I maintain)

Cora (she/her)19:04:48

maybe you'll like it! or maybe you'll learn you were right and you hate it. I mostly use it in the context of functional react, not java-like factories and interface/impl pairings and stuff. it mostly ends up just being typing of maps and arrays which is helpful without being painful

Cora (she/her)19:04:19

so if you try to write java in it then maybe it does suck in that context shrug

slipset20:04:34

It’s also interesting how easy it is to conflate OO and type systems. The way I end up doing TS is very comparable to CLJS, but with enforced specs on everything. And the code is mainly static fns munging data

1
borkdude20:04:58

@U04V5VAUN I wish all Java methods were static too ;)

borkdude20:04:20

@U04V5VAUN A feel a new talk coming from you: TypeScript for CLJS programmers ;)

😂 1
Cora (she/her)20:04:30

plus using emotion.sh and jsx means I can have every component self-contained

Cora (she/her)20:04:18

and even have syntax highlighting/completion for html and css alongside the js syntax highlighting/completion. it feels more whole, all together, and tightly scoped

borkdude20:04:41

don't make us too jealous, we have CLJS to do!

pizzaspin 1
pez05:04:19

Morning!

dharrigan07:04:33

Good Morning!

simongray07:04:37

good morning

genRaiy07:04:24

Good ❄️ morning

😍 1
thomas09:04:04

morning.... TGIF!!!! Albeit a white one!

thomas09:04:34

but the snow is disappearing quickly, definitely not staying

borkdude09:04:35

Goat moaning!!!

🐐 1
orestis11:04:40

Finally I can boast some sunny weather. 22 degrees in Athens.

reefersleep11:04:01

Does anyone know a tool for discovering irrelevant :exclusions?

reefersleep11:04:35

We’ve got a lot of dependency conflicts that we tend to fix with :exclusions. But there’s no easy, automated way to discover when an :exclusion becomes irrelevant.

reefersleep11:04:45

Or, indeed, to see why it was instated in the first place.

borkdude11:04:40

@reefersleep I think clj-kondo could easily do this

❤️ 1
borkdude11:04:49

but it hasn't got it right now. PR welcome :)

borkdude11:04:44

This is something I wanted to have for a while

reefersleep11:04:43

ah, maybe I was unclear. I meant in project.clj’s

borkdude11:04:13

ah ok, but you triggered an idea I already had, even if it was unrelated. good luck with project.clj :)

🍻 1
simongray11:04:16

If you can produce 1) the list of “calculated” dependencies for your project (= the whole dependency tree) and 2) a list of the local dependencies for each of your explicit depended-on libraries, then shouldn’t you be able to determine if the exclusion is meaningless if the final calculcated dependency has a higher version number than the excluded local dependency? Obviously, this trick would only work in cases where you are still bringing in that dependency through some other means. I’m not sure how you can determine if a total exclusion—i.e. one that isn’t brought in elsewhere by one of your other dependencies—is unneeded other than trough trial and error. (not sure if I am communicating my point clearly enough, shit’s hard)

reefersleep13:04:28

I think I get it, and yeah, it’s hard to talk about!

reefersleep13:04:19

Maybe “higher” is a sufficient heuristic, maybe not. But in any case, yeah, having the calculated whole dependency tree of project A compared against the dependency trees of each dependency (B, C, D etch) of project A would perhaps yield some interesting options for automated or semi-automated resolution.

reefersleep13:04:14

But my brain is exploding thinking about how to do thorough verification (is lein check enough?) along with sane resolution (how to automatically coordinate several exclusion vectors in one project.clj in the best possible manner?)

reefersleep13:04:32

Perhaps it’s too late in the week for such thoughts 🙂

simongray14:04:11

maybe you don’t even need higher, you just need present

borkdude11:04:07

(damn, I should have read this better)

practicalli-johnny14:04:48

I started a new book to capture some of the lessons learned when adopting a more vegan approach to food, which has been helping me mitigate some of the covid symptoms (and diabetes & hyperthyroidism were exacerbated along with it) or at least avoid putting on lots of weight when unable to exercise due to low blood oxygen. https://practical.li/vegan/ This is very much a side project as a step away from the often chaotic world of software engineering. So far its just capturing some aspects I have learned about making milk (hemp milk is my favourite). https://github.com/practicalli/vegan/issues and pull requests for recipes, raw indigence and cooking tips most welcome And no, this is not an April fools joke 😂

😍 3
🥕 2
borkdude14:04:43

As a long time (+10 years) plant-based and vegan enthusiast, I applaud this!

genRaiy14:04:49

🥕 🍆

gklijs15:04:47

Nice, been two years for me, I do sometimes cheat with cheese, when there are no vegan options.

practicalli-johnny15:04:19

I think the final push away from meat was in the year 2000, after I had been living on the border between The Netherlands and Germany. I worked in a textile factory (doing software) and no one could explain (or seemed to care) what the 'meat` the canteen served was made from. It really got me thinking. Watching people eat 'from the wall' at Febo in Amsterdam also was a bit of a wake-up call. I became vegan rather than just vegetarian mostly because I discovered dairy really messes with my body, even more-so if there is a global pandemic of a flu-type virus. Cheese is still a tough habit to break, until I discovered yeast flakes which have replaced my cheese addiction with a yeast flakes addiction. Brexit vote was also a driving factor because I stopped shopping in supermarkets (getting very expensive from 2016) and started buying raw ingredients in bulk, so much cheaper and far higher nutritional value (and buying 25kg of chick peas at a time means I'm less at whim to price fluctuation due to trade barriers or food shortages) I am still working on the sugar addiction and over-eating my grandparents helped me establish in my early years 🙂

borkdude16:04:24

There's yeast flakes standing next to the laptop I'm typing on

practicalli-johnny16:04:22

I havent a name for this yet, but I like to blend pale skin peanuts with a splash of hemp milk to make a nice protein spread, which I use in a toasted pitta bread and liberally sprinkle with yeast flakes for a rich cheese taste. For a bit of a kick, I add a pinch of cayenne pepper powder or a few jalapenos. Hmm, I am hungry now :)

borkdude16:04:22

Peanut allergy :)

practicalli-johnny16:04:23

I assume it would work with a nice thick tofu spread instead of the blended peanuts :)

practicalli-johnny16:04:54

unless there is also a soya bean allergy 😞

borkdude16:04:55

nope, luckily not!

gklijs16:04:06

Yeast flakes are nice as well. Problem is more with social things like having lunch with colleagues. But there is a place right next to the Utrecht office with nice vegan options. Meetups can be a 'problem' to, and it's not always feasible to bring my own food.

orestis18:04:12

Wow, can you eat yeast flakes like a snack? e.g. right from the bag? 50g of protein per 100g is crazy high.

borkdude18:04:01

@U7PBP4UVA I usually use it on pasta and things like that

orestis18:04:30

Greek food can easily be 100% vegan, but dairy plays a big role. But high-protein sources are always interesting, I'm looking to increase my protein intake to lose some weight.

borkdude18:04:10

@U7PBP4UVA Beans are very satiating and contain relatively much protein.

borkdude18:04:54

Also vegetables contain much protein compared to other macro-nutrients, but they just don't contain a lot of calories to begin with :) But eating a shit-ton of vegetables is a good strategy to lose weight, provided that you don't use a lot of oil on them (e.g. in salad dressings) which very is heavy in calories and contains hardly any nutrition value.

borkdude18:04:06

If you're interested in my only medium blog, and co-incidentally about this subject ;) https://medium.com/@borkdude/tl-dr-of-my-long-term-weight-loss-and-maintenance-success-49cb43f62a1a

orestis18:04:01

Sadly in recent years I don't tolerate beans and other legumes 💨 -- I still eat them regularly but I want to have alternative sources of protein. Another quirk I have is that I like my meals to be warm so I never found salads compelling. Thankfully now that I'm back in Greece vegetables do taste oh so much better and it starts to get warmer.

orestis18:04:03

@U04V15CAJ The amazon list is 404

borkdude18:04:24

yeah I noticed, apparently they removed this feature :/

borkdude18:04:47

A few authors I enjoyed reading/watching lectures from: John McDougall, https://nutritionfacts.org/ (Dr. Greger), Forks over Knifes (Netflix, might still be there), Fuhrman m.d. (book called Eat to Live)

borkdude18:04:37

The concept they all have in common is called "Whole foods plant based" eating and if you search for this in google you will find a ton of material probably

lread15:04:52

Goat mooing

🐐 2
🐮 2
borkdude21:04:20

Really enjoying my new tool...

🙀 5
🤡 2