This is the corresponding code written in React using hooks:<p><pre><code> export const Counter = ({label, counterType, onClick}) => {
const [counter, setCounter] = useState(0);
return (
<button onClick={() => {
counterType == "Increment" && setCounter(counter + 1);
counterType == "Decrement" && setCounter(counter - 1);
onClick && onClick();
}}>
{label}: {counter}
</button>
);
}
</code></pre>
I think the case for PureScript React would be more convincing if the code you ended up with was loosely as concise as the above.
You can also use React Hooks in PureScript with purescript-react-basic-hooks[1].<p>Or for a more native PureScript approach to single-page web apps, check out purescript-halogen[2] and purescript-halogen-hooks[3] (created by the author of this article).<p>[1]: <a href="https://github.com/spicydonuts/purescript-react-basic-hooks" rel="nofollow">https://github.com/spicydonuts/purescript-react-basic-hooks</a><p>[2]: <a href="https://github.com/purescript-halogen/purescript-halogen" rel="nofollow">https://github.com/purescript-halogen/purescript-halogen</a><p>[3]: <a href="https://github.com/thomashoneyman/purescript-halogen-hooks" rel="nofollow">https://github.com/thomashoneyman/purescript-halogen-hooks</a>
Is PureScript nice to use again? Tried it a year or two ago and it relied heavily on Bower and I had a hard time getting anything to work on Windows - lots of Bower errors and such. I tried it a few years ago and got it to work, but in that case getting Halogen to compile the most basic app just stuck the compiler into a freeze for minutes, so I gave up. But I am not shitting on PureScript, it looks like a fantastic way to develop JS apps, and I'd love to use it.
Not to hijack the thread, but I’ve recently learned that Purescript-Native has a Go target [1].<p>Does anyone have experience with this? How practical would it be to use this where one would otherwise use Go?<p>[1] <a href="https://discourse.purescript.org/t/purescript-native-can-now-target-golang/878" rel="nofollow">https://discourse.purescript.org/t/purescript-native-can-now...</a>
How is Purescript these days?<p>I haven't heard many news from its ecosystem since Phil Freeman stepped down from its active development. Purescript by Example must be quite outdated by now? I know that Alex Kelley is still working on his set of tutorials "Make the Leap from Javascript to Purescript"[0]. Anything else interesting going on?<p>I feel like there was a lot of excitement about Purescript in around 2015-2016, but then it sort of died out?<p>0 - <a href="https://github.com/adkelley/javascript-to-purescript" rel="nofollow">https://github.com/adkelley/javascript-to-purescript</a>
> JavaScript apps to PureScript
> Both companies have seen a dramatic drop in bugs in production.<p>I suspect if they migrated from JavaScript to TypeScript instead they would have seen the same dramatic drop in bugs, but also migrated much quicker and would be able to hire engineers easier, and development speed would have increased (because of much better tooling/IDE/interop).<p>I think PureScript is a very bright project, I even want to try it myself, but realistically, comparison to plain JavaScript is not the best benchmark.
How do they connect child components to parts of the application state in PureScript? I'm looking for a mechanism like react-redux's `connect` function. Something that eliminates the need to pass state through the root component down to everything else.
I admire his CLI approach to things, but this just seems dogmatic:<p><pre><code> echo -e "\noutput\n.psc*\n.purs*\.spago" >> .gitignore
</code></pre>
Sure, ok, saying "add these entries to your .gitignore" is too pedestrian?
The article says that PureScript helped them reduce bugs but fails to give any examples of how PureScript prevented bugs.<p>Looking at the examples, the code seems to function the same so it's not obvious what problem is being solved that warrants teaching a whole dev team a new language.<p>In my experience, the vast majority of React app bugs are 1) state management, or 2) asynchronousisty. How does PureScript help to prevent those two classes of bugs?
Do we need another strongly typed language that compiles to JavaScript? If that's so important, why don't people use C/C++ and compile that to WASM for best performance too? We've got TypeScript... is it necessary to have yet another language??
It seems like a horrible idea to introduce this one off framework where ever you go. I feel sorry for the companies that has to carry the burden of the rewrite to something known. This should be used for a hobby at home.