Hacker News new | ask | show | jobs
by kiesel3rde 1773 days ago
Hi! I am fscherf on GitHub and started Lona as side project when covid related home office started in germany (march 2020). I am a full time python web developer and searched for a way to code entire web applications in python without javascript. I came up with a Javascript based rendering mechanism that speaks a specialized protocol over websockets in order to give the python based backend full control over the frontend. My project reached 1.0 a few days ago and i am searching for feedback
7 comments

It's great to have more and more of these projects, especially since frontend dev is such a huge time sink (if you're not doing it 100%).

There are also some similar projects, for example flask-meld [1] for flask (also via websockets but falls back to polling if not available) and django-unicorn [2] (afaik only polling).

[1] https://github.com/mikeabrahamsen/Flask-Meld [2] https://www.django-unicorn.com/

Sorry, not a web dev. What is polling in this context?
This is like Hotwire, https://hotwired.dev/ or Phoenix https://phoenixframework.org/ , but for Python
Phoenix is really cool and ergonomic, albeit a bit strongly opinionated (which makes newcomers clueless IMO).
I've always felt like I had a much, much easier time picking up strongly opinionated tools rather than open ended tools if I'm being honest.
depends on the nature of the opinionated tool I think. If it's opinionated in the sense of boiling down well known concepts to their essence it aids in learning, say Clojure to me is like this.

On the other hand if it's opinionated in an esoteric way it can be quite hard. I remember a HN post about some decentralized chat app that had a language called 'Hoon' I think and it read like someone had reinvented Malbolge.

I'd be interested and will check this out. I have used plotly dash and love to hear a compare and contrast
Unfortunately i don't know plotly and have no experience with dart programming.
Ok, so you should definitely look at Plotly Dash and Streamlit. They are both frameworks that have essentially accomplished the same goal.

Plotly Dash doesn't use websockets though, at least not since I was deep in a project to build a Tableau-like viz creator on top of it a couple of years ago.

I'd like to see your thoughts and how this compares.

There is a fork / enhanced version of Dash that does use websockets: https://github.com/richlegrand/dash_devices
Ok. Plotly: if i read the docs correctly, Plotly converts python scripts to a web application and they can host the app for you. Lona is meant to be self hosted and runs the python directly. Streamlit: Streamlit provides an editor to create your app, and infrastructure to run it. Lona has no editor and runs on your infrastructure. I would say Lona has the smallest software stack of the three, and you have full control over it
>Streamlit provides an editor to create your app

That's actually not the case. Streamlit is an open-source python package to generate frontend components for data-focused apps. You can host it on whatever infrastructure you like.

It's essentially for data engineers who don't even want to think about front end. Streamlit's narrow use-case doesn't seem to compete with Lona, which seems more general and flexible.

See the code examples here: https://github.com/streamlit/streamlit

Dash (by Plotly) doesn't "convert" Python scripts, no, it works in a similar way to Lona: there is a Javascript frontend that communicates with the Python backend and the Python functions (callbacks) are executed directly.
Both Plotly and Streamlit can be self-hosted. I've hosted prod apps in both frameworks. However, I understand why you thought that, because both companies seek to monetize their open source software via offering ultra-simple, semi-automated hosting for apps built in their respective frameworks. Plotly Dash is just a Flask app with a whole lot of other things wired in and a sophisticated front-end operating on a DAG structure provided by the server that is dynamically generated from the Python code. It's got it's issues, but it's interesting nonetheless.

I'm not trying to be some pedantic know-it-all or anything, I'm just correcting you on this because I'm very curious on the deltas between your very interesting looking framework and those. I love these kinds of projects and I'm excited to take a deeper look at yours once I'm done with my current sprint. Very glad to see you made awesome use of your time during the lockdowns.

@JPKab: Ah ok! Thanks for making this clear
Awesome work!

How would you say it compares with similar frameworks like Plotly Dash and Streamlit which attempt to accomplish the same thing?

Lona needs no cloud services because its meant to run on your infrastructure. It runs your code directly, no translation layer like in Plotly and all of its features are open source. No pricing whatsoever
Dash also can be hosted on local infrastructure and in fact does no "translation", it's also using a complex Javascript front-end that abstracts away the HTTP conversation from the Python end :)
Ah ok! I didn't know that
Do you have an online demo?
First thing I wanted as well. I want to see how this thing feels. Can you see the joins? Is it a normal webapp at first glance or some clunky monstrosity?
Unfortunately not, but i will have some at lona-web.org/demos soon. There is a ready to use, barebones project linked in the docs. You have only to clone and run "make server" to fiddle around with it.
Just to let you know a few people are still waiting for the demo. The project looks cool but we would like to see it work without having to download and install stuff. It may sound petty but there are many projects out there and practically speaking installing all interesting ones would take ages, so we need to be picky and choose carefully. I bookmarked your page and am visiting it regularly, but the demo is still not there. Thank you very much for your work and I hope a demo appears soon!
I am sorry that you are still waiting. Currently i am very busy fixing bugs and helping people who started Lona projects in the last days. I only work on Lona at night because this is a side project.

The hosting infrastructure behind lona-web.org is very lightweight and Lona makes heavy use of multithreading. I plan on providing "demos" in Form of an code example next to a gif or video of me using it.

I released Lona 1.2 which has a much smaller package size and now can run from a single python script. So there is no need anymore to install much stuff to try it out til then.

Still waiting for this!
+1, not in docs nor in github :(
OK, I'll give you some feedback. I want a way to write Python-only in apps that look native on iOS, Android, and desktop , and can also be used on the web.

There's React, which has React Native for iOS and Android, and there are even Windows and Mac versions of React Native. However, React Native isn't really complete for desktop yet as far as I can see. For one thing, most of the Mac interface, which comes from Microsoft, was undocumented last time I looked, which was recent.

Flutter (based on the Dart language from Google) seems like it may be very good for iOS, Android, and desktop. But it kind of sucks for the Web. Dart web apps just don't feel like normal web apps, and either the user has to download a 2MB framework or put up with an HTML-only renderer which reportedly has problems with font spacing.

Recently I ran across Framework7, an HTML5 framework that has themes for iOS, Android, and desktop (the latter theme is called Aurora). While there aren't themes specifically for Windows and Mac, I suspect Aurora would be good enough in a context like nw.js or electron, where one of those is used to interact with the native menu and notification systems.

Framework7 supports React, Vue, and Svelte; all excellent Javascript based frameworks. You can also use it with plain JS.

However, I'm a long-time Python programmer, not a JS programmer, and would prefer to use Python.

What I would LOVE to see is a Python-only application framework that worked with Framework7's JS interface, which would provide good iOS and Android themes, as well as an decent one for desktop and web.

It could be served from PyQt or PySide for desktop-native interfacing and Cordova for mobile, and run on the web too.

While nw.js or electron can be used to get the same effect for JS apps, the solution I am pointing toward seems like it would get that effect equally well for Python.

Maybe there are few problems or difficulties using Lona with Framework7 as things stand already. But it would be great if a developer didn't have to even know javascript at all in order to use Framework7 from Python, and that can't be the case since all Framework7's docs and interfaces are aimed at JS folks.

I'm learning JS now and expect to use Framework7 for an upcoming project. Once I've learned JS, I may not care so much about whether or not I can use Python, because the fact is that modern JS is a very nice language, which has taken things like generators from Python and other things from other languages. It now has standard OO abilities, etc.

But I'd still rather not do that; it would be great if there really was a pure python solution for mobile, desktop, and web that allowed most of the same source to run in all those contexts. Something like BeeWare has that ambition, but it seems like they are too far away from fully implementing it to be usable anytime soon. But leveraging something like Framework7 seems to offer the possibility of solving the problem much more quickly.

It does seem that using the approaches embodied in Lona, Dash, JustPy, etc., that it would be possible.

Just a thought.

I never used Framework7 but at first glance there it should be no problem to use it in a Lona project. Lona has a contrib module that supports Bootstrap3 and Chart.js at the moment. Pretty much all frameworks that require common web technologies like HTML, CSS and JS can be integrated.

https://lona-web.org/end-user-documentation/html.html#fronte...

Thanks for the link. Will investigate further.
Not nitpicking, but i had to reread “JavaScript based” several times before it finally clicked as “JavaScript-based” or based on Javascript (style).

Nicely done.

Thanks! Whoops! Thanks for the feedback (i am no native speaker)