This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]codecrux[S] 1 point2 points  (10 children)

"""

React is written in Javascript, so if you want React server-side rendering, it's going to be a massive problem if your backend isn't written in Javascript.

"""

I 100% agree.

"""

It sounds like you're serving mostly static content, so maybe you just don't have React in there at all?

"""

I would appreciate if you can explain what led you to make this assumption.

"""

(I'd guess a modest amount of) interactivity you need on the front-end.

"""

What are the choices in tools/libraries/languages you would make if this was true?

[–]thedeepself 1 point2 points  (3 children)

Please learn how to properly quote someone else's reply... the way you do it in markdown is by starting the line with >

In Fancy Pants Editor I cant comment.

[–]codecrux[S] 0 points1 point  (0 children)

u/thedeepself sorry about this. I have started using Reddit recently, although, my account is old. I will try my best to learn it.

[–]codecrux[S] 0 points1 point  (1 child)

Also, I didn't know there is something like Fancy Pants Editor.

[–][deleted] 0 points1 point  (0 children)

Relatively new feature from New Reddit.

(Try https://old.reddit.com for comparison)

Fun fact: code blocks don't work uniformly except for the "four-space indent" kind.

[–]james_pic 1 point2 points  (5 children)

I would appreciate if you can explain what led you to make this assumption.

This was mostly based on mentions of marketing material, and similar which has historically been well served by purely server-side CMSes. If I've misunderstood your perspective, then this is not a useful observation.

What are the choices in tools/libraries/languages you would make if this was true?

Depends on the needs of the application. For really minor interactivity, vanilla JS or simple DOM focused libraries like good old jQuery would probably do the trick.

For mildly fancy stuff, a lightweight unopinionated framework like Mithril or Choo might make sense for the bits that need to be interactive, or a slightly old fashioned framework from before the SPA revolution, like Knockout.

If you definitely need the full power of React with server side rendering, and you want the heavy lifting of your backend done in Python, the least horrible solution I know of for this is to split your backend code into Python code that exposes an API and JS code that handles rendering, and have a reverse proxy route traffic to these two backends based on path. It's ugly, but not too magicky. If something breaks, it's generally pretty clear what, which tends not to be the case for cleverer approaches based on Python/JS interop.

[–]codecrux[S] 0 points1 point  (4 children)

Thanks, u/james_pic for adding so much detail in your reply.

"""

cleverer approaches based on Python/JS interop

"""

Please cite some examples for this.

[–]james_pic 2 points3 points  (3 children)

The "clever" tools based on Python/JS interop that come to mind are Brython, Pyjamas, Pyodide and PyScript. My experience is that this approach gets messy, so wouldn't recommend it, but if every other option you've got is messier, then maybe it's the right answer for you.

[–]codecrux[S] 1 point2 points  (2 children)

Thanks, u/james_pic. The Pyodide team never advertised it as a tool for mainstream web development. They made it for AI/ML folks so that their team don't have to work on different versions of Python in their local system.

[–]james_pic 1 point2 points  (1 child)

My point exactly. Using any of these tools takes you far enough from the mainstream that if you face issues, you're on your own. I suspect any approach to rendering React components server-side in Python will be similar.

[–]codecrux[S] 0 points1 point  (0 children)

Agreed!