Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support compile to asm.js #1234

Closed
5nyper opened this issue Nov 21, 2014 · 6 comments
Closed

Support compile to asm.js #1234

5nyper opened this issue Nov 21, 2014 · 6 comments
Labels
Duplicate An existing issue was already created

Comments

@5nyper
Copy link

5nyper commented Nov 21, 2014

basically what was once here: http://typescript.codeplex.com/discussions/438243

Can it be done? :)))

@RyanCavanaugh
Copy link
Member

See #375

@electricessence
Copy link

@Ap0ph1s. ASM is hard. And it has a large number or restrictions. I wish it was that easy to just tell typescript to compile to it. But from what I've read, it seems better to write your code in C and then compile down to ASM. :|

Just curious, for what do want to use ASM for, or is it more like you are writing ASM and want to use TypeScript to do it?

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Nov 21, 2014
@yahiko00
Copy link

Having an --asmjs option with the compiler would help to optimize TypeScript code for online games.
I like the original idea.
Also, this would help to create a kind of buzz in the web community and help people to convert to the One True Language: TypeScript for all.

@Xample
Copy link

Xample commented Jul 10, 2016

Typescript to Haxe: https://github.com/jeremyfa/node-ts2hx
Haxe to C++ : http://old.haxe.org/doc/start/cpp
C++ to LLVM : http://llvm.org/
LLVM to ASM : https://github.com/kripken/emscripten
Good luck =)

@jslegers
Copy link

Personally, I don't see much of a benefit of using TypeScript instead of JavaScript. Especially now that the ES6 standard also added class-based object-oriented programming to the language, all you'd really get from adopting TypeScript today would be the addition of static typing... and interfaces. Besides making your code look more like eg. Java code, I really don't see the benefit at all... except when using static typing to optimize the JavaScript code it produces... which is where asm.js comes in.

In environments where high performance is essential (eg. 3D rendering in the browser for browser games or GIS web apps), the current approach is to write the core code (that does the heavy lifting) in C/C++ (compiled to asm.js) and everything else in JavaScript. That means you need a really good understanding of both JavaScript (which I do) and C/C++ (which I don't) to be able to write proper code or maintain existing code for such apps, both inside and outside of the the core code.

How great would it be to be able to use one - TypeScript - codebase for such projects and compile to asm where possible and to regular JavaScript where not possible? Or to put it differently : how great would it be for a JavaScript programmer to be able to program in highly readable superset of JavaScript and have it compiled - where possible - to a highly optimized subset of JavaScript?

It seems like a win-win for everyone, really, especially if you leave it optional whether or not to compile to asm.js for developers who don't work in high performance environments and prefer readability to performance.

IMO, compilation of (a subset of) TypeScript to asm.js would be major improvement over TypeScript as it exists today. For me, it would totally be a game changer and make the difference between supporting and not supporting the adoptation of TypeScript at the company I work for...

@jslegers
Copy link

jslegers commented Jun 22, 2017

Those also interested in converting staticly typed variations of JavaScript to asm.js, WebAssembly or C might want to take a look at ThinScript, TurboScript or AssemblyScript.

ThinScript compiles to JavaScript, WebAssembly, and C. TurboScript compiles only to JavaScript and WebAssembly. AssemblyScript compiles to WebAssembly only.

Each of these languages have been inspired by TypeScript, and the latter is a subset of TypeScript.

I'd like to thank @RReverser for pointing me in the direction of these languages.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

6 participants