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

Comparison to other languages #334

Open
milesfrain opened this issue Jul 16, 2020 · 2 comments
Open

Comparison to other languages #334

milesfrain opened this issue Jul 16, 2020 · 2 comments

Comments

@milesfrain
Copy link
Contributor

milesfrain commented Jul 16, 2020

The differences from Haskell doc in this repo is really helpful.

Likewise, this Elm to PS cheatsheet is great too, and we have permission (alpacaaa/elm-to-purescript-cheatsheet#9) to absorb its content.

Proposing we include docs for comparisons to all of these languages:

  • Haskell
  • Elm
  • TypeScript
  • ReasonML
  • ClojureScript

There's an outdated section in the book's intro that touches on comparisons to other JS options. I was originally considering adding some notes on other languages there, but I think it would be best to have all this info in a common location.

@milesfrain
Copy link
Contributor Author

milesfrain commented Jul 16, 2020

Here are some notes on ReasonML differences from reading their overview.

  • Philosophy
    • Less strict about immutability and effect tracking.
    • Less FFI ceremony.
    • More efficient JS (speed and size).
  • Syntax
    • Closer to JS than Haskell.
    • rec required for recursive functions.
    • () is shorthand for unit.
  • Records
    • Record types must be declared before creating values of that record type.
    • Records may have mutable fields.
    • Nominal typing - Cannot use a record with a superset of fields in place of a record with a subset of fields.
    • Record update uses spread syntax.
      • Adding fields is complicated by nominal typing. Easier in PS with disjointUnion.
  • Functions
    • Named function arguments built into language.
      • Different than passing a record argument with named fields.
    • Automatically uncurried whenever possible (even if this produces multiple functions).
    • Built-in optional arguments.
      • Technically uses an option type, which is like Maybe.
      • Possible to do with purescript-option, but certainly a lot more ergonomic when built into the language.
  • FFI
    • One-liner. PS requires two lines in separate files.
  • Type Classes
    • Uses Module system (rather than type classes).
    • Could mimic haskell-like type class hierarchy, but this is not common among libraries.
  • Frameworks
    • Strong encouragement for React and Tailwind (<-- RML doc links).
    • PS is less opinionated.

@milesfrain
Copy link
Contributor Author

Should we include any content with comparisons to OOP? This might help folks coming from an OOP background where PureScript is their first FP language. Thinking it would be better to link to existing Haskell resources, rather than re-write our own. Here are some I found so far:

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

1 participant