Skip to content

Instantly share code, notes, and snippets.

@NickClark
Last active September 27, 2021 22:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickClark/a13139a49e083af88405 to your computer and use it in GitHub Desktop.
Save NickClark/a13139a49e083af88405 to your computer and use it in GitHub Desktop.
Elm vs TypeScript Thoughts

Elm and TypeScript

  • Elm Task - An Elm specific implementation of Observables (more limited?)
  • TS and Elm - Once it compiles it usually runs (Provided you're following the warnings provided in either the compiler output (better) or editor (best) )
  • Editor and tooling support?
  • TS and Elm - Typed Langs
  • Most suitable for complete apps, not just a JS compiler
  • Enforces Reactive programming - Angular 2 (Observables) provides the same thing, just not forced.
  • Know TS, know JS. Able to contribute back to the community easier.
  • Object assignment kinda weird: { point | x = 42 } Reason? (overall weird sytnax)
  • Elm is new, very few libs. Interface to JS has to be done through Ports? TypeScript handles this better, you can get safety out of community type definitions using DefinitelyTyped (tsd, or typings)
  • Elm's own benchmark only perfomrs at par, and that apparently is against libs that are already out of date. benchmark
  • Elm - An interesting library, perhaps behind the times as the web is adopting Web Components, ES6, Observables, and ShadowDom
  • TS - best combination of safety and ease of integration with JavaScript libraries, guaranteed to stay with the evolution of JS as it's just a superset and excellent tooling.
@andyrue
Copy link

andyrue commented Feb 23, 2016

Disclaimer:
My understanding is very limited and I'm certainly not knowledgable enough to be a good resource for debating Elm vs TS/Angular but lets see what we can come up with. :-)

Elm Task - An Elm specific implementation of Observables (more limited?)

I think to match Observables you need to look at Mailboxes and Signals as well. Mailboxes, Signals & Addresses

TS and Elm - Once it compiles it usually runs (Provided you're following the warnings provided in either the compiler output (better) or editor (best) )

That's cool. I didn't realize TS had an equally intelligent compiler. I honestly only briefly looked at TypeScript (looked too much like JS for me!)

Editor and tooling support?

Sublime Text has an Elm package for syntax, autocomplete, etc. Support for Gulp and webpack. That's all I've needed so far.

Most suitable for complete apps, not just a JS compiler

True, not just JS Compiler. Really it's an HTML + CSS + JS Compiler. Allows you to pretty much write one language/pattern for everything.

Know TS, know JS. Able to contribute back to the community easier.

Depends on which community you're contributing to. :-)

Object assignment kinda weird: { point | x = 42 } Reason? (overall weird syntax)

I think this comes down to it being a Functional Programming language vs an OOP. I'm not really sure of the strengths of Elm extensible records vs the traditional objects we're used to. At the very least it's just different. Further reading. Elm Records

Elm is new, very few libs. Interface to JS has to be done through Ports? TypeScript handles this better, you can get safety out of community type definitions using DefinitelyTyped (tsd, or typings)

Yes, young and has few libs but can still use existing JS libraries through ports. Most notable backer is Prezi. Certainly would be better to keep everything in Elm land with enforced semantic versioning of packages but you have the option to extend and still reap the stability and maintainability benefits of Elm.

Elm's own benchmark only performs at par, and that apparently is against libs that are already out of date

I'm not sure I would consider 2nd only to Mercury "at par". In my mind, React is par and everything above that is fast. It would be nice to see newer versions in the benchmark though. I think the point is, if you like what Elm gives you, you'll still be faster than most.

I'm still trying to find my place in this frontend world, will need to give TS + Angular2 another go. In the meantime I am enjoying learning about functional programming. :)

@pietro909
Copy link

TS - best combination of safety

Actually we should define what is safe as all types are nullable in TypeScript. You could miss a return statement and it will compile succesfully, leaving you the surprise at runtime... if you are lucky. Otherwise will produce a bug in a different place of your application, leaving the surprise to your QA team.

@JabX
Copy link

JabX commented Jun 17, 2016

There a compiler flag to catch all those missing returns, and non-nullable types are coming in the next version (2.0)

@jtomaszewski
Copy link

jtomaszewski commented Oct 17, 2016

Nice summary @NickClark. I've got very similar realisations lately too.

I think one of the coolest features of Elm is the immutability - which can't be achieved by TS for now. Hopefully es7 spread operator get merged soon.

Anybody knows how is the ts support for ImmutabilityJS working in the reality? Is the typing working, do we need to attach a lot of immutability to the interface definitions to support it?

@kokizzu
Copy link

kokizzu commented Feb 20, 2017

Elm is cool :3 just like Haskell on JS platform..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment