5 ms·
Show HN: ClarifyJs – Overcoming Limits of JavaScript Method Chaining
- abritinthebay 9y agoInteresting intellectually but I’d say the problem it’s trying to solve as illustrated in its readme is just poor application design. Streams, events, etc have all solved this problem without repurposing existing syntax to “fix” a round peg by making it square. Clever though.
- tzahola 9y agoYet another layer to go through when debugging. Wonderful! /s
- reificator 9y agoI don't know why you're being fight clubed, this is a serious concern. The places where this comes in handy are already prime candidates for bug hiding locations. Adding this in might remove some of those, but if the cost is that debugging what remains is significantly more difficult, then is it really worth it?
- alangpierce 9y agoI think the point about debugging is legitimate, and the downvote was because of the sarcastic tone. Someone put a lot of time into this project, so it's nice for feedback to be straightforward and, if possible, constructive.
- omidh28 9y agoThanks for sharing your feedback, Yes I'm agree on some degrees hopefully I'll add some debugging features into the project. However ClarifyJs is not intended to wrap your whole code but just endpoints that you want to be called more fluently or want to put a layer of abstract over calling functions and passing arguments.
- Kamshak 9y agoCould see this work nicely for testing :) Does make it a bit tricky to reason about code if the execution order is not clear
- brudgers 9y agoIf it meets the guidelines, this might make a good 'Show HN'. Show HN guidelines: https://news.ycombinator.com/showhn.html https://news.ycombinator.com/showhn.html
- sctb 9y agoThanks! We've updated the title, which we're happy to revert if the submitter objects.
- jostylr 9y agoThe example with the message could just be msg('hello everyone').to( list).except('John').send().then... where send() returns a promise. That is, the message creates an object that is getting modified until it hits the send method and then it is done. Maybe it is just a too simple example to get a point across, but I would want to see an example where this would not work.
- hn_throwaway_99 9y agoAgreed. The builder pattern is well established and useful, and is a lot simpler to understand (and less bug prone) than what is being proposed here.
- alangpierce 9y agoMy impression is the goal of this library is to make it a little cleaner than the builder pattern because you don't need the `.send()` at the end. Arguably, it's nice to make the syntax a little more concise if the library is there to hide all of the complicated details from you. That said, I get uneasy when reading code like the example send('hello everyone!').to('friends').except('john'); since it doesn't follow my mental model of how programs execute. It's shorter than the builder pattern, but, at least to me, less understandable because there's more magic going on.
- bryanrasmussen 9y agoI liked it because it reminded me of Ruby's more English like syntax, however someone else made the same comment where I work about it being a source of possible confusion so that is probably true. I guess otherwise it would need to be something like send('hello everyone').to('friends', 'John'); but now you don't understand what 'John' does unless you read the code - which,I know, realistically people don't always make their methods match the names so you don't really know that except('John') does what you might assume until you read it as well. But in a theoretical world that was as we would like it to be you could reason from the method name to what the method actually does.
- Can_Not 9y ago
- partycoder 9y agoThe example the author gives is a domain specific language-like expression. I think DSLs are, as their name says, domain specific. I do not think there's a one size fits all solution.
- d--b 9y agoOof... syntactic sugar at the cost of obfuscation and configuration. How is this clearer than normal method calling, when you have to look for a priority number in the config to know which method executes before the other one? Sorry but I think this is a really bad idea...
- lozzo 9y agoI don't think you should apologize. I too think it's a terrible idea. And the irony it's that the author called the library "clarify".