This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-18
Channels
- # announcements (35)
- # babashka (14)
- # beginners (23)
- # calva (5)
- # cljsrn (3)
- # clojure (154)
- # clojure-europe (12)
- # clojure-losangeles (2)
- # clojure-uk (5)
- # clojurescript (42)
- # conjure (3)
- # cursive (10)
- # datomic (3)
- # emacs (6)
- # events (1)
- # graalvm (1)
- # helix (1)
- # honeysql (1)
- # hyperfiddle (1)
- # jobs-discuss (1)
- # lsp (8)
- # malli (54)
- # meander (1)
- # membrane (1)
- # off-topic (246)
- # polylith (4)
- # practicalli (1)
- # re-frame (14)
- # releases (1)
- # shadow-cljs (21)
- # sql (58)
- # vim (1)
- # vrac (2)
I created an example of building terminal UI (TUI) with Clojure and native bindings to https://notcurses.com/, a modern library with advanced graphics support (different from ncurses, check out the video on their homepage to see what terminals are capable of). It includes a compilation step with GraalVM native-image to produce an excutable binary with instant startup time: https://github.com/dundalek/notcurses-clojure-example
That would be the next step, I think we can build some higher level widgets in Clojure on top of Notcurses, which will handle the lower-level tricky terminal bits.
Probably @U7RJTCH6J has some ideas here as well, as he has a UI framework which abstracts reagent, lanterna (similar thing), etc.
I have a demo of running a todo app terminal ui, https://github.com/phronmophobic/terminal-todo-mvc There are also examples using https://github.com/phronmophobic/membrane-re-frame-example and https://github.com/phronmophobic/membrane-fulcro for state management. Currently, lanterna is used for "graphics", and events, but it wouldn't be too hard to add another backend based on notcurses. That might be useful if notcurses makes it easy to draw certain elements like graphs. Fwiw, cljs has https://github.com/eccentric-j/cljs-tui-template. I haven't used it, but it looks pretty good.
Previously I tried react-blessed and react ink, but I found some limitations and also it would be nice to have something with react-like interface that works in Clojure proper. Membrane looks really cool, from a quick glance it looks exactly what I was looking for, will definitely give it a try.
:thumbsup: . if you run into any issues or have questions, feel free to ask in #membrane
I also used react-blesed
and got disappointed, now I basically forked ink
and write most things myself from scratch in cljs
. However I would still prefer to use clj
instead of cljs
.
@U70QD18NP Perhaps I should try to learn some Zig, it looks useful.
@U0BBFDED7 yeah, react-blessed
being a wrapper over imperative library it has bunch of issues that surface out. ink
is much nicer, more in line with modern react, simpler and better layout support using flexbox. The issue with ink
is that it does not support layering (no modal windows), does not support labels on boxes and glitches with newer unicode versions.
@U04V15CAJ I can recommend it, Zig is a nice tool to have in a toolbelt. For me it covers the remaining use cases that are not covered by clj, cljs, and babashka. It is also a pretty small and simple language, most of it can be learnt in one afternoon.
@U70QD18NP I don't need layering, although I'd probably be happy if there was. I added the labels to myself and would be happy to do a PR if @vadimdemedes is interested, which he probably won't be. Regarding the glitches, commits were merged yesterday that seem to fix it. I think it was even your commits if I remember correctly.
@U70QD18NP Can you show me any fun Zig projects I can hack and play with, besides your notcurses project? I did do some Rust programming, but Zig sounds really cool as well. Perhaps I can make a babashka pod with it.
By the way, I'm really rooting for https://github.com/dundalek/liz, although I haven't had a chance to use it yet.
@U0BBFDED7 I am currently working on a project using ink
so I made a PR to fix the most glaring bug. But there are more subtle ones, which I am not sure if they are fixable withhout a major rewrite.
I have some examples in the section https://github.com/dundalek/liz#examples which include both Liz and Zig source, last year I did some advent of code with it, thanks to low level speed was able to brute force a solution instead of coming up with proper algo π
Also if you have some lower level project i a drawer perhaps using some C library or OS syscals it might be a good fit. Zig has seamless interop with C like Clojure interops with Java.
zig looks very good, like something between rust and c. The problem is that it is very young and there is no ecosystem around it yet
Clojure's interop with C is pretty good with clojure-jna
and/or dtype-next
some c libraries are easier to wrap than java!
@U7RJTCH6J Is there an example on the web of how to use this?
https://github.com/Chouser/clojure-jna/ https://github.com/cnuernber/dtype-next/ https://github.com/cnuernber/avclj https://github.com/phronmophobic/clj-cef
there's probably more
but dtype-next is
This blog is also informative: https://yyhh.org/blog/2021/02/writing-c-code-in-javaclojure-graalvm-specific-programming/
I also have some experiments writing JNI bindings in Liz which should be graal compatible, I can try clean it up and publish.
I started developing a block-based WYSIWYG editor in CLJS (for use within JavaScript and CLJS projects) called Blocko: https://github.com/askonomm/blocko. The idea is to create something similar to what WordPress Gutenberg editor is, albeit a lot simpler. Itβs currently in a 0.1 with a lot of things still pending to do, but it does work and Iβm quite excited about it - and how surprisingly easy it is to build something like that with Clojure.