Giter Club home page Giter Club logo

Comments (7)

the-real-blackh avatar the-real-blackh commented on August 10, 2024

There are three things I would say:

  • First, you are used to imperative code but not to FRP code. This gives imperative code an unfair advantage.
  • Second, the syntax of FRP is terrible. I talk about this briefly in the book. It could be improved hugely with some kind of preprocessor. It'd be great to standardize that.
  • FRP is semantically simpler and easier to make modular. The advantages increase as the code size gets bigger.

from sodium.

romansl avatar romansl commented on August 10, 2024

Agree, so I need the rules how to write and read FRP code.

This syntax can not be simplier in java. Mb in kotlin. The one thing I really dont like is loops. kotlin can make this part less verbose, but not totally eliminates the problem:

    val sink = Sodium.streamSink<Int>()
    val cell = Sodium.tx {
        val cell = cellLoop<Int>()
        cell loop sink.filter {
            it.value > cell.sample().value
        }.hold(0)
        cell
    }

from sodium.

the-real-blackh avatar the-real-blackh commented on August 10, 2024

That's why the best solution is a preprocessor. In Haskell loops are just forward/cyclic references, enabled with the keyword 'rec':

(sink, sendSink) <- newEvent
rec
    cell <- hold 0 $ filterJust
                   $ snapshot (\c s -> if c > s then Just s else Nothing) sink cell

A preprocessor would also allow for auto-lifting and type inference, e.g.

Cell<Integer> a = Cell.lift((b_, c_) -> b_ + c_, b, c)

becomes

a <- b + c

from sodium.

romansl avatar romansl commented on August 10, 2024

There is FRP language: http://elm-lang.org/

from sodium.

the-real-blackh avatar the-real-blackh commented on August 10, 2024

ELM has the same syntax as Haskell, so it has type inference, which is great. But it doesn't have auto-lifting and there are probably other things we can improve.

from sodium.

ritschwumm avatar ritschwumm commented on August 10, 2024

scala.react, as described in http://infoscience.epfl.ch/record/176887/files/DeprecatingObservers2012.pdf provides some much more readable syntax, at least for behaviours. the way it's done is not exactly pretty, but with some macros - like the ones https://github.com/pelotom/effectful provides - the same could be achieved in a much better way.

from sodium.

the-real-blackh avatar the-real-blackh commented on August 10, 2024

Of course I would love to improve FRP syntax, but given that Sodium has a lot of work to do yet to get things working on multiple languages, I am going to consider this area not within the immediate scope of Sodium for now and close this bug.

from sodium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.