9 ms·
I can't wait to use some of the new features in our production apps. Typescript is/was my bridge into javascript development, because IMHO javascript was a bro
by edroche 10y ago
I can't wait to use some of the new features in our production apps. Typescript is/was my bridge into javascript development, because IMHO javascript was a broken language for a long time, and I am not sure if I could have ever done as much as I have without its existence.
Non-nullable types, tagged union types, and easy declaration file acquisition are definitely the biggest wins for me with this release.
- nikolay 10y agoWell, to make JavaScript tolerable, you need to use Babel with tons of plugins and presets. Instead, you can just use TypeScript.
- qwertyuiop924 10y agoJavascript isn't as broken as you might think. Non-nullable types, OTOH, might just be the thing that makes me start using TS, despite my love of dynamic typing.
- niieani 10y agoTry adding 1.3 + 1.1 and tell me JavaScript isn't broken. Hint: The result is isn't 2.4, it's 2.4000000000000004. Unfortunately that's something TypeScript doesn't tackle, but you can use external libraries for floats, where you work on floats as... strings.
- dvlsg 10y agoThat's arguably a problem in almost every language that follows the IEEE 754 standard. It doesn't make much sense to pin that problem solely on Javascript.
- qwertyuiop924 10y agoJS does that... And so does C, and just about every other language out there.
- keithnz 10y agowhen you work with floats, never expect anything to exactly equal a value, ie, it should be banned to use <float> === <constant> . That is universal across languages, for exact representations often languages provide another type. But floating point is popular because CPUs can natively work with them.
- Roboprog 10y agoFor financial work, you want to use a fixed precision or binary coded decimal library, such as java's BigDecimal. You knew that, but I'm just spelling it out for others.
- qwertyuiop924 10y ago...Or you could use Scheme, where we have precise numbers (fractions)
- h1d 10y agoIs that your only complaint about JS?
- Roboprog 10y agoWell, here's one way around that, at least on the server: https://github.com/roboprog/nashorn_play/blob/master/script/np_script/src/js/java_user.js https://github.com/roboprog/nashorn_play/blob/master/script/...
- rtpg 10y agonon-nullable types are excellent. It basically gives you implicit Maybe/Option.
- Roboprog 10y agoYeah, I'm sick of the "static types and classes!!!" crowd, too. I've come to the conclusion that "mandatory and immutable" should be the default, but there are precious few languages in which that is the case, rather than some noise words that have to be plastered all over. (the noise words should be something like "dont_know_when_or_if" and "whacked_whenever_i_feel" for optional and mutable to make you cringe when you use such a local/parameter/return-value. It's always funny (funny-sad) to read a project or a research paper that discovered "static types turned out not to catch as many errors as we thought it would". We've made our turing tar pit, now we have to live in it :-( ... at least until we push the whole C-and-its-spawn edifice over the cliff.
- qwertyuiop924 10y agoWell, if you assume Static Types, or anything else, is the be-all-end-all. If you use a bit of common sense, you should be fine.
- Roboprog 10y agoI hear you. Compile time types can be useful, but again, I'm just weary of hearing from the people who want to make them mandatory, and seem unwilling to consider the tradeoffs. Enter the XML config file... :-( I ranted quite a bit lately about partial function application as well, but it's not appropriate for everything. But when when you're dealing with a crowd that has no idea that there are other ways of doing some things...
- qwertyuiop924 10y agoI mean, yeah. Mandatory typing isn't always The Right Thing, and XML config <english:word:grammar:adjective:insult value="sucks"/>. And it is a tradeoff. And partial application is never necessary. It's elegant and useful, and can save you a bit of typing, yes, but it's never needed. It's nice to be able to type: map (+ 3) a-list but I don't mind: (map (lambda (x) (+ x 3)) a-list) and in most Schemes, there's a macro called cut, which means you can do this: (map (cut + <> 3) a-list) Which is almost as nice as the first one, and works regardless of the position of the arg you want to apply. And it's no so much that the crowd doesn't know that there are other ways of doing things, it's that they reject them out of hand, because they're different.
- lcfcjs 10y agoTypescript sucks, but luckily Javascript is so flexible that we can keep butt badgers like you around :)