Hacker News new | ask | show | jobs
by gmaster1440 635 days ago
I've enjoyed working with Reflex (https://reflex.dev) as a pure Python wrapper over React.
2 comments

react license applies then to products made with this stack? i.e. no product that meta thinks of as a competitor is allowed?
React is fully OSS as far as I know: https://github.com/facebook/react/blob/main/LICENSE

I think the term you mentioned was there at the start but has since been removed and React is licensed pure MIT since 2017.

React used to be licensed as BSD + recovable patents: https://engineering.fb.com/2017/08/18/open-source/explaining...
+1 for Reflex. Truly amazing.
How is it writing React without multi-line lambdas?

They are everywhere in JavaScript and I couldn't imagine my day-to-day without them!

I think my answer: I have no idea what multi-line lambdas are, probably explains why I find Reflex (or Rio/Streamlit, etc) amazing, haha

For a person with zero front-end knowledge, it's a game changer.

In JavaScript you can do this:

    const f = (x, y) => {
      const z = x + y;
      const w = z * 2;
      return z - w + x;
    };
In Python, you cannot do this:

    f = (
      lambda x, y:
        z = x + y;
        w = z * 2;
        return z - w + x;
    )
Instead, you need to pull it out into a def:

    def f(x, y):
      z = x + y;
      w = z * 2;
      return z - w + x;
Sometimes, this is no big deal. But other times, it's damn annoying; the language forces you to lay out your code in a less intuitive way for no obvious benefit.
Actually you can. If you really want a multi-line lambda with your example...

```f = lambda x, y: [ z := x + y, w := z 2, z - w + x, ][-1]```

* That version does look strange, as it uses a list in order to get that last calculation. But I often use lambdas to check results in parametrized tests, and they naturally spread to multiple lines without the list hack since they're chains of comparisons.

Using a list combined with the walrus operator is a clever hack, but it's nice to not be limited to expressions. In JS you can define the equivalent of a multi-line lambda function with any number of statements (which is helpful when you're passing a function as a callback e.g. in a React hook).
That's pretty janky - I don't think it would pass review in many places!
Ah I see! Thanks for elaborating! :)
Rio components are classes, so you could create a named class method and reference it. Obviously not the same thing as multi-line lambdas but it'd be the pythonic approach imho.
Either name them, or squeeze multiple expressions into a tuple. More can be done, now with walrus.
> They are everywhere in any proper programming language

FTFY.