Skip to content

Comment on Anders Hejlsberg, Steve Lucco, and Luke Hoban: Inside TypeScriptparent

Comments

The difference is you can't use 3rd party libraries in CS or Dart unless you create some kind of wrapper for them.

TS allows you to use any JS library off the bat. If you want stronger type checking the you can define an interface to the library, but it's not necessary.

I think that's a much better place to be rather than create a whole new ecosystem.

>you can't use 3rd party libraries in CS

yes, you can - i.e.:

  $('h1').hide() //javascript
  $('h1').hide() #coffeescript

Fair enough. I probably shouldn't have put CS in my examples. That's what I get for making assumptions!

the 5ht sentence on the official coffee-script page[0] is: "It's just JavaScript", this sentence is not just marketing yadayada. everything that can be done in coffeescript, can be done in javascript, everything that can be done in javascript, can be done in coffeescript.

[0] http://coffeescript.org/

So what you're saying is: as well as don't make assumptions, at least do some basic research? ;)

I get it, thanks.

But the opposite is not always true. There are many libraries written in CoffeeScript that are difficult to use in plain JavaScript due to the use of its class syntax. You can use Underscore.js to get around this, or just write your own inheritance code, but that's obviously a big tradeoff. Of course, using TypeScript libraries in JS will likely have this same issue.

    > There are many libraries written in CoffeeScript that are 
    > difficult to use in plain JavaScript due to the use of 
    > its class syntax.
No, there aren't. I can only name one, and it's a willful-on-their-part-oversight that could be easily fixed by adding a function like this:
    Model.extend = (child) -> child extends Model
...
    > You can use Underscore.js to get around this
No, you can't. Underscore.js has nothing to do with inheritance.
    > Of course, using TypeScript libraries in JS will likely 
    > have this same issue.
Yep -- TypeScript implements a very similar inheritance function, and the potential workaround for subclassing TypeScript constructors from JavaScript should be equally easy.

The need for workarounds makes fragmentation an inevitability. That's not a reason for to-JS languages not to exist; every developer should make the decision on what works for their own needs, but ignoring it is foolish.

there are many libraries written in JavaScript that are difficult to use in plain JavaScript due to the use of a classy syntax, that's why even halfway decent developers care about displaying clean interfaces / API endpoints.

Developers targeting the JavaScript community will be careful to have good API endpoints, but not all to-JS programmers care about that. Batman.js (http://batmanjs.org/) is one example that doesn't.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.