Comments (19)
Here's a screenshot with puget + the above changes made in a local checkout of fipp:
from fipp.
Note that zprint already works with bb:
(ns zprint
(:require [babashka.deps :as deps]))
(deps/add-deps '{:deps {org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}
zprint/zprint {:mvn/version "1.2.3"}}})
(require '[zprint.core :as zp])
(println (zp/zprint-file-str (slurp *file*) "yolo" {:color? true :style :dark-color-map}))
but some users would like to use fipp as well.
from fipp.
Submitted a PR to address point 2: #82
I think that change would be good in general, not only for bb.
from fipp.
Hey @borkdude, thanks for the detailed writeup and PR #82 (merged!).
In general, I'm willing to make improvements (cleanup, fixes, etc) that also extend compatibility, but would like to avoid accreting compatibility cruft. On that front, I'm disinclined to eliminate the dependency on rrb vectors & would instead encourage you to upstream the compatibility fixes there.
Perhaps worth mentioning is that Fipp used to use finger-trees for ClojureScript (See a2bd18a), but rrb-vectors grew support there. I might also consider an alternative dependency that provides a dequeue interface more abstractly.
from fipp.
On that front, I'm disinclined to eliminate the dependency on rrb vectors
Just to be clear, I'm not asking to eliminate the dependency, the change would be hidden behind reader conditionals for bb. clj + cljs would still be using rrb. But I understand that you would not like to deal with compatibility for more than clj and cljs.
from fipp.
I haven't looked too deeply into this library, but Java also comes with a Deque implementation:
https://docs.oracle.com/javase/7/docs/api/java/util/Deque.html
Perhaps you've already considered that.
from fipp.
Needs a functional/persistent dequeue.
I didn't mean to cause you to close this issue. Still open to small changes to support Babashka, but my hope is that can be as easy as bumping an rrb-vector dependency.
from fipp.
A few thoughts:
-
I don't think it makes a lot of sense to make rrb compatible from source so we can run rrb from source with babashka. Performance of code executed with babashka is several times slower than executed with the JVM. Falling back on regular vector will likely make things faster in babashka than executing rrb from source to optimize concatenation of vectors. Of course I haven't measured this and I might be wrong.
-
Babashka has built-in dependencies which execute as fast (since they're just using the compiled code). Babashka could decide to include rrb as a built-in dep. But so far, I haven't seen many other libraries that need rrb, other than those depending on puget / fipp.
-
Maintaining a fork of fipp is still an option. Maintaining a separate repo that creates a "polyfill" for rrb that falls back on clojure.core is another option. The latter option seems to be the least intrusive for fipp. I could give that a try first.
from fipp.
Babashka could decide to include rrb as a built-in dep.
Looking at this patch here: babashka/babashka#1241 (comment)
I don't know anything about Babashka, but do you have some sort of library/namespace/function stub/patch mechanism? Seems like you could stub either fipp.deque or clojure.core.rrb-vector and you only need that one catvec function?
from fipp.
@brandonbloom Babashka is able to "fake" any Clojure function via the SCI (interpreter) configuration, so that's certainly an option to try. I will try that soon.
from fipp.
I have a development version of babashka here (for macOS):
which can run fipp (the current version from master).
What I've done is include rrb vector proper, but only the catvec
function. This adds 350kb to the binary. Might be worth it, but I'll wait for feedback in greglook/puget#56, to see if I can keep it at that for compatibility for fipp + puget.
$ rlwrap ./bb
Babashka v0.8.2-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.
user=> (babashka.deps/add-deps '{:deps {fipp/fipp {:deps/manifest :deps :git/url "https://github.com/brandonbloom/fipp" :git/sha "efdf87f22a6fcc08cef5017c14769df29fc37850"}}})
nil
user=> (require '[fipp.edn :as fipp])
nil
user=> (fipp/pprint (range 45))
(0
1
2
3
4
from fipp.
Finally got to the point that hashp is working in babashka (current master version)
;; add fipp from master
(babashka.deps/add-deps '{:deps {fipp/fipp {:deps/manifest :deps :git/url "https://github.com/brandonbloom/fipp" :git/sha "efdf87f22a6fcc08cef5017c14769df29fc37850"}}})
;; add newest zprint which is already compatible with bb (hashp also loads zprint)
(babashka.deps/add-deps '{:deps {zprint/zprint {:mvn/version "1.2.3"}}})
;; add babashka fork of clojure spec
(babashka.deps/add-deps '{:deps {org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}})
;; add hashp
(babashka.deps/add-deps '{:deps {hashp/hashp {:mvn/version "0.2.1"}}})
(require '[hashp.core])
(set! *data-readers* {'p hashp.core/p*})
from fipp.
If you can release a new version of fipp, then we don't need the git/sha stuff anymore and then I think we can close this issue.
from fipp.
What I've done is include rrb vector proper, but only the catvec function. This adds 350kb to the binary.
I'm not sure I follow, but I am curious: What does it mean to add it "proper" but only one function?
from fipp.
deployed: https://clojars.org/fipp/versions/0.6.26
from fipp.
@brandonbloom It means I've only exposed the catvec
function to the interpreter:
https://github.com/babashka/babashka/blob/master/feature-rrb-vector/babashka/impl/rrb_vector.clj
GraalVM native-image will analyze what is used and will not include other vars in the native image, if they are not reachable.
from fipp.
Thanks!
from fipp.
It means I've only exposed the catvec function to the interpreter
Since catvec returns an object of the rrb vector class, presumably that means a fair amount of code is then included?
from fipp.
@brandonbloom Yes, that fair amount of code yields about 350kb.
from fipp.
Related Issues (20)
- Just a small warning in CLJS (undeclared var `fipp.edn/*file*`) HOT 1
- Cannot load fipp in Java 9 using bootclasspath HOT 10
- Optional println? HOT 1
- Make usage of commas optional HOT 3
- :pass rendered before indentation HOT 4
- clojurescript tests failing HOT 2
- consider automating tests on circleci HOT 3
- print-table of nested map HOT 1
- Use of undeclared Var clojure.core.rrb-vector.rrbt/Transient HOT 3
- java.sql.Timestamp not guaranteed to exist HOT 9
- BigDecimal Handling HOT 10
- Escaping of newlines in strings HOT 2
- Incompatible with Java 11 due to org.clojure/core.rrb-vector dependency HOT 1
- a strange case in generating regex with slashes, related to ClojureScript HOT 5
- print unreadable symbol utilizing #=(symbol ...) for *read-eval* HOT 1
- How to specify fixed width floats in specific tagged-literals for output purposes HOT 2
- ClojureScript: fipp interacts badly with console.log as default print strategy HOT 6
- UnsupportedOperationException when printing java.sql.Date HOT 2
- Optionally print without trailing comma HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fipp.