clj-commons / manifold

A compatibility layer for event-driven abstractions
1.01k stars 106 forks source link

babashka compatibility #226

Open Sohalt opened 1 year ago

Sohalt commented 1 year ago

It would be cool to have an implementation that works with babashka, to make libraries using manifold more universally available and manifold truly a lingua franca for asynchronous programming, as per the rationale.

KingMob commented 1 year ago

This probably also requires Graal compatibility. PRs welcome!

KingMob commented 1 year ago

Also see #184

KingMob commented 1 year ago

@Sohalt You tried to add Manifold to babashka, right? It would help if you could write up some of the issues you ran into.

Akeboshiwind commented 4 months ago

Not an expert in manifold by any means, but I came across this issue when looking into interceptors.

Here's a small reproduction of an error in babashka:

$ echo '{:deps {manifold/manifold {:mvn/version "0.4.2"}}}' > bb.edn
$ bb -e "(require '[manifold.deferred :as d])"
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  Unable to resolve classname: clj_commons.primitive_math.Primitives
Location: clj_commons/primitive_math.clj:4:3

----- Context ------------------------------------------------------------------
1: (ns clj-commons.primitive-math
2:   (:refer-clojure
3:     :exclude [* + - / < > <= >= == rem bit-or bit-and bit-xor bit-not bit-shift-left bit-shift-right unsigned-bit-shift-right byte short int float long double inc dec zero? min max true? false?])
4:   (:import
     ^--- Unable to resolve classname: clj_commons.primitive_math.Primitives
5:     [clj_commons.primitive_math Primitives]
6:     [java.nio ByteBuffer]))
7: 
8: ;;;
9: 

----- Stack trace --------------------------------------------------------------
clj-commons.primitive-math - clj_commons/primitive_math.clj:4:3
manifold.executor          - manifold/executor.clj:2:3
manifold.deferred          - manifold/deferred.clj:5:3
user                       - <expr>:1:1

Looks like the first issue is in primitive-math :)

KingMob commented 4 months ago

Dunno what that's about. The path/ns/etc are correct. No idea how bb loads it with sci.

Only possibility that immediately jumps to mind is, primitive-math was written in an older era, before Lein suggested separating the java- and clojure-containing src dirs. When both languages share the same src root (src/ in this case), you can occasionally see weird loading order issues. But that's with lein.

Akeboshiwind commented 4 months ago

I think it's that babashka doesn't load external java files, I'll admit I've not looked into it too much though.

Also don't worry about looking into it too heavily, I was mostly posting to add information not because I need this issue solved :)

KingMob commented 4 months ago

No worries, it's valuable. People ask about Graal compatibility every few months, but from the few stabs we've taken at it, it seems like a lot of work.