Hacker News new | past | comments | ask | show | jobs | submit login
Better RxJS code with pointfree style (codewithstyle.info)
17 points by miloszpp on Dec 13, 2018 | hide | past | favorite | 11 comments



In my opinion (as a non Haskell user) pointfree style is less readable than the using the normal lambda syntax. In the latter I see at least for each step the amount of input parameters for a function and how they are used. With pointfree style I would need to look up which parameters a function consumes, and what the previous step actually delivers. Type systems at least make this safe, but I still think readability suffers, and the only gain is a bit smaller code.


I agree with this completely. This demos well... "I took this 'mess' and turned it into two clean limes!"

However, actually trying to figure out what the hell the code is doing in pointfree style is an order of magnitude (or greater) more difficult.

This is a maintainability nightmare, no thank you.


that's why you need a typed compiler for this kind of stuff


I don't use JavaScript much, and have yet to do any RxJS.

I found the pipe() example to be more readable. BUT I would not think through the implementation detail, auto-currying functions so that I dont have to etc.

FWIW I love Scheme, but had not thought about these concepts for years. Seeing them in a new context, Currying and partial application, I can see how I could write some stuff that would trip up other JavaScript programmers. Not because I am a better programmer, but because I have habits from a differemt programming style.


> pointfree style is less readable than the using the normal lambda syntax

Came here to say pretty much just that. The original lambdas that got "fixed" I could read very easily. The pointfree style I could figure out but it took a few extra cycles to do so. No thanks. It's neat that you _can_ do this but anyone coming upon it who wasn't the author would have to burn a lot of mental calories figuring out what the hell was going on.


IMHO, it's a matter of not being familiar with such way of writing code. Once you wrote a few lines yourself, it becomes much easier to read such code.

Anyway, I'm advocating to use it with caution, not in a "pointfree all the things" manner.


Hasn't that been like that since rxjs 6, for more than a year? I have been using this for a loooong time. Don't get me wrong, its awesome, and more blog posts about rxjs is good. I was just expecting something new. Also I never heard about pointfree before, only about pipe and pipeable.

Good luck :)


Sure, pointfree style has been present in RxJS since version 6 but on a different level. The article is about using `pipe` for composing functions that you pass as arguments to RxJS opertators. RxJS's `pipe` is about composing the operators themselves.

RxJS's pipe: `stream$.pipe(map(x => something), filter(x => something)`

The article: `stream$.pipe(map(pipe(something, somethingElse))`


Pointless style is nice in a statically typed language like Haskell if you don't take it overboard, but it's a disaster in a dynamically typed language like JS. Without the types, it is almost impossible to read.


It's possible to use Ramda with TypeScript, although it's not perfect. It actually shows some weaknesses of TypeScript's type system as it's not possible to properly type some functions.


Looks similar to Spark implicits. For example, prop('foo') in Spark is $"foo".

Although Spark needs it for building computation DAG, tofigure out what columns are needed before processing it.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: