Fork me on GitHub
#clojure-europe
<
2021-09-17
>
dharrigan06:09:02

Good Morning!

pez06:09:45

🌞

reefersleep07:09:37

Good morning, and good coffee to you all!

reefersleep07:09:41

What’s your favourite language apart from Clojure (and Clojurescript 😛 )?

borkdude07:09:07

I don't have any favorites but I do like to explore other languages. The next one on my list is Zig, but I don't really have a good use case for that one personally

2
borkdude07:09:30

I dabbled a bit with Rust and Go, which were ok (Go is much easier btw)

reefersleep20:09:22

Do Rust and Go aim at the same type of applications, just in different ways?

borkdude20:09:49

Rust is more suited for things where you cannot tolerate GC overhead/pauses

borkdude20:09:22

Go is basically a dumbed down Java with go-routines which compiles directly into machine code.

reefersleep20:09:52

From what you say, and what I’ve heard before, my impression is that Go, the language, is not very interesting in itself

reefersleep20:09:33

I mean, concept-wise. But perhaps it tries to be boring. That’s a valid goal in some contexts 🙂

reefersleep20:09:25

Kind of the opposite of Clojure, which, in my book, is a firecracker of cool and useful concepts

borkdude21:09:02

yeah, the language isn't that special, but it yields small binaries (relatively speaking) and the ecosystem is pretty rich by now

2
borkdude07:09:01

I usually enjoy programming even in non-optimal languages like bash and JS but that's just my problem ;)

reefersleep09:09:23

Non-optimal by which standard? Language design?

borkdude09:09:45

non-optimal subjectively

reefersleep09:09:11

well, I feel the same about those langs, for a hazy, subjective definition of “non-optimal” 🙂

hkjels07:09:31

😂 That’s almost exactly what my response would be as well, except I haven’t dabbled with Go

dharrigan07:09:31

I quite like Kotlin

dharrigan07:09:30

I used it extensively in my previous job. Highly interoperable with Java, runs on the JVM, quite functional oriented (still quite imperative too), but brings in a lot of things that cuts down the ceremony that one has with Java

dharrigan07:09:05

There are things now in Java 16/17 that existed prior in Kotlin - so there is healthy cross pollination going on.

dharrigan07:09:45

Very good tooling support from IntelliJ IDEA (as one would expect, as Jetbrains are the originators of the language)

genRaiy08:09:31

I like C - it’s very direct. Zig is to C as Clojure is to Java - a language that is fully interoperable with the C ecosystem.

reefersleep20:09:52

I’ve always thought that it’d be perhaps boring, but very useful, to learn C.

reefersleep21:09:16

I like high level abstractions. Handling memory directly seems like a chore to me.

dominicm17:09:02

You can write a lot of useful programs without doing memory allocation! Don't be put off

dominicm17:09:59

An IRC client/bot is a good project.

genRaiy08:09:26

I have high hopes for Zig but it’s very early days

genRaiy08:09:59

Embedded systems look like a great target for Zig

borkdude08:09:42

@raymcdermott I hope to get something in bb so you can use C libs directly from bb like in Python

2
phronmophobic21:09:49

Just updated the github issue for using c libs in bb with the latest progress, https://github.com/babashka/babashka/issues/978#issuecomment-922076622 Clojure's support for calling c libraries is very good. There's https://github.com/Chouser/clojure-jna/ , https://github.com/cnuernber/dtype-next/ , and a newer option called https://github.com/IGJoshua/coffi Here's what it looks like using dtype-next:

(ns ffiexample.clj
  (:require [tech.v3.datatype.ffi :as dt-ffi]))

(dt-ffi/define-library-interface
  {:strlen {:rettype :size-t
            :argtypes [['s :pointer]]}})

(strlen (dt-ffi/string->c "Hello World"))
;; 11
It even supports repl reloading and compiling with graalvm's native-image.

😎 6
borkdude21:09:30

@smith.adriane Very interesting. The question is: would this work dynamically in bb

borkdude21:09:26

oh I read it now

borkdude21:09:29

very interesting

phronmophobic21:09:45

`dtype-next` doesn't dtype-next's support for graalvm's ffi interface doesn't allow dynamically calling c libraries but using libffi you can load shared libraries dynamically and call them

phronmophobic21:09:15

so I just wrote a dtype-next wrapper for libffi so you can ffi while you ffi

borkdude21:09:18

mindblowing

borkdude21:09:00

@smith.adriane Meanwhile we've been developing a library for the build time initialization issue. https://github.com/clj-easy/graal-build-time You can just include it in your build and leave out the other --initialize-at-build-time= options

phronmophobic21:09:24

yea, that looks awesome! looking forward to deleting a bunch of lines from my libs. I think it's still necessary to have the intialize-at-build-time flag since dtype-next relies on single segment namespaces

borkdude21:09:01

can we ask Chris to move to multi-segment namespaces perhaps

borkdude21:09:12

I'll poke him

borkdude21:09:06

can you point me to those nss?

borkdude21:09:47

ah shit, that one

😆 2
borkdude21:09:46

I think using . also works btw

borkdude21:09:55

--initialize-at-build-time=.

phronmophobic21:09:06

alternatively, we could just make a pull request to dtype-next to add the primitive-math classes to the initialize-at-build time list similar to how graal-build-time works

phronmophobic21:09:14

Would it just require creating a class in dtype-next like https://github.com/clj-easy/graal-build-time/blob/main/src/clj_easy/graal_build_time/InitAtBuildTimeFeature.java that adds the primitive math classes to the list?

borkdude21:09:16

he's only using the Java class?

borkdude21:09:59

yeah. I tried tweaking clj-easy to include single segment classes, that may also work

borkdude21:09:09

PR welcome if that works out

borkdude21:09:32

but not sure if that's a good idea. I think we should encourage multi-segment nss in the community anyway

phronmophobic21:09:01

sure. primitive math is archived, but we could fork it, change the namespace, and use that as a dependency

borkdude21:09:24

I think since that library is archived anyway, it might make sense for dtype to "mranderson" / vendor it

borkdude21:09:50

same thoughts

phronmophobic21:09:23

I can write an issue for dtype-next

👍 2
borkdude21:09:19

I will write a clj-kondo rule about this ;)

borkdude21:09:55

This is very awesome work. I will study it more in the weekend. The binary size is a bit concerning, but we can at the very least make an experimental SCI-based tool where we incorporate this and see how it evolves. Also with respect to building other Clojure libraries as shared libs. Would it be possible to pass function references over the native FFI border for example? I would be surprised if this was possible.

borkdude21:09:51

I converted the issue into a Github discussion to have more room for threads, etc.

👍 2
borkdude21:09:47

(as this seems like a longer researchy issue)

phronmophobic21:09:06

> Would it be possible to pass function references over the native FFI border for example I also doubt that this is possible.

phronmophobic22:09:02

actually, I'm just going to follow up in the discussion instead of here

👍 2
borkdude08:09:56

@smith.adriane has some ideas about this

thomas08:09:03

TGIF!!!! Morning

borkdude08:09:01

Does someone have a nice hello world but useful kind of program in Zig?

simongray09:09:25

@reefersleep Probably Python, mostly because of its rich ecosystem, its relatively simple idioms and because it (unlike Clojure) is all about being beginner-friendly. Python is like a modern Basic… in a world where Basic is also used to develop cutting-edge machine learning algorithms.

2
👍 2
🐍 2
Jakub Holý (HolyJak)09:09:57

I don't really have any other favourite lang than Clojure/Script. I would love to do some work in Rust both because it is a challenging language (in a similar way as Clj was) and because it would allow me to the low-resource, high-perf domain where JVM is not suitable. Wolfram Language is also fascinating but as I understand it it is primarily for exploring and presenting data, not really for creating stuff.

otfrom10:09:18

I find the more clojure I do, the easier it is for me to understand other lisps. The only other lisp I've done professional work in is elisp, and that feels easier to read nowadays.

borkdude10:09:42

I found it hard to go back to Common Lisp after Clojure. It feels arcane to me

otfrom10:09:47

I think my problem with common lisp and scheme was that I just reached a point quickly where I wasn't solving my problems any more, I was writing xml or json parsers (tho it has been a few years)

javahippie10:09:29

I still like Java, though I am biased, as I work with it for 13 years, now. The latest additions are really nice and enable devs to use a more functional style (although the syntax for it is still not ideal). I was a little ranty about Java in the last two years, but I realized I don’t have an issue with the language, but with the common and established architecture and patterns.

javahippie10:09:14

One downside: The “later” releases breaking downwards compatibility is a shame.

otfrom11:09:24

were there any compatibility breaks outside of the internal packages? (com.sun* etc?)

gklijs11:09:31

Some things have been removed entirely like JavaFx. But continue stand alone, and there are some limits on reflection. Not sure from which version the warning become/became errors.

javahippie11:09:47

The modularization removed some default things, also the deprecation of the security manager and the harder reflection restrictions, which increased with the latest versions

javahippie11:09:15

As a result, Lombok will likely stop working in the future, because there won’t be any workaround for what they are currently doing

gklijs11:09:09

Not sure that's entirely a bad thing. I like how Lombok prevents a lot of boilerplate, but then you need plugins for your ide to work with it and sometimes weird errors.

javahippie11:09:31

I don’t use Lombok either, for these reasons, but a lot of people do and it adds to the general frustration. People generally like the new features, but the Java Architects and Devs did not yet really manage to properly communicate the benefits of the module systems for developers.

gklijs11:09:57

Modules are only really beneficial if others use your code. It's really nice to have a clear seperation between what's considered to be the API and what not. You can build smaller apps, but that's not often really useful.

simongray12:09:10

I feel like Java could be a fantastic language if you made all of the Java devs unlearn all of the heavy-handed OOP and XML fetichism. The problem with Java are the existing codebases, not the language itself (apart from a few rough spots).

👆 4
javahippie12:09:19

I held a talk some times about how the “we might need it one day” boilerplate architecture for Java could be broken up, and that it is not a capital crime to decouple every little aspect of your software from anything else. When it came to the slides, that you don’t need to load DB entities from the DB, map it to the service layer and then to the DTO which are mapped to JSON, but that you just can extract the “Frontend Objects” directly in some cases, there were questions like “Yeah, but that’s not allowed, is it?” 😅 Edit: https://app.pitch.com/app/presentation/10ee9dd4-bfce-4e24-a858-0398ebf282a4/3be4ca15-6494-4b61-9e7f-4dfa0ae8125d

😁 2
seancorfield17:09:03

@U0N9SJHCH Just gone through that slide deck -- good stuff! And very much an argument I've had with people in a past tech life who were slavishly wed to their four-layered architecture. Glad I'm not the only "heretic" 🙂

javahippie17:09:44

Thank you! Also talked about this with Oliver Drotbohm from the Spring Data team at one meetup, this is also something he tries to promote. We are many 😄

2
👍 2
reefersleep21:09:08

What’s the “non-traditional” way to pass around data in Java, then? use “untyped” hashmaps like in Clojure?

reefersleep21:09:30

Since I moved from Java to Clojure in my day job, I’ve thought about Java code bases with public static methods everywhere and no particular data types, just maps and lists. But, I thought, “no one will work with me if I do it like that” 🙂

👍 2
rich 2
javahippie21:09:56

There are some articles / a book on using HashMaps in Java, but it is not well received by the Java devs, and imho non-idiomatic. It has a static type system after all, and circumventing it won’t do any good. While the “default” currently is to have one class for the database representation, one class for the domain logic and one class for the frontend object, which are decoupled via mappers, my preferred way (for read access, at least) is to have one object which represents the frontend data, and populate it directly from the database. This is only viable if the database is the “single source of truth”, if you pull data from different sources this won’t work as well. But a lot of applications out there are still that simple, so there is no need for the whole boilerplate and ceremony.

javahippie21:09:21

There is a blog post ripening in my brain about applying Clojure Concepts to Java, but it is more along the way of “composing libraries instead of using frameworks”, “composing your system of subsystems” and “immutability”. But it’s not quite there, yet.

reefersleep13:09:46

@U0N9SJHCH sounds interesting!

reefersleep13:09:20

I guess you can also get more transparency by avoiding doing side effects in your DTOs, or just have them be entirely "dumb" to begin with.

reefersleep13:09:33

And, generally, trying to make your functions as "pure" and side-effect free as possible. I guess that, when immutability is not built in, mutation can be OK, as long as it's obvious.

javahippie15:09:44

Yes, I guess that’s good practice in every language, OOP or FP or both. That’s the “Frameworkless” part. Many Java Frameworks force you to build “Java Beans” with getters and setters for every field, which means mutable state everywhere. I’m not sure why this style is so widely adapted, because from my understanding, that’s not what OOP should be about either

gklijs16:09:22

Yes, so Records to the rescue right? But will take a while till it works 'Frameworkless'.

javahippie16:09:59

That’s the neat part with the latest updates 🙂 Not everything can be a record, but pattern matching will promote records very well

gklijs11:09:17

I don't really have another favorite, Java, Kotlin, Elm and Rust all have there uses and nice and less nice things. Seems like I need to do a bit of Python and Golang in the near future.

dharrigan11:09:09

I'm doing a fair share of Python 3 atm, and I quite like it too

dharrigan11:09:35

as @simongray says, it's BASIC for the 21st Century 🙂 Easy to get into, lots of libraries, simple constructs and runs about anywhere!

borkdude11:09:30

The one gripe I have with Python... can't stand whitespace sensitive stuff ;)

simongray12:09:23

But that’s the best part! 😛 And also why I use parinfer.

borkdude12:09:15

Hard disagree :P

Ed11:09:38

that and yaml ... significant whitespace needs to die ... and these days it's ingrained in my brain that comma's are whitespace 😉

borkdude11:09:09

@dharrigan have you ever tried Hy?

dharrigan11:09:33

I only have so much brain capacity before things pop out of the other ear 🙂

borkdude11:09:03

Hy is basically a Lisp for the Python eco-system, if I understand correctly

borkdude11:09:37

so that would take care of the whitespace issue

dharrigan11:09:09

This reminds me of the question, I hate to open up a 🥫 🪱 but do people align their maps or bindings in a let, etc...?

reefersleep21:09:57

My editor does, and I think it reads nicely that way, so yeah 🙂

mccraigmccraig09:09:53

no, i don't really like it... but if the RHS of a binding is longish, i will sometimes put the symbol directly above the value expression, with an empty line

(let [foo 10

      bar
      (some
       long
       expr)]
  ...)
      

borkdude11:09:24

since Clojure doesn't care about this, I generally don't care about it a lot either

2
dharrigan11:09:32

🙂 Right answer 🙂

lread14:09:38

A looong time ago this Canadian worked in France and other parts of Europe. The custom of shaking hands with coworkers on the first greeting of the day was foreign to me, but I liked it. Good morning!

borkdude14:09:09

@lee I've never done that at my job

lread14:09:33

It was a long time ago.

lread14:09:43

Yeah, maybe a France thing?

2
otfrom14:09:45

in England there is at least a 2-5 meter distance between everyone, and that was before the pandemic

😆 6
reefersleep14:09:29

Not a Denmark thing, for sure.

borkdude14:09:02

Maybe @lee was in a cult?

😹 2
otfrom14:09:13

where I live in Scotland (east coast for those who will pick holes in my story) I've not really noticed any changes in daily life since the start of social distancing

lread14:09:37

It is possible I was in a cult and didn't realize it. simple_smile

otfrom14:09:53

was this you on your way to "work"?

lread14:09:55

Hmm... the dude in the white suit looks quite like my younger self.

😆 2
lread14:09:16

The other cultural greeting difference I noticed was that in Canada we'd typically say "Hi" multiple times a day to the same person, but in France, only once at the start of the day.

slipset16:09:34

This aligns with my observations. You never bonjour the same person more than once per day.

lread17:09:20

Aha! Maybe I’ve not gone crazy after all! When I bonjour-ed more than once, I’d get a somewhat shocked “Dis donc!” look back.

Jakub Holý (HolyJak)17:09:48

That is not mutually exclusive troll

lread17:09:42

Good point! simple_smile

lread14:09:32

But.... this was 25 years ago... maybe things have changed.

simongray14:09:27

From my point of view, you’re all weirdos

❤️ 8
otfrom14:09:23

awww.. thx!

otfrom14:09:27

:hugging_face:

thomas15:09:46

In Hungary you shake hands with absolutely everyone when you first meet them that day.

gklijs05:09:09

My first thought was that it's probably a good thing. And possibly explained by either less growth hormones used in the meat/milk industry, or less consumption of those. I really don't like the tone of the article, like bigger is always better.

simongray15:09:16

Experts have started saying that we have achieved COVID herd immunity in Denmark!

🎉 6
🐑 2
💉 2
otfrom15:09:04

that's interesting. I thought you'd need something like 85-90% vaccination/previous infection rates to protect against delta

simongray15:09:03

That might be the case. We have ~75% vaccinated at the moment. One difference from other European countries is the fact that we banned Astra-Zeneca/J&J and only use Pfeizer/Moderna.

otfrom15:09:20

is that 75% of adults or of total pop? (media is often pretty sloppy here so difficult to know)

simongray15:09:27

total population

otfrom15:09:36

that is awesome

otfrom15:09:20

Pfizer/Moderna seem to have different rates of effectiveness against delta, so it might make the needed rate lower. If so that is really good news. Just have to get the rest of the world up to that level now. 🙂

simongray15:09:58

fucking finally

simongray15:09:16

if true, obviously

otfrom15:09:47

<moving to a thread>

phronmophobic21:09:49

Just updated the github issue for using c libs in bb with the latest progress, https://github.com/babashka/babashka/issues/978#issuecomment-922076622 Clojure's support for calling c libraries is very good. There's https://github.com/Chouser/clojure-jna/ , https://github.com/cnuernber/dtype-next/ , and a newer option called https://github.com/IGJoshua/coffi Here's what it looks like using dtype-next:

(ns ffiexample.clj
  (:require [tech.v3.datatype.ffi :as dt-ffi]))

(dt-ffi/define-library-interface
  {:strlen {:rettype :size-t
            :argtypes [['s :pointer]]}})

(strlen (dt-ffi/string->c "Hello World"))
;; 11
It even supports repl reloading and compiling with graalvm's native-image.

😎 6