Earlier quoted context omitted.
Is TypeScript really future proof? I mean unless types, exactly implemented as they are in TypeScript, will become part of the spec, we can't really call it future proof. Also how is it compatible with anything, JavaScript is compatible with TypeScript, since TypeScript is superset of JS, but it is not compatible the other way around.
Yes, it is. Compiling TS just removes type annotations; the compilation output (.js) is as readable as your original .ts. It has the same structure, same indentation, same variable names, same whitespace, same comments, same everything. This also makes debugging the code in the browser very easy. TS does not add any semantic features, it only adds type annotations. Which it checks at compile time, and then removes. T…
JavaScript libraries should be written in TypeScript
161–170 of 285 posts
Re: JavaScript libraries should be written in TypeScript
#162Let's hope WebAssembly will help to relegate JavaScript to obsolescence and allow a productive and safe language to gain momentum. I also hope WebAssembly will solve the debugging (no DWARF) story universally. Web browsers are one of the most popular attack vectors and hence would benefit from an APL-like rigid language profile for web applications. JavaScript is too imprecise and bug prone for anyone to use.
Given that there are Cobol users still out there, it's entirely likely that JS will outlive both of us and maybe even our species :)
Plus JS is one profile away from becoming a very sound language. And it's not like it hasn't moved that way already (strict mode).
Re: JavaScript libraries should be written in TypeScript
#163Earlier quoted context omitted.
Have you used TypeScript? Try it out for a month or two on a real project. It's the best thing that has happened to web development in recent years - it improves Javascript in a completely compatible and future proof way. The most amazing thing is that Microsoft created it. It's the polar opposite of Old Microsoft - standards are being followed (not subverted), it's simple pragmatic and has no lock-in.
Is TypeScript really future proof? I mean unless types, exactly implemented as they are in TypeScript, will become part of the spec, we can't really call it future proof. Also how is it compatible with anything, JavaScript is compatible with TypeScript, since TypeScript is superset of JS, but it is not compatible the other way around.
Your code will keep working, but it may diverge a bit from standard JS; however everything will keep working, and I'm sure the expectation would be to move over the es6's syntax unless there were semantic reasons not to.
The Typescript authors are involved in the ECMAScript process, so I'm pretty sure that there won't be any surprising huge rifts at least.
Re: JavaScript libraries should be written in TypeScript
#164I've been down this path before. I used coffee script on a few projects. Every time I have to go down that path I end up having to write more complex code just to do basic things. This blows up the project timeline when I could've done the same things in basic javascript in a few minutes. I read lets discard the benefits of writing javascript as javascript in favor of something else because of a few people refuse to…
I shudder to think of the countless man-hours that have been wasted working around and debugging issues caused by stupid design decisions in the Javascript language.
Re: JavaScript libraries should be written in TypeScript
#165You obviously have no idea what you're talking about. Almost all statically typed languages get compiled to something much less type-strict. This is one of the reasons for writing compilers in the first place! Case in point: Haskell gets compiled to assembler. You can't get a much bigger difference between typing disciplines than that.
Re: JavaScript libraries should be written in TypeScript
#166This is akin to saying "Every C++ library should be written in Objective C." EDIT: Hey people down voting me; it literally is the same. C++ is a standard, JS is a standard. TypeScript is (like Objective-C) a compatible alternative.
Re: JavaScript libraries should be written in TypeScript
#167Earlier quoted context omitted.
It's not about reading, it's about the tooling you need to set it up. JS initial strengh was ease of dev for beginers. Throw in a transpiler, a dependancy manager, a package manager, a bundler with FS watching, and source maps and what you got is wall for the very same type of dev that were producing all those fantastic jQuery plugins 10 years ago. And actually even for me. I do know how to install and use all those.…
> It's not about reading, it's about the tooling you need to set it up. npm install typescript -g This is the only addition on top of vanilla js, which is what you should be comparing with instead of the massive crap of build-tool-of-the-month. All said and done, if you're using those build tools in typescript, you'd be using them for javascript as well.
It's as though crazy javascript tooling is so deep into the bones of javascript developers that they can't even tell when they're using a tool. I expect you were genuinely sincere in your suggestion.
Re: JavaScript libraries should be written in TypeScript
#168I completely agree with the sentiment that typed libraries are more stable and self-documenting. You can autogenerate documentation from typescript and it's guaranteed to be up to date, unlike JSDoc comments. I personally have converted a few of my libraries [1] [2] over to Flow. It helps me personally, catches a lot of bugs, and does a great job of self-documenting while not getting in the way. Flow has a lot of bug…
I know this was definitely the case when I started using TS a few years ago, but they recently added support for compiling .js files in your typescript projects, so you only need to deal with the compiler one file at a time.
Admittedly I haven't used it, but I think it should have made the migration easier. Probably still not as easy as Flow, but easier...
Re: JavaScript libraries should be written in TypeScript
#169> but transpiling it down into a language that isn't as type strict just seems silly to me You obviously have no idea what you're talking about. Almost all statically typed languages get compiled to something much less type-strict. This is one of the reasons for writing compilers in the first place! Case in point: Haskell gets compiled to assembler. You can't get a much bigger difference between typing disciplines th…
Re: JavaScript libraries should be written in TypeScript
#170Earlier quoted context omitted.
Have you used TypeScript? Try it out for a month or two on a real project. It's the best thing that has happened to web development in recent years - it improves Javascript in a completely compatible and future proof way. The most amazing thing is that Microsoft created it. It's the polar opposite of Old Microsoft - standards are being followed (not subverted), it's simple pragmatic and has no lock-in.
If Elm didn't also exist, I'd almost agree with you.
This unfortunately makes languages like Elm and Clojurescript unlikely to be chosen in a lot of situations (e.g. as I understand it, the JS interop story with Elm isn't amazing, so you can't just use JS libraries with it).
Typescript is close enough to plain Javascript to not scare people off (I'd be willing to bet any JS developer could pick it up in a few hours) and can almost be considered in the same light as vanilla JS in such a decision, yet brings with it the advantages of a fairly decent type system.
As I've said elsewhere, it's definitely not perfect, but for developers in a position where other, more "esoteric" compile-to-JS languages aren't likely to be accepted, Typescript probably represents the best choice of bringing a decent amount of sanity and predictability to codebases.
(This isn't meant to be having a go at the parent BTW, it's just something I've been thinking about a bit and the comment jogged my memory!)