Hacker News new | past | comments | ask | show | jobs | submit login
Reflex – Web apps in pure Python (github.com/reflex-dev)
254 points by simonpure on Aug 2, 2023 | hide | past | favorite | 144 comments



Django + Unicorn has a similar goal except:

- you still use html and a templating language for the views

- it mostly looks like old ssr code but you can transparently call methods on the server (like meteorjs)

- you get one of the best ORMs in existence with great relationship handling and generated admins

https://www.django-unicorn.com/examples/search

Not 1.0 yet but I'm using it in production and omgosh is it easy to crank out UIs.


I love this:

> Note that all examples are deliberately left unstyled to present the simplest implementation.

I've looked at too many documentation examples that show a bunch of things at once, with unrelated tech, making it hard to understand the current point.


This is awesome.

Also check out https://laravel-livewire.com (PHP) and https://hotwired.dev (backend agnostic; there are implementations for Rails and Flask) and https://htmx.org


This is kind cool. Closer than the Reflex thing to what I think would be cool. I wonder if anybody has made any kind of Python/Django system that lets you just write the front-end stuff in React but handles all the state synchronization stuff between React and your Python server.


This is that, just using django templating language instead of JSX.


Why wouldn't it say nowhere (README, the website) what does it actually do and how? It's all marketing bullshit such as: Get up and running in seconds! Build web apps in minutes. Deploy with a single command. Build anything, faster. Create your whole app in a single language. Don't worry about writing APIs to connect your frontend and backend.

This kind of shit might catch a manager's eye, not a developer's one.


It has a complete code example in the README. Looks pretty nice for the use case it's designed for.


That answers the "what does it actually do" part, but not the "how".

Github and hackernews are both places where developers exchange ideas, so it helps if you explain which tech you build on and what challenges you faced.


> which tech you build

This is literally a link to the source code repo!


That and even if it were just a readme, that's not marketing bs, it's how you use it.


Dude its pretty clear what it does just from scrolling down the readme. “Its just like php” if that helps you, but you can also write frontend state management and dynamic behavior right there in the “template”, all in Python.


According to the Project Structure docs, it seems to compile down to JS in the end, which is information that's missing from the README.


that doesn't help. I looked at the modules it makes use of and the first one is "openai" (Edit: whoops, it's in their example, not in their requirements. disregard).

php didn't use openai IIRC

i kind of cannot imagine what this would use openai for unless it's using it to write a web application for you. which is pretty ...not like php.


To be fair I don't think Reflex does use openAI, that's just the code example they used.

I think its a decent example project, its easily readable and you can understand what they're doing, but I think as a general rule its better to do something without external unrelated libs. An AI image generator just seems a bit too specific of an example for something that fundamentally has nothing to do with AI.


ah you're right, I thought I saw it in their requirements, it's just in their example code. got it.


Worth noting is that this framework has telemetry [1] enabled by default [2] which gathers and sends off various information about your system unless you explicitly disable it.

[1] https://github.com/reflex-dev/reflex/blob/919f239168d789056d...

[2] https://github.com/reflex-dev/reflex/blob/919f239168d789056d...


I haven't kept up with web framework type things in awhile—how commonplace is this? from here it looks kind of insane.


I was shocked when I discovered that Dart, a programming language, included telemetry.

Of course, since it’s coming from Google, I suppose it shouldn’t have been quite so surprising.


Probably semi-common in Node world.


We are keeping all our telemetry anonymous and don't store/track ips

https://nextjs.org/telemetry https://docs.streamlit.io/library/advanced-features/configur...


good Lord, when did things get to be like this? if I shipped a free web framework with opt-out telemetry, I'd feel like a massive douche


Opt-out telemetry in companies based on open source projects has become a critical component of YC applications, VC pitches, and acquisition pitches. If it was opt-in of course nobody would turn it on. It's shady but I also somewhat understand the founders who are doing product-led growth by giving out the product on GitHub/PyPI, yet still need some usage metrics to quantify the stickiness to their backers. Pip installs and git clones/forks are only a loose indicator of real usage.


How about tracking licenses or subscriptions sold and show that to investors?


How do you do that with an OSS project that's on GitHub?


by not trying to turn it into a VC fueled rent-seeking cash cow?


Fair enough.


By switching to a proprietary license for your proprietary product.

If we call things by their names, it's not surprising at all and actually makes solving the situation much easier.


if it's a paid product and it's part of an agreement for support then sure, but for a free product? when you know some high percentage of users are never going to even know that the option to opt out exists?

man... the modern YC/VC webdev game is rough.


Sorry, but this is bullshit.


"Why iy iy iy, don't you uuuuuuse it?"

Seriously tho, when one sees the first word of a Python project with the description "Performant", or a project put Out There by someone with a handle not linked to a bio (even a fake bio)...

Anyway, software regs ARE coming because The Way of software developers has not been obscured from public view for some time now and the (relatively) recent ransomware of municipalities and hospitals resulting in deaths along with serious tensions among global powers have made it a priority. How ironic is it that Microsoft is best positioned to play the gatekeeper role? https://noguiltlife.com/wp-content/uploads/2023/01/scie-fi-m...


Oh alright, no more quoting Duran Duran lyrics ("The Reflex", 1984) on Hacker News, even if Nick Rhodes did mainstream audio samplers hah

Hacker News is for serious discussions only --wow, already up to 119 comments already at https://news.ycombinator.com/item?id=36967829

"My-iy-iy time don't loooose it."


It's amazing how even open source software is becoming tainted by surveillance. We can no longer assume that code written by our peers will be free of such nonsense.


There’s nothing user identifiable here though. No ips, locations, etc. I guess they could get it from the reception though hmm


> No ips

It sends the information to a remote server, so your IP is obviously shared as well. It also sends a "project_hash" as "distinct_id" which sounds like a unique tracking ID to me.


Probably counting how many apps are in the wild to show investors.


I missed that project hash bit. Well. At least the tracking is disable-able.


My only wish for this is that it didn't just cobble a bunch of existing web stuff together behind the scenes and put an python interface + code generator on it.

Installing all the python deps (250mb), and node_modules (500mb) , plus a package size of 3mb of js isn't a great look.


Yeah I see your point it's definitely something we are going to try and reduce in the future. We wanted to give the users the ability to wrap external react components and leverage that ecosystem so there were trade off we had to make.

The 3MB of JS is in dev mode or prod mode? (Is this similar to the other comment where they were running in dev mode but when they ran in prod it was much smaller ~ 340KB?)


Wild timeline: for ref. a HTTP webserver in C would run you under 1mb, all-in, if TLS'sn't required.



Redbean is 2.3mb including TLS, Lua, and SQLite, and the same binary runs on Windows, Mac, Linux, and Free/Net/OpenBSD.


I have built three quick sites with Reflex and it is fantastic for a systems programmer like myself who has no interest in learning Javascript. The recent addition of supporting Tailwind CSS works well and makes it very easy for me to make not terrible looking frontends. Their discord is very helpful for questions and issues that I have raised on their GitHub are responded to quickly.

I wish them the best with their hosting platform.


Could you share your sites?


Interesting how the reception seem to be different this time around compared to when they were called Pynecone. At least that is my recollection. I follow this project with interest, I don't understand all that "you shouldn't do x with y". Each to their own requirements, its great to have a choice.


Yeah HN loved Pynecone! [x] I wonder if the new name is landing poorly or tides are turning against this 'everything in Python' space. Or the "Launch HN" tag encourages positive feedback.

[x] https://news.ycombinator.com/item?id=35136827


I was just going to ask how this compares to pynecone, lol. The rename should really be highlighted more prominently.


A lot of diagnostic in this discussion so far misses how approachably straightforward the DSL (patterned Python) is.

I'd go so far as to say the patterns are so clean they're almost self-evident, which is remarkable lift for beginners or busy people just mocking up something functional.


Btw what's "patterned Python"?


As as a meta comment the dynamics and interplay of language adoption and language evolution is quite fascinating. For whatever reason, a lot of people have learned Python in recent times. Whether the hype is data science, machine learning or AI, the number of users creates its own reality.

So now you have some serious talent looking at the pain points people express about the platform, because ofcourse you want to keep the "devlopers, devlopers, devlopers" happy.

Personally I dont see the attraction of an all python approach to the web. The event driven nature of client side programming has no particular affinity with Python. While JS is clearly a monopoly, it doesnt strike as we are paying a huge price for the lack of alternatives. Maybe its just my lack of imagination. If people complain about JS frameworks is because of the choices and designs and burdens these imply, not the fact they are JS.

The area where an all-Python approach would be a radical new take that opens entirely new horizons is actually not the web, but mobile apps.


Mobile is blocked by Google and Apple, that's all. You can't fix that.

What you can fix, though, is an ecosystem built on a pile of left-pad-quality hacks that change every other week. Hence the various attempts to jailbreak the accidental monopoly JS was born with.

Unfortunately, this project doesn't even try to do that, and still relies on that pile of hacks. As such, it's never going to be particularly popular - why suffer most of the JS-ecosystem pain plus the additional pain brought by a transpiler?


$5 million raised for hosting? I honestly fail to understand the ways of VC despite a decade of trying to understand them.


Hey, you know the most popular programming language in the world? They don't have a way to write web applications. If you fund us, we'll build a tool for that, tap into a huge TAM and make bank.

Sounds like a pitch that would make VCs start falling over eachother


Close, except throw "AI" in there a few dozen times. Even the example they use in the README is for calling the DALL-E API.


This one trick will 10x your preseed valuation


>Close, except throw "AI" in there a few dozen times.

Yes, and earlier it was crypto, and earlier, $foo_buzzword, and earlier, $bar_hypeword, and earlier, SAAS, and earlier, client-server, and ...


This is literally Vercel for Python, and Vercel as a company has performed extremely well so far.

It's not really much of a stretch to understand why they got funding.


I'm not sure I understand what you mean because we can already use Flask or Django in serverless functions on Vercel.


Python on Vercel is in beta and it's not their core competency: https://vercel.com/docs/concepts/functions/serverless-functi....

Vercel is synonymous with Next.js and JavaScript, not Python. Flask and Django also don't have full integration with React like Next.js (Because it's all JS) and Reflex (Feature of the framework) do.

The value prop is very clear to me. Next.js is extremely popular for good reason, I see a lot of value in bringing that to the Python ecosystem as well, especially with all the Python ML SDKs.


Thank you


VC looking for an aquihire payout. I haven’t looked, but perhaps some of the team is ex-FAANG and the VC is counting on a purchase price > $5mil.


Do aquihires go for that kind of money? I expect these to be much much lower.


Depends on who, I've seen an aquihire for around 7 engs with pedigree go for around 30 million. Now that company had taken on around 20m in VC and had developed a product... but that product was immediately thrown away by the acquiring company and the devs assigned to existing work.


I'm following Pynecone (now Reflex) from the start and liked the idea of building out an AST with Python and compiling that to a working web app (we're actually doing the same with https://wasp-lang.dev/, only it's a DSL and an explicit compiler with JS interop).


Thanks! We are fans of wasp as well!!


My major complain here is that, as far as being a web framework there is precious little information here about the framework. How does this framework scale with multiple requests? What concurrency strategy is it using (threads, processes, actors, etc?). Is this opinionated (it doesn't seem so but it also doesn't say it isn't either). How does this work with popular libraries x,y,z. The full docs have a little bit more information, but not a ton. But mostly there are some cute toy examples and "built in python" and thats about it.

Lets compare this with for example play https://www.playframework.com/ I know from this that it built on Akka, its stateless, aims for predictable resource consumption, has non-blocking io, etc. There is a ton of really important information on what does this web framework actually do that is really important when you are making a choice of a framework.

I have no idea how good this framework is, but besides a few toy examples, I can't see anything that makes me thing "wow this is great I need to use this". Using python to generate front end attributes isn't new, most any web framework can do this also.


This isn't a web framework, it's something to get you up and running ASAP. It's probably not worth it for anything other than utility/one-off, but there's nothing wrong with that.

No offense, but the play framework docs are objectively worse, it feels very "enterprisey" and too many clicks (the "Hello World Tutorial" spans 3 pages)


I don't really understand how "stateless" fits in here. As in it's HTTP-based? As in it doesn't need a database behind it? What does stateless mean in this case?

In general, I think the readme's not bad. I think the example is eye-catching, and I can imagine this would be really nice to make a prototype with. Whether or not it would scale well etc, yes, it would be good to have some of that detail. But I can see a really good use for it already.


stateless in web frameworks means that requests don't alter state of the code for a user. If you look at say JSP with traditional Spring, it tracks the state of each user on the website, which page they are on, which flags they have, etc.


It's just Python code that gets translated into a NextJS app.


We do use nextjs but I think what's the most handy part of Reflex is the simplification of state management and event handling so there is more complexity to the framework.


Where did you find this information?


If you actually do the demo project thing, you'll find a .web directory, with all the next-js code. :)


F12 o Ctrl+U on most browsers


Most browsers are mobile so that won't work :)

I was hoping there is some technical explanation how the compilation step works (especially what do they do to event handlers) but their documentation is very light on details.


Firefox on android allows you to inspect source.

You need to prefix the url, ie.

    view-source:https://news.ycombinator.com/


Their github repo README has the following: > Performant ...

Do we have benchmarks for this? More generally speaking, I don't see more technical differentiation besides it being a Python DSL. Nor do they provide numbers to back it up.


I agree we need some benchmarks working on getting this asap.


But there's emojis on the readme!


They even have that long bunch of meaningless badges to say that tests are passing or whatever!


We have 5 badges in total, and 1 of them to points to our integrations test passing. And the integration test do serve an important purpose in making sure we are compatible on multiple different os and don't make a change that would break WSL for example. More info here https://github.com/reflex-dev/reflex/tree/main/.github/workf...

The others are the current latest version, python version we support, how many people are on our discord (A metric to see community activity), and a badge that points to our docs. I think all of these are important but open to suggestions on ones you think would serve a better purpose.


They serve no purpose, other than make life hard for disabled people.

I expect tests to always be passing before merging anything.

pypi metadata has the list of supported python versions, in text format

A link to your documentation? Ok but why can't it be a regular link?

I use forums or IRC, so the online users on whatever aren't super meaningful to me personally.


I see thanks for bringing this to my attention, I didn't know that badges caused this problem for disabled people.

We will look into this, I think the info is still important to show but there probably is a better more inclusive way of doing it.


Can you be more specific in your criticism wrt disabled people? It's a lot easier for someone to receive feedback when it's specific, especially when discussing something like a README. It can be helpful to others reading who are on the fence about badges and their ilk, too.

What, specifically, is the issue with the badges concerning accessibility? Most badges I see can be reduced to a div containing two spans and some text, which should be usable with a screen reader. Is there missing alt text, aria attributes, etc?

Re: tests, it comes down to developer culture. It may be acceptable for experimental or alpha/beta versions to not pass tests, live on a separate branch, etc. Distros should be live-testing any packages they ship, too; upstream releases aren't guaranteed to be tested, depending on the upstream you're working with. It's nice to know that the latest commit is actually working without having to double check CI locally. However, tests also aren't created equally. The project author(s) could be learning how to refine their tests, and not actually trust the CI's results (yet).

Can we argue that's sloppy, or that they should've never done that before merging and pushing? Sure. Not sure where it gets us. Actionable feedback and cautionary advice is useful, though.


They can, but are they?

If a test is not working/outdated, remove or fix the test. It's not what the badge is showing anyway.


Looks nice!

I've used Anvil [0] quite often in the past years for what seems to be a similar purpose (not affiliated, just a happy customer). Does someone know how Reflex compares?

[0] https://anvil.works/


sometimes the war is lost even before the battle begins. During grad school, I wrote a whole bunch of web apps entirely in R using Shiny. It was clunky as hell, but yeah, it worked. I went looking for what's up with Shiny these days and found this - https://shiny.posit.co/

So yeah, full on pivot into python. pip install shiny. Alright!

"No web development skills required. Develop web apps entirely in R I mean Python"...yeah that's not happening.


Could be worded better but I would interpret it as "No web development skills required to start developing web apps entirely in R/Python". You're still expected to learn web development but within the context of an R/Python environment


I've looked into this recently and it's really good. They make use of Python's type annotations to do some clever conversions to frontend code.


"Clever" and "frontend" with Python honestly concerns me.

I realize TypeScript may be doing the same thing but that somehow tastes OK because it was purpose built for the task. (Although I abhor cleverness in general).


> They make use of Python’s type annotations to do some clever conversions to frontend code

Do you mean internally in the library? None of the sample code has any type annotations.


How is this different from Streamlit or Pynecone?


This is the renamed Pynecone project. Much more general purpose than streamlit.


> Reflex launched in December 2022 with the name Pynecone.


I feel like everything is eventually going to go full circle back to Google Web Toolkit[0]. The original "write it all in X language" toolkit with compile to JavaScript functionality.

[0]: https://www.gwtproject.org/overview.html


I was a massive GWT fan - particularly because it played well with the Java ecosystem.

1. huge programmer pool 2. tried and tested legacy code could be easily used / adapted 3. code quality / checkstyle plugins just worked 4. great testing tools

My main gripe was the compile time (often 2-3 mins)...whereas Adobe Flex would crank code out in 3 seconds.

Now, the new language models should help us push through the noise.


Any idea what/which websites are written using GWT?


It was Google Adwords that was the big one to my mind...with Ray Ryan (rjrjr) leading a lot of those efforts.


Why are we trying to fit a square peg into a round hole


Isn’t the answer obvious? They want to!

There is no denying the importance and usefulness of web apps. You and me may be fine writing JS/TS, but many don’t want to. Why shouldn’t there be an option that works better for those folks?


JS got popular on the server because it was the default option on the client. Makes sense that Python should get popular on the client because it's the default option on the server.


Since when is Python the “default choice” for server side dev?


Never to the degree JS on the client is, though the early and strong support on PaaS/serverless systems gaveit something of an edge for certain server-side stuff, and it was popular for a long time (though not dominant) outside of that.

Really, I think the main driver for isomorphic Python web libraries like this isn't general web apps (though they'll get used for that, too), but the putting frontends on data science, ML, etc., stuff where Python is the dominant tooling language.


I agree, the datascience / ML crowd is _probably_ more interested in having something simple and easy/fast to implement to put in front of their data than in having a proper web framework with all the bells and whistles a software engineer would prefer.


> putting frontends on data science

Jupyter and Shiny seem adequate for that.


Well, it's very popular.

Which is why I'm a bit surprised that RPC/APIs still have as much overhead as they do, especially around types.


Since never.

People use either Java, PHP or NodeJs.


I don't know where you work, but at my company, I'm struggling to get people to use anything but Python.


Me too, but we don't do web stuff so Python makes at least some sense. Even if it is generally pretty awful.


Good luck with that! I think using python for anything beyond a simple script or PoC, should be taken as a red flag in development and immediately revise that decision of using it.


Could you elaborate as to why? I’ve used to program in PHP and have moved (since I forgot most of PHP) to Python and I don’t get why people are displeased by it.


> I don’t get why people are displeased by it.

By and large "people" are not "displeased" by Python. But every language has a set of diehards, people who dedicated decades to this or that and resent adopting anything else. They will complain no matter what. Python is displacing a lot of other platforms in its continued rise, so the noise keeps going up.

In addition, there are groups of nerds that love to formalize absolutely everything in their code, development speed be damned; and people who will optimize every line they write to an inch of their life (again, dev speed be damned). Both those camps are often uneasy in an ecosystem built on duck-typing, "practicality beats purity", and an overall approach favouring development speed over machine speed.


Tell that to Netflix, youtube, instagram, quora, Uber and others.


Those are all realy slow websites and it's clear why.


Everything but the Crab language is worthless fluff.


you might want to let Instagram or Github know those are the three choices


"People" stuck in 2005, probably.


Some people are die hard python fans, trying to use a scripting language for everything. I encountered some where they try to use Python in embedded (robotics to be exact) and oh boy how terrible it was, a “collision avoidance” was taking few seconds to respond..


Some of us just need a simple webform for our project. Keeping all code in Python makes sense. Nearly all generative AI projects with a web frontend on Github use libraries like Streamlit etc.

And, while Phyton would not be my preferred choice for robotics, I did write kernels for small 'autonomous' mobile robotics a long time ago in C. The systems ran at 20 hz. I'm pretty confident modern embedded computers running Phyton can achieve 20 hz sense/think/act cycles.


> Some people are die hard python fans, trying to use a scripting language for everything.

Kind of a weird thing to say when the domain is web frontend where the default (which this wraps) is JS, another “scripting language”, to the extent that label actually means anything (which it mostly doesn’t.)


Maybe it is easier to learn a framework within the ecosystem of a language you already know than to learn both a framework and a new language.

Tons of software exists for this reason. For example, somewhat relevant here, web apps in R via R Shiny: https://www.rstudio.com/products/shiny/

(There is also Shiny for Python IIRC.)


> Maybe it is easier to learn a framework within the ecosystem of a language you already know than to learn both a framework and a new language.

I'm in this camp.

For services that I'm building that are not heavily frontend reliant, I don't want to learn a whole new language and framework


Agreed.

There's a time and place for quick and dirty interfaces to kick off server-side code, which is what this feels like.

There is definitely that barrier to entry to have to write server side routes and html/js to interact with them.


Why not? Someone has found a way to fit a square peg into a round hole, your round pegs still work the same as they did before, people just have more options now.


because some people have a square peg and not a round one.


I played with this yesterday. The counter demo app (two buttons and a number) transfers ~2.5MB compressed, which uncompresses to ~12MB.

Completely ridiculous!


Hey are you running in dev mode or prod mode I just tried the counter in prod mode and it was 340.1 KB compressed?


I see, I was indeed running it in dev mode without realizing it. It's indeed much better that production mode is a much more reasonable size.


Yes, dev mode is just for developing/creating and has hot reloading enabled.


Not to be confused with Reflex, allowing web apps in pure Haskell: https://reflex-frp.org/


Another project in this space is ReactPy (formerly IDOM). [0] [01]

But it is more like Python bindings for React and supports multiple web frameworks (Django, FastAPI, etc.).

[0]: https://reactpy.dev/docs/index.html [1]: https://github.com/reactive-python/reactpy


I haven't worked with Python in many years now. Do people not use Django or Flask anymore? What's the recommended web stack, and where does this one fit in?


I second the FastAPI. But always I choose Django and if you throw HTMX in the mix not even Rails come close to what it can build.


They're still good. The new one is FastAPI which is performant and supports concurrency, schema validation, and a few other modern nicities


And finally with pydantic 2 it's no longer using the slowest library for schema validation that existed!

Still not the fastest, but not the slowest at least.


I still use Django, and I love it, but it can be a bit of a heavyweight framework. I wouldn't call it cumbersome, but I couldn't imagine using it to build a single page web app without a backend for example, it's just a bit overkill.

I'd see this as more like Svelte (or at least the projects I'd usually build with Svelte I might consider this for instead).


Reminds me of some of the crazy stuff microsoft tried with ASP and ASP.NET back in the day that made it really hard to build applications in a disciplined way.


While I see the appeal of putting everything on the server (from a DX perspective), but it just seems so wasteful.


I love this style of web development. I'll go to lengths to avoid doing anything {Java,Type}Script when building web applications. My last favorite was Seaside w/ Smalltalk – not quite the same thing as this project though (Seaside works mostly server side).


Just asking based on your handle / name, have you tried parenscript for your js ?


I don’t think this is a good idea, playing with the components there’s like a whole second for the checkbox to change status.. I don’t think python is even a good tool for ML/AI either. Maybe to prototype a UI but to be used in the wild, I don’t think so.


Do you support server pushes, e.g. periodic updates initiated by the server to update client UIs?


How does it compare to Plotly Dash?


That seems like a very unergonomic API.


using PyQT nowadays a bit... and honestly that is a joy compared to these examples.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: