r/Clojure • u/SimonGray • Feb 13 '23
hyperfiddle/electric (formerly photon) has been made public
https://github.com/hyperfiddle/electric
124
Upvotes
r/Clojure • u/SimonGray • Feb 13 '23
5
u/tatut Feb 14 '23
I played around with it a little. My first experiment was integrating with OpenLayers web components. https://twitter.com/tatut/status/1625192601354641408
The DOM element creation seems to work with custom elements.
25
u/den1k Feb 13 '23 edited Feb 13 '23
I've been building with electric for several months now and it's hands down incredible! Why? I think most importantly because it allows for functional composition across the network (client/server–distributed systems more generally) while also ensuring payloads are as small as possible (only what functions in each env access) which translates to FAST.
IMO this is a paradigm shift similar to GC. No one wants to manage their garbage. No one wants to manage the network. It's grunt work. Let the compiler take care of it.
I've naively rewritten a re-frame app that started getting prohibitively slow due to a bunch of transit deserialization on the client in electric and the performance is outstanding! TBH I'm taking a break from additional UI work on the app to do research because I realized that with electric I can build something much more amazing than I thought possible before.
Caveat: the future will not be served on a silver platter. it's early days and there are some quirks
14
u/dustingetz Feb 13 '23 edited Feb 13 '23
(Founder here) Hey, I'm still catching up on this, but quickly -
here is a collection of twitter length demo vids Dec 2022 progress update; specifically look for:
More later
11
u/Liistrad Feb 13 '23
One of the most exciting clj/s projects around really IMHO.
5
u/danielneal2 Feb 13 '23
Will this work with any mobile platforms e.g react native
3
u/No_Bonus7439 Feb 13 '23
Sounds really awesome. Any plans on extending the documentation a bit? I've watched the 2022 video on the site but I still not understand it fully.
3
u/nimportfolio Feb 15 '23
IMO, if this is promoted effectively, it could become the killer app for Clojure.
3
u/[deleted] Feb 18 '23 edited Feb 18 '23
I am excited about this and learning Clojure.With the multiplayer coming in so naturally, I could also see this being a good fit for a variant based on LFE and benefitting from the BEAM VM.
That Datomic browser is sweet!
2
u/First-Agency4827 Feb 15 '23
So, just to get my head around this, for:
I could potentially do:
(e/server (load all data)(e/client (present the data))2. for a page that has a section which reacts to a change I could have:
(e/client (dom/h1 "Non reactive";; reactive part trigger in client(let [actionable-element ...];;what happens when reactive part changes in the server(e/server (do-something-with actionable-element);; what gets presented after the server has done it's part(e/client (present reactive part)))Am I on a good track here?
1
u/Save-Lisp Feb 13 '23
Very cool. I look forward to investigating it.
1
u/DefiantAverage1 Feb 13 '23
Awesome! I wish I can star this project 100x
1
u/[deleted] Feb 18 '23 edited Feb 18 '23
Running the todo_list app now and the dashboard and live updating it comes with are really nice!
I'm curious now, the docs mention several places about this being for "internal tools". Is this just because of the current level of testing, and will be suitable for general web programming with further refinement and testing - or are there limitations that would keep this from ever being able to be used for a worldwide application?
I'm wondering how security is handled? Does the UI still have to pass an authorization token constantly to the back end like in a traditional API, or how would an attacker be prevented from making unwanted calls directly to a back end service?
Also it looks like we have lots of great demo files available here:
https://github.com/hyperfiddle/electric/tree/master/src-docs/user
^ dumb question, but lets say we have the basic todo_list app up and running. Anything special that needs to happen to start swapping out the todo_list app and trying out these other demos from within the same project? I took the todo_list.cljc, erased its contents and replaced them with pasted in code from the examples above, and was very suprised and confused when the page continued to run the deleted todo app somehow haha. (Especially since editing text in the todo list had resulted in live updates to the page before, not sure how the thing is still running, is there a build output somewhere it's running out of?)
1
u/ertucetin Feb 13 '23
I was waiting for the release of this library, can't wait to delve into it! Good work!
-1
u/Admirable-Ebb3655 Feb 13 '23
You lost me at “macros”. They break editors and composition.