[HN Gopher] Reflex - Web apps in pure Python
       ___________________________________________________________________
        
       Reflex - Web apps in pure Python
        
       Author : simonpure
       Score  : 134 points
       Date   : 2023-08-02 15:40 UTC (7 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | cataflam wrote:
       | 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/
        
       | ecshafer wrote:
       | 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.
        
         | drcongo wrote:
         | But there's emojis on the readme!
        
           | bombolo wrote:
           | They even have that long bunch of meaningless badges to say
           | that tests are passing or whatever!
        
             | apetuskey wrote:
             | 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.
        
               | bombolo wrote:
               | 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.
        
               | apetuskey wrote:
               | 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.
        
         | tzhenghao wrote:
         | 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.
        
           | apetuskey wrote:
           | I agree we need some benchmarks working on getting this asap.
        
         | impulser_ wrote:
         | It's just Python code that gets translated into a NextJS app.
        
           | marwis wrote:
           | Where did you find this information?
        
             | n3storm wrote:
             | F12 o Ctrl+U on most browsers
        
               | marwis wrote:
               | 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.
        
               | wwtdtgotiatl wrote:
               | Firefox on android allows you to inspect source.
               | 
               | You need to prefix the url, ie.                   view-
               | source:https://news.ycombinator.com/
        
             | ilc wrote:
             | If you actually do the demo project thing, you'll find a
             | .web directory, with all the next-js code. :)
        
           | apetuskey wrote:
           | 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.
        
         | robertlagrant wrote:
         | 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.
        
         | turtlebits wrote:
         | 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)
        
       | nologic01 wrote:
       | 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.
        
         | toyg wrote:
         | 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?
        
       | paxys wrote:
       | 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?
        
         | nighthawk454 wrote:
         | They're still good. The new one is FastAPI which is performant
         | and supports concurrency, schema validation, and a few other
         | modern nicities
        
           | LtWorf wrote:
           | 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.
        
         | rajasimon wrote:
         | 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.
        
       | skratlo wrote:
       | 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.
        
       | turtlebits wrote:
       | 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.
        
         | apetuskey wrote:
         | 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?)
        
       | jdoss wrote:
       | 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.
        
       | haolez wrote:
       | 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.
        
         | dragonwriter wrote:
         | > 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.
        
         | leetrout wrote:
         | "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).
        
       | ptx wrote:
       | 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...
        
         | gigatexal wrote:
         | There's nothing user identifiable here though. No ips,
         | locations, etc. I guess they could get it from the reception
         | though hmm
        
           | bakugo wrote:
           | > 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.
        
         | adamrezich wrote:
         | I haven't kept up with web framework type things in awhile--how
         | commonplace is this? from here it looks kind of insane.
        
           | apetuskey wrote:
           | 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...
        
       | LispSporks22 wrote:
       | 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).
        
       | ilrwbwrkhv wrote:
       | $5 million raised for hosting? I honestly fail to understand the
       | ways of VC despite a decade of trying to understand them.
        
         | jboy55 wrote:
         | 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.
        
         | lijok wrote:
         | 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
        
           | paxys wrote:
           | 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.
        
             | conductr wrote:
             | This one trick will 10x your preseed valuation
        
       | abdullahkhalids wrote:
       | I played with this yesterday. The counter demo app (two buttons
       | and a number) transfers ~2.5MB compressed, which uncompresses to
       | ~12MB.
       | 
       | Completely ridiculous!
        
         | apetuskey wrote:
         | 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?
        
           | abdullahkhalids wrote:
           | 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.
        
             | apetuskey wrote:
             | Yes, dev mode is just for developing/creating and has hot
             | reloading enabled.
        
       | pruthvishetty wrote:
       | How is this different from Streamlit or Pynecone?
        
         | davea37 wrote:
         | > Reflex launched in December 2022 with the name Pynecone.
        
         | pkos98 wrote:
         | This is the renamed Pynecone project. Much more general purpose
         | than streamlit.
        
       | brap wrote:
       | While I see the appeal of putting everything on the server (from
       | a DX perspective), but it just seems so wasteful.
        
       | dxbydt wrote:
       | 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.
        
         | jsiva wrote:
         | 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
        
       | PaulHoule wrote:
       | 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.
        
       | Terretta wrote:
       | 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.
        
       | bjornasm wrote:
       | 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.
        
         | shrimpx wrote:
         | 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
        
       | pard68 wrote:
       | That seems like a very unergonomic API.
        
         | fock wrote:
         | using PyQT nowadays a bit... and honestly that is a joy
         | compared to these examples.
        
       | jeron wrote:
       | Why are we trying to fit a square peg into a round hole
        
         | dinkleberg wrote:
         | 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?
        
         | tamimio wrote:
         | 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..
        
         | [deleted]
        
         | toyg wrote:
         | 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.
        
           | cjaybo wrote:
           | Since when is Python the "default choice" for server side
           | dev?
        
             | solarkraft wrote:
             | 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.
        
             | wheelerof4te wrote:
             | Since never.
             | 
             | People use either Java, PHP or NodeJs.
        
               | zzzeek wrote:
               | you might want to let Instagram or Github know those are
               | the three choices
        
               | cosmojg wrote:
               | I don't know where you work, but at my company, I'm
               | struggling to get people to use anything _but_ Python.
        
               | IshKebab wrote:
               | Me too, but we don't do web stuff so Python makes at
               | least some sense. Even if it is generally pretty awful.
        
               | tamimio wrote:
               | 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.
        
               | wheelerof4te wrote:
               | Everything but the Crab language is worthless fluff.
        
               | toyg wrote:
               | "People" stuck in 2005, probably.
        
             | dragonwriter wrote:
             | 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.
        
               | alfons_foobar wrote:
               | 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.
        
         | dr_kiszonka wrote:
         | 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.)
        
           | lijok wrote:
           | > 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
        
           | turtlebits wrote:
           | 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.
        
         | gostsamo wrote:
         | because some people have a square peg and not a round one.
        
         | [deleted]
        
       | matijash wrote:
       | 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).
        
         | apetuskey wrote:
         | Thanks! We are fans of wasp as well!!
        
       | tamimio wrote:
       | 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.
        
       | [deleted]
        
       ___________________________________________________________________
       (page generated 2023-08-02 23:00 UTC)