Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×
Java Microsoft Network Operating Systems Programming Software The Internet Windows

TypeScript 2.0 Released (arstechnica.com) 89

An anonymous reader quotes a report from Ars Technica: Since its introduction, TypeScript has included new features to improve performance, enhance JavaScript compatibility, and extend the range of error checking that the TypeScript compiler performs. TypeScript 2.0 introduces a big step forward here by giving developers greater control over null values. null, used to denote (in some broad, hand-waving sense) that a variable holds no value at all, has been called the billion dollar mistake. Time and time again, programs trip up by not properly checking to see if a variable is null, and for good or ill, every mainstream programming language continues to support the null concept. TypeScript 2.0 brings a range of new features, but the biggest is control over these null values. With TypeScript 2.0, programmers can opt into a new behavior that by default prevents values from being null. With this option enabled, variables by default will be required to have a value and can't be set to null accidentally. This in turn allows the compiler to find other errors such as variables that are never initialized.
This discussion has been archived. No new comments can be posted.

TypeScript 2.0 Released

Comments Filter:
  • null !== undefined...

  • I wasn't sure what TypeScript is so I looked it up.

    https://en.wikipedia.org/wiki/TypeScript [wikipedia.org]

    It's a language similar to JavaScript that allows you to optionally use types on variables. It "transcompiles" to JavaScript, so you can write programs in TypeScript and then they will run in standard web browsers that only support JavaScript.

    It's possible to use standard JavaScript libraries with TypeScript, and further is it possible to write a header file that documents type information for those libraries. So it

    • by tgv ( 254536 )

      It's precisely that: Javascript with type checking and a few features that make programming a bit easier. If you have to write in Javascript, you really owe it to yourself to check it out.

    • by SeaFox ( 739806 )

      I wasn't sure what TypeScript is so I looked it up.

      https://en.wikipedia.org/wiki/TypeScript [wikipedia.org]

      It's a language similar to JavaScript that allows you to optionally use types on variables. It "transcompiles" to JavaScript, so you can write programs in TypeScript and then they will run in standard web browsers that only support JavaScript.

      You left out the part about it being developed and maintained by Microsoft. So it's a language that generally imitates something someone else has done and is already a standard, but adds it's own special new features that are not in the original, thus making a case you should use this new Microsoft technology and not the other.

      Where have I heard that before... [wikipedia.org]

      • The first sentence of that wikipedia page you linked says that it's free and open source (with those words hyperlinked to their definitions). It's developed on github like any other open source project.

        The license is Apache 2.0:
        https://github.com/Microsoft/T... [github.com]

      • by Karlt1 ( 231423 )

        Google is also a big proponent of TypeScript. Angular 2 is being written in TypeScript.

      • So?

        MS like any organization makes great and crappy software.

        So they make mediocre operating systems. They do make excellent business software and good development software like C# and visual studio. Gnu makes great operating systems and ok development software.

        Use the right tool for the job. It is open source and compiles to JavaScript so no locking. Why can't ms make something good considering no one makes everything good? Are you that biased?

  • Rust probably isn't quite a "mainstream programming language" although it's getting close. But anyway it doesn't support null or null pointers for normal safe programming. Objects are created by declaring them so they either are or they aren't.

    If you have a function that may return an object or may not for some reason, then it must return an Option or a Result (or something of a similar nature) and the caller has to explicitly test and handle what got returned.

    Null is only supported for unsafe operation

    • Unfortunately, habituating your developers to call .unwrap() on everything (with the tacit "oh I know it's bad, but..." approval) doesn't really put you in a better place.

      What you have with Result<T,E> and especially Option<T> is the concept of null delivered in a purposefully non-ergonomic form, with the theory being that the extra explicitness will drive developers to write better code by default. However, that unwrap() escape hatch is mighty convenient; time will tell if the theory was ri

      • by DrXym ( 126579 )
        You don't have to unwrap on everything though. If I have a function that is guaranteed to return something (e.g. a constructor) it just returns that thing. Compare to C++ where anything that returns a pointer is potentially capable of returning NULL even if it shouldn't.

        Option and Result are only necessary for actions which might legitimately might return something or might not. e.g. a network request, or retrieving a record from a database. Even there it's not necessary to unwrap since you could say "if

  • DuoCode [duoco.de]?

    I've been much happier keeping everything in C#.
    • Because websites still use JavaScript for client side stuff. Typescript makes this job easier and oddly use JavaScript like a byte code in Java where it compiles to JavaScript so it works in every browser or mobile app

      • by PJ6 ( 1151747 )

        Because websites still use JavaScript for client side stuff. Typescript makes this job easier and oddly use JavaScript like a byte code in Java where it compiles to JavaScript so it works in every browser or mobile app

        Um, yeah, DuoCode transcompiles C# to JavaScript.

        Maybe you should have clicked the link before posting.

  • every mainstream programming language continues to support the null concept.

    Because you cannot do without. The computer cannot guess a value of a variable, so the default is always "Not Set" aka Null. Other languages use a Type.NULL or whatever, but it's just the same as Null. So, every language have a null concept.

"The great question... which I have not been able to answer... is, `What does woman want?'" -- Sigmund Freud

Working...