7 ms·
It doesn't have an adequate type system. There are too many silent conversions. The syntax is very clunky. All the object systems feel hacky and they can't be r
by lmm 13y ago
It doesn't have an adequate type system. There are too many silent conversions. The syntax is very clunky. All the object systems feel hacky and they can't be relied on to interoperate with each other. Problems like no standardized threading support or decimal type could be resolved in the future. But the language as it exists currently lets you override everything, and that's the sort of thing that you can't remove in later versions because existing code will be using it. So it's always going to be possible to e.g. modify Object.prototype and then expect the method you added to be accessible on anything. And then that library breaks because you defined an object that already has a method with that name.
Yes, a sufficiently smart developer can write good code in Javascript. But there are very few people who I'd trust to write financial code in Javascript, and I think all of them would use a better language rather than expending the effort working around its deficiencies.
- embwbam 13y agoI think Typescript solves a lot of these problems. The type system is amazing, conversions are explicit. Syntax is slightly improved, built-in class system. The others I don't really mind: I like writing event-loop code over threads, and have never once run into Object.prototype problems in the wild.
- dasil003 13y agoI hadn't heard of Typescript, but I think we'll be seeing a lot more efforts along these lines. Despite the pain and inelegance of compiling something to Javascript, I see two inexorable forces that will lead a lot of smart engineers in that direction. First, running the same UI code on the front-end and back-end will enable the best performing apps across platforms. Imagine being able to run a rich client on a powerful PC that just talks to an API and does all the rendering as a single page app, while simultaneously being able to serve up pure HTML/CSS to mobile devices and search engines. Being able to run code on the server or client as needed solves too many problems to ignore. But on the other hand, javascript flexibility and lack of type system will inevitably cause problems as the codebase grows unless you have a good lead developer to define standards and an iron-fisted approach to code reviews. Personally I think coding standards are a stretch with a language as wild as javascript, and a higher level language to enforce certain things is the best way to reconcile these two problems. I can even imagine supplementing with something like (for instance) a Haskell library that lets you generate JS code for interfacing with the back-end in a provably correct fashion, and plugging that into the UI code.
- k3n 13y agoWhere have you been hiding? There's been a virtual explosion in the number of languages that compile down to JS[1] in just the past 1-2 years, and TypeScript is probably the youngest of them all. CoffeeScript[2] is another big one, I believe it's much more Ruby-like. There's even 7 projects involving Haskell. 1. http://altjs.org/ http://altjs.org/ 2. http://coffeescript.org/ http://coffeescript.org/
- dasil003 13y agoWell I'm a Ruby guy so I'm definitely aware of Coffeescript, but mostly I'm just not starting a lot of greenfield projects these days :(
- Kiro 13y agoWhat's so good about TypeScript's type system and what problem does it solve?
- 10098 13y agoProblems like I look at a function and have no clue about what it's arguments are.
- tracker1 13y agoJSDoc comments?
- 727374 13y agoIn general, I believe it will help make larger JS codebases more maintainable. Specifically it enhances the following: - Refactoring e.g. easily globally change a class member's name - Type safety e.g. it will bark if you pass a string where an int is expected - General IDE handyness e.g. 'Go to definition' A really good demo here: http://channel9.msdn.com/Events/Build/2013/3-314 http://channel9.msdn.com/Events/Build/2013/3-314
- zcrar70 13y agothe two best features of Typescript's type system IMHO are: - structural typing for interfaces (which means that classes implicitly implement an interface if the definitions match) - gradual typing (mainly the ability to convert between 'any' and other types implicitly, which makes it much easier to interact with JS libraries/port JS code to Typescript.) More generally speaking, Typescript aims to solve the problem of maintaining large codebases by giving you the additional security of static typing. The idea is that many simple errors can often be caught by a compiler, but would be much more time-consuming to find otherwise.
- tracker1 13y agoJS already has this.. if (obj && obj.quack && typeof obj.quack == 'function') obj.quack(); //looks like a duck
- 13y ago
- yareally 13y agoI've been using TypeScript for experimenting with Node.js and while it's a great solution there's a few difficulties some might face with it: -TypeScript definitions for many libraries, such as express are out of date and require modding to use. -Visual Studio has no built in support for TypeScript with Node for debugging, but it has been mentioned as likely to be added by the TypeScript team eventually. -There are third party plugins for Node in Visual Studio for debugging, but none support TypeScript yet. I've found the best solution thus far is Intellij IDEA or WebStorm, as it has support for both Node and TypeScript.
- novaleaf 13y agofyi, webstorm 7 has good compiler support for typescript, but the ide intellisence/ syntax highlighting is still not great. i use typescript professionally, i use vs2013 for writing code, webstorm for debugging / testing
- deleted 13y ago[deleted]
- spankalee 13y agoThis is why I hope and work towards making Dart succeed. Dart is very nice as server-side or command-line scripting language - the VM and dart:io provide a very node.js-like environment. It provides much more safety, structure and feedback to help guide developers towards better code than JavaScript.
- rpedela 13y agoJava and .NET are the only strongly typed languages used heavily as a web backend. Python, PHP, Ruby, and Node.js are all weakly typed.
- hackula1 13y agoYeah this strikes me as the usual "language X sucks, because dynamic languages suck".
- lsiebert 13y agoYou are confusing dynamic/static vs strong/weak typing.
- deleted 13y ago[deleted]
- veemjeem 13y agoI think python & ruby are considered strongly typed, whereas javascript is weakly typed. strong/weak usually refers to implicit conversion or not.
- ricardobeat 13y agoAlmost every shopping cart in existence right now is written in PHP, Python or Ruby, and they have much of the same "issues". Write tests, use a good bignum library, maintain code standards. Syntax is subjective, I find it pretty nice when following a certain style. Almost nobody modifies Object.prototype, and we now have plenty of APIs to deal with that - defineProperty, seal, freeze, etc.
- adamors 13y agoWas just going to say, a large percentage of online shopping is based on open source e-commerce solutions, most of which are written in PHP. Which shares (and possibly overshadows) Javascript's problems.
- troyk 13y agoWhat's the big deal with getting bignum into js? Everything else I can agree with, but not having 64bit int support in a server side language has to hurt. (just look at most node db adapters and bigints are handled as strings)
- tracker1 13y agoOkay, aside from some scientific functions, what do you really need from an integer that 52bits isn't enough for?
- ricardobeat 13y agoIt's not about storing large numbers, but math precision. For example: 0.3 * 3 => 0.8999999999999999 A few rounding mistakes and you have a huge mess.
- hrjet 13y agoYou seemed to have jumped from talking about integers to floating point! And the example you have given is a problem with all floating point implementations, not just Javascript. You will get that exact same answer in C, Java, etc. The only way to avoid this is to represent rational numbers directly, without simplification. For example: (3/10) * 3 => (9/10)
- peterhunt 13y agoIf you use jshint (it will yell at you when using == with non-null) much (all?) of these problems go away.
- greg5green 13y agoUnfortunately, concatenation can still be a mess if you don't know how it works. And sometimes in spite of knowing how it works.
- ronreiter 13y agoOnce ES6 will kick in, things will get better. Right now it's definitely a shit storm.
- CmonDev 13y agoYeah, things will be so much better in year 2050.