Coffeehouse Thread

113 posts

TypeScript is JavaScript...

Back to Forum: Coffeehouse
  • User profile image
    Dr Herbie

    @Ray7: Except Typescript is not the same idea as CoffeeScript or Kotlin!  

    CoffeeScript and Kotlin are new languages, while TypeScript is a language extension; that's why it's different from previous attempts.


    Herbie

  • User profile image
    Ray7

    , Dr Herbie wrote

    @Ray7: Except Typescript is not the same idea as CoffeeScript or Kotlin!  

    CoffeeScript and Kotlin are new languages, while TypeScript is a language extension; that's why it's different from previous attempts.


    Herbie

    Ah, I see. So there's the 'familiarity' thing ...

    Verrry interesting ....

     

     

  • User profile image
    Dr Herbie

    @Ray7: Also, you can rename your existing JavaScript files to a TS extension and hey-presto, they're valid as Typescript; easy transition is important when there is a whole world of JavaScript already out there -- nobody is likely to throw away an entire site's worth of JavaScript and rewrite in CoffeeScript, but they might rename some files and run it through the TypeScript compiler as a starting point ...

    Herbie

  • User profile image
    Ray7

    , Dr Herbie wrote

    @Ray7: Also, you can rename your existing JavaScript files to a TS extension and hey-presto, they're valid as Typescript; easy transition is important when there is a whole world of JavaScript already out there -- nobody is likely to throw away an entire site's worth of JavaScript and rewrite in CoffeeScript, but they might rename some files and run it through the TypeScript compiler as a starting point ...

    Herbie

     

    Okay, how does the compiler work? It says that it runs on any OS anywhere, yes? So I don't need VS to compile this?

  • User profile image
    Dr Herbie

    @Ray7: That's where my knowledge ends, unfortunately.  I've been reading about it, but haven't used it yet.

    The http://www.typescriptlang.org/ page states that the compiler can be used in any JavaScript host, but the details are a bit thin.

    Herbie

  • User profile image
    Ray7

    Okay, they missed a trick here.

    function greeter(person : Person) {

    return "Hello, " + person.firstname + " " + person.lastname;
    }

     

    What's wrong with this?

    function greeter(person : Person) {

    return "Hello, ${person.firstname} ${person.lastname)";
    }

     

  • User profile image
    DeathBy​VisualStudio

    , kettch wrote

    @DeathByVisualStudio: They are the most upfront about what they are doing. Companies like Google and Apple seem to be hiding behind the FOSS banner and using it for their own purposes, but don't seem to give back as much as they take.

    Microsoft doesn't use any FOSS in their products, but gives a whole lot to the community. They aren't even pushing their own branded licenses any more and are instead using licenses that are more palatable to the FOSS fanbois.

    Hmmm... I'd agree about Apple; can't think of anything they've contributed. Maybe bug fixes to webkit, mach? Google on the other-hand does plenty...open source Android for starters. If anything they endorse and legitimize FOSS projects much like Microsoft does. I'm also glad Google battled Oracle over java to keep Oracle from locking that beast down and trying to monetize it.

    I just wish people would stop polarizing around specific tech or companies. It's one thing to say something or someone sucks; it's an entirely different thing to take up the life long cause of being an apologist for a given tech or company. That's just a general statement and not directed at you or anyone. Being an apologist, fanboi, or otherwise removes critical thinking from the equation and limits growth.

    If we all believed in unicorns and fairies the world would be a better place.
    Last modified
  • User profile image
    Ray7

    , Dr Herbie wrote

    @Ray7: That's where my knowledge ends, unfortunately.  I've been reading about it, but haven't used it yet.

    The http://www.typescriptlang.org/ page states that the compiler can be used in any JavaScript host, but the details are a bit thin.

    Herbie

    Yes, that's the bit that I'm missing. It seems to have something to with Node.js but I can't quite make the connection.

  • User profile image
    Ray7

    , DeathBy​VisualStudio wrote

    *snip*

    Hmmm... I'd agree about Apple; can't think of anything they've contributed. Maybe bug fixes to webkit, mach? Google on the other-hand does plenty...open source Android for starters.

    Seriously?

    http://www.zdnet.com/blog/btl/report-open-source-android-mobile-platform-not-very-open-at-all/54085

    Most commercial companies support open source up to a point. The 'point' is where it starts to impact their profits.

    I just wish people would stop polarizing around specific tech or companies. It's one thing to say something or someone sucks; it's an entirely different thing to take up the life long cause of being an apologist for a given tech or company. That's just a general statement and not directed at you or anyone. Being an apologist, fanboi, or otherwise removes critical thinking from the equation and limits growth.

    In my experience, those who label others as 'apologists' and/or 'fanbois' are usually both.

  • User profile image
    Sven Groot

    , Ray7 wrote

    Okay, they missed a trick here.

    *snip*

     

    What's wrong with this?

    *snip*

     

    I'm not sure if this is the case, but if they aim to be a compatible superset of JavaScript (and from the renaming stuff Herbie has been mentioning it sounds like they do) that would break any regular JavaScript code that happens to include stuff like that in a string.

  • User profile image
    Ray7

    And I'm not sure there's really a need for a 'new' keyword here.

    var user = new Student("Jane", "M.", "User");

    Do we really need a constructor? Why not just a member function to set the values?

     

  • User profile image
    Ray7

    , Sven Groot wrote

    *snip*

    I'm not sure if this is the case, but if they aim to be a compatible superset of JavaScript (and from the renaming stuff Herbie has been mentioning it sounds like they do) that would break any regular JavaScript code that happens to include stuff like that in a string.

    Mmmm. Yes, that makes a lot of sense,

    I guess that is the problem if you're aiming to extend rather than come up with a new language. Fairynuff.

     

  • User profile image
    Blue Ink

    dup

  • User profile image
    magicalclick

    @Ray7:

    Have you watched the C9 video yet? Because that explained about everything. For example, the new constructor is mapped to the JS pattern that defines constructor. If you don't want to do that, you can use method for that. But you need to think about Type. Meaning, you can pass in a Object that has specific student attributes, but, you cannot say obj.SetSrudentAttrributes().

    You don't need to rewrite the source, but, you need to give a type declaration xx.d.ts file. So TS would know know it is not ANY yet. If you pass in pure JS, the type is ANY, which I dont know how the IDE deal with it. Probably in the same video that I need to rewatch.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified
  • User profile image
    cbae

    , Ray7 wrote

    Okay, they missed a trick here.

    *snip*

    What trick?

    What's wrong with this?

    function greeter(person : Person) {return "Hello, ${person.firstname} ${person.lastname)";} 

    There's nothing syntactically wrong with it. It returns a string literal.

  • User profile image
    cbae

    , Ray7 wrote

    And I'm not sure there's really a need for a 'new' keyword here.

    *snip*

    Do we really need a constructor? Why not just a member function to set the values?

    Can you prevent a member function from being called more than once on the same instance?

  • User profile image
    7alken

    Ray7: tsc can simply compile itself to JS file, so you can use it as embedded scripting precompiler, which exposes everything useful for you too, types "reflections", refactorings, code analysis, syntax coloring, etc ... its pure-JS, thats the trick Smiley, no VS needed, no node.js needed ...........

  • User profile image
    7alken

    Ray7: and as probably biggest TS project now, tsc source code in few .ts files is really very good start to analyze tooling features support using VS2012 plugin, to try to understand how it works. Already this is pure beauty, you have open compiler interface at aour fingertips, you can skip to definitions, find references, simply everything you do to figure out how yet unknown code works; so good to learn how much MS eats own dog food (not foot:-)) here Smiley

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.