Comments (7)
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.
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.
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.
There is FRP language: http://elm-lang.org/
from sodium.
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.
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.
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)
- Add Test For Transaction Regen To C# Version
- Fix Transaction Regen Bug In C# Version
- Add Test For Transaction Regen to Java Version
- Add Test For Transaction Regen To Scala Version
- Improve Transaction.Post
- Fix Send allowed in Operator
- Fix Send allowed in Operator
- Fix Send allowed in Operator
- Fix Send allowed in Operator
- More aggressive cleanup for switchC / switchS HOT 2
- FRP book, javascript code refactoring HOT 1
- Check whether rank bug needs to be fixed in Java version
- Check whether rank bug needs to be fixed in C# version HOT 1
- C# Cell Lift firing twice, but only propogating value from single execution HOT 2
- [1.17/dev] Game crashed after joined the server HOT 1
- Simultaneous timer events HOT 4
- Causality in the Haskell denotational semantics
- Alternative to ranks & priority queue
- Cannot create account on sodium.nz because https is down
- Cell WPF binding HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sodium.