3 ms·
Throw in in scale, dot, angle etc and the functional style would be hard to reason about for me, I think your imperative example is more explicit and you can sp
by z3t4 5y ago
Throw in in scale, dot, angle etc and the functional style would be hard to reason about for me, I think your imperative example is more explicit and you can sprinkle a bunch of console log's between the lines.
I think pure functional programming works best when there is no state. So move the state out from the program. Only use local buffers if you need for performance...
The order of things is very important so make your coding life easier by making sure the are no concurrent state - like TCP for networking and single threaded business logic.
For example in a chat app, buffer text in a textarea, but when a user hit "send" don't render the message before it has been received by the server, that way everyone connected to the server will see the messages in the same order.
The more possible state a program can have the more you will benefit from testing.
- didibus 5y agoYou find this: position = 10 firstPosition = position.value secondPosition = position.value firstPosition.minus(2) secondPosition.plus(10) position = firstPosition.times(secondPosition) position.value easier to reason about then this: position = 10 times(minus(position, 2) plus(position, 10)) ? Are you sure? I think maybe you're just conflating syntax and semantics. Syntax can be made in different ways either functional or imperative, the semantics are what matters here. Like would this be better for you (still functional, but different syntax): position = 10 firstPosition = position.minus(2) secondPosition = position.plus(10) result = firstPosition.times(secondPosition)