Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How has Haskell influenced your JS coding? #39

Closed
hemanth opened this issue Jul 17, 2015 · 6 comments
Closed

How has Haskell influenced your JS coding? #39

hemanth opened this issue Jul 17, 2015 · 6 comments

Comments

@hemanth
Copy link

hemanth commented Jul 17, 2015

No description provided.

@passy
Copy link
Owner

passy commented Jul 17, 2015

Great question!

The single biggest influence Haskell had on my JavaScript is that I don't write much of it anymore. And that's no coincidence. There are so many things in Haskell I enjoy that either don't exist in JavaScript at all or are just painfully hard to replicate. I simply don't have much fun bending JavaScript to my needs anymore.

That said, when I still write JavaScript it does in fact look very different from what it did a couple of years ago.

  • I push side effects to the boundaries of the system.
  • I embrace immutability wherever possible. This means simple things like not using var or let at all, using proper immutable data structures instead of the builtins and use abstractions on top of unavoidably mutable rubbish like the DOM.
  • I use transpilers. I didn't want to use this as a top-level answer, because it feels a bit cheap. PureScript, Elm and GHCJS (of which I've only used the first two in anger) are fantastic pieces of software and if I the constraints a certain project exists in, I would always pick one of those over plain Vanilla JS.
  • My code is a series of transformations, not a bunch of disseminated mutations. Even without monads in JavaScript, you can express effects as a series of computations against an initial state.

@passy passy closed this as completed Jul 17, 2015
@hemanth
Copy link
Author

hemanth commented Jul 17, 2015

👍

My code is a series of transformations, not a bunch of disseminated mutations

^++

@arthurvr
Copy link

Cool answer @passy!

@passy
Copy link
Owner

passy commented Jul 17, 2015

@arthurvr Thanks! :)

@tgvashworth
Copy link

Almost got there without "monads" :-P

@passy
Copy link
Owner

passy commented Jul 17, 2015

Hah, as if I'd miss an opportunity for that. :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants