Fork me on GitHub
#clojure
<
2022-03-27
>
West00:03:44

So I wanna make a desktop app, but I don't really wanna use something java based as wayland support is non-existent. Intellij idea won't work on sway. How difficult would it be to have Clojure somehow interface with GTK?

Joshua Suskalo01:03:02

or if you want a clojure-based wrapper, you could use coffi https://github.com/IGJoshua/coffi

Benjamin C03:03:44

Probably too young at this point, but I am looking at https://github.com/HumbleUI for this type of thing.

Benjamin C03:03:22

(It's not using GTK, but it does? (will) support Wayland).

phronmophobic19:03:32

Glfw claims to support wayland. The various libraries that use glfw might be an option: • https://www.lwjgl.org/https://github.com/JetBrains/skija/https://github.com/phronmophobic/membrane (my library) For better or worse, it's a very different beast than GTK. There's also the cljs route with something like electron.

West20:03:13

The only reason I ask, is because I'm trying to avoid Electron. Neutralino seemed promising, but unfortunately I can't get passed a simple bug within it.

West20:03:09

I've also used cljfx, and seesaw with some success, but that was on MacOS. I'm also concerned about wayland support for two reasons. 1. It's what I live in on a daily basis 2. It has great HiDPI and MultiDPI support, unlike X will ever have.

West20:03:45

I'm gonna test out these things for sure @U7RJTCH6J.

👍 1
West04:03:36

Maybe it's possible to use libpythonclj to interface with GTK or Qt.

Joshua Suskalo14:03:28

oooh, skija seems pretty cool

West20:03:54

Maybe Graalvm can help as well, not sure though.

SK10:03:21

Is there a binary version of .edn? What I'm looking for is more performance and less disk space usage, but keep it schema-free. What are you using for that? As a compromise I thought I'll use .edn but ZIP it before/after, but I guess there is something more high tech than that 🙂

thheller10:03:33

transit and fressian are options

👍 1
mkvlr11:03:59

nippy has excellent performance & compression

👍 1
SK11:03:03

Is there some good resource to learn about the new stuff in clojure 1.11 ? I mean something more elaborate than the official release announcement

p-himik11:03:23

There was a video recently linked in, I think, #news-and-articles

👍 1
Carlo14:03:55

I think I saw some video (maybe the same) in the latest deref

👍 1
borkdude14:03:54

I remember there was some -slim jar distribution in which clojure was not directly linked / AOT-ed, but I don't see that on mvn. Tangentially related, is there also a jar that includes the Java sources and how could one discover these alternative jars?

Alex Miller (Clojure team)14:03:52

there is a "slim" classifier out there

Alex Miller (Clojure team)14:03:20

you'd use it with org.clojure/clojure$slim {:mvn/version "1.11.0"} for example

potetm14:03:48

Are classifiers a maven thing? It’s weird that you cannot see these at all on http://mvnrepository.com.

Alex Miller (Clojure team)14:03:31

classifiers are a maven thing, yes

Alex Miller (Clojure team)14:03:03

classifier artifacts are weird in that they all share the same pom. they were originally intended for "variants" of an artifact (specific to a jdk or architecture) but are also somewhat abused for more metadata like things (source, javadoc)

Alex Miller (Clojure team)14:03:18

I don't think the designers of Maven understood the problem space enough at the time of design and things in this area are complected

borkdude14:03:42

Thanks! Ah, so there is a -sources classifier. But would that also contain the compiled classes, or is that an extra dep to pull in?

borkdude14:03:07

(I assume the latter, since the dep name makes it a different dep?)

Alex Miller (Clojure team)14:03:21

sources is not intended to be a runnable thing, it's original intent was for providing Java source for Java artifacts

Alex Miller (Clojure team)14:03:00

if I understand what you want, it's the slim classifier, which is intended to be non-AOT Clojure artifact

borkdude14:03:55

well, I was looking actually for $sources, since Eric and I are adding Java class navigation to kondo/lsp. So if people would include that extra artifact, they would be able to navigate to the source (rather than decompiling the .class)

Alex Miller (Clojure team)14:03:22

ah, so then you do probably want sources, although I don't recall if that has the Java source in it

borkdude14:03:44

oh I see :)

Alex Miller (Clojure team)14:03:20

yeah, sources has clojure and java source in it

🎉 2
borkdude14:03:06

Confirmed:

$ clojure -M:clj-kondo/dev --lint $(clojure -Spath -Sdeps '{:deps {org.clojure/clojure$sources {:mvn/version "1.11.0"}}}') --config '{:output {:format :edn :analysis {:java-class-definitions true}}}' | jet -f '(fn [out] (take 10 (filter #(str/ends-with? (:uri %) ".java") (:java-class-definitions (:analysis out)))))' --pretty
({:class "clojure.asm.SymbolTable",
  :uri "jar:file:file:/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar!/clojure/asm/SymbolTable.java",
  :filename "/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar:clojure/asm/SymbolTable.java"}
 {:class "clojure.asm.Label",
  :uri "jar:file:file:/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar!/clojure/asm/Label.java",
  :filename "/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar:clojure/asm/Label.java"}
 {:class "clojure.asm.Attribute",
  :uri "jar:file:file:/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar!/clojure/asm/Attribute.java",
  :filename "/Users/borkdude/.m2/repository/org/clojure/clojure/1.11.0/clojure-1.11.0-sources.jar:clojure/asm/Attribute.java"}
 {:class "clojure.asm.TypePath",
...

Asko Nōmm16:03:35

Am I imagining it or is flattenv no longer a function in Clojure? I can’t seem to find anything on Google, but I could swear that I’ve used it before.

p-himik16:03:36

According to git, it has never been a part of Clojure itself. Maybe you've seen it in some library.

Asko Nōmm16:03:40

Yea could be I suppose. Thanks for checking!

Noah Bogart17:03:25

There’s mapv and filterv. Maybe you've conflated the two?

Asko Nōmm18:03:55

Now that I think about it yeah it could be I’m confusing it to filterv.

chouser18:03:28

What's the best way to read an untrusted edn string with line and column numbers attached as metadata? It appears that both clojure.edn and clojure.tools.reader.edn will track line numbers when given the right kind of input stream, and will use those line numbers in exceptions, but neither attaches them as metadata like clojure.core/read does.

borkdude19:03:48

Perhaps https://github.com/borkdude/edamame will help you here, it's quite configurable so it's likely that you can tweak it to your likings

borkdude19:03:20

By default it aggressively attaches metadata to any value that it can

borkdude19:03:29

which can also be selectively tweaked

chouser14:03:11

Looks perfect, @U04V15CAJ. Thanks!!

borkdude14:03:01

Good to hear! Let me know if you have any questions. This library is used as the parsing library in SCI (babashka, nbb, etc), clerk, etc. and has seen quite a lot of exposure, so it should be fairly battle tested.

jaide19:03:12

Is this possible with case:

(case [:a :b]
  [:a :b] "a b combo"
  [_ :b] "at least b" 
)
Or does it not work like that?

Apple20:03:33

user=> (let [[x y] [:a :b]] (if (= [x y] [:a :b]) "a b combo" (if (= y :b) "at least b"))) "a b combo" user=> (let [[x y] [:c :b]] (if (= [x y] [:a :b]) "a b combo" (if (= y :b) "at least b"))) "at least b"

pithyless21:03:10

@U8WFYMFRU - without using core.match, you could probably get something similar, but a little more verbose, with cond. BUT, you may be interested why exactly this isn't possible with case: the clauses are compiled into a tableswitch on the JVM that provides constant lookup (instead of linear, like cond). That's why they must be literals (need to be known at compile time) and they can't be ambiguous like in your example (because they are not compared at in order - they either exist in the lookup table, or not).

jaide21:03:34

Right, compile time literals. That's how I understood it but wanted to ask to see other options. For practical purposes, I just went with cond as I don't want to add core.match just for one function

pithyless21:03:31

OK :) I was surprised the first time I learned how case actually works, so I thought I'd point it out. e.g. prep-hashes does a lot of work to convert Clojure structures into integers that avoid hash-collisions and are densely packed: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6719-L6745

jaide21:03:38

Ah cool, thanks for breaking down the implementation, that part I definitely did not know

potetm19:03:49

it does not work like that

potetm19:03:09

https://github.com/clojure/core.match is what you’re looking for, I think

Martin Půda19:03:24

(clojure.core.match/match [:a :b]
  [:a :b] "a b combo"
  [_ :b] "at least b")

jaide19:03:48

Good to know, thanks