Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@andyrue 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. :)

@andyrue

This comment has been minimized.

Copy link

@andyrue andyrue commented Feb 23, 2016

So far not impressed by how much setup work is required to get started with TS+Angular2. I imagine there's scaffolding things out there to set things up quicker, but still...2 json files, 2 ts files, and an html file (more if you count automatic compile and refresh, but that's equal to elm). Relatively an awful lot of work just to print "My First Angular2 App!". Also ran into an error when starting the 2nd part of the tutorials, burned 30 minutes before finding the solution of installing typings globally. I know in the grand scheme of things this setup is <0.01% of the time taken in a normal project, just my observations so far. :)

Nevermind, turns out I'm still not past that error.

@andyrue

This comment has been minimized.

Copy link

@andyrue andyrue commented Feb 24, 2016

Already ran into my first bug that made it into run time and wasted a few minutes of my life. Super simple newbie mistake but Elm would have caught it during compilation. Apparently your declared types need to be on top? I had it in the middle...this actually isn't even a problem with Elm, convention says to put it at the top but it will work anywhere.

@pietro909

This comment has been minimized.

Copy link

@pietro909 pietro909 commented Jun 9, 2016

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

This comment has been minimized.

Copy link

@JabX 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

This comment has been minimized.

Copy link

@jtomaszewski 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

This comment has been minimized.

Copy link

@kokizzu 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