Code Monkey home page Code Monkey logo

Comments (3)

jarble avatar jarble commented on August 22, 2024

My universal-transpiler tool can already compile a subset of TypeScript into C++.

It would also be possible to convert JavaScript into C++ by combining a TypeScript-to-Python compiler with a Python-to-C compiler.

from ts2c.

KubaO avatar KubaO commented on August 22, 2024

The JS-to-C++ via Python is a crazy route. I specifically want a translation that looks nice :) The universal transpiler seems like a very general tool - is it ever supposed to support what ts2c does already?

from ts2c.

andrei-markeev avatar andrei-markeev commented on August 22, 2024

The JS-to-C++ via Python is a crazy route

Agree! There are quite a few ways to compile JS to C++ through some other language. For example, I tested ts2hx project and some others and it worked more or less fine. However, size and quality of resulting code is very bad, and considering the huge overhead such compilation brings, I wonder if there is a real scenario where it makes sense to use it.

My universal-transpiler tool can already compile a subset of TypeScript into C++.

Universal-transpiler seems to be a good project, but for now it fails to compile even very basic examples - e.g. concatenation of strings, simple array operations, etc.. Considering my experience with TS2C, it's still a long way until something usable. Nevertheless, good start, keep it up! 👍

It'd be nice if C++ support was also available. I was specifically thinking of supporting Arduino libraries from Typescript, and those are all C++.

Yes, I was thinking of supporting several different transpilation targets, and Arduino and friends (including e.g. ESP8266) were among the primary candidates. But understand me correctly: there are so many shades of C++, and I don't want to go there. What I am talking of here is a tailored transpilation target, so it produces functions "setup()" and "loop()", uses Arduino's String class for working with strings, and so on.

For now I don't have any concrete approach of how to implement this. I was thinking of template overrides, so some of the templates can be overriden depending on the transpilation target (Code Templating used in ts2c explained here). There are many tricky things there though. For example, I'm not sure how RAll would play out with escape analysis I am using for memory management. Type recognition also changes a bit when we introduce those C++ classes.

Have to say, my personal current goal is to bring coverage of ES3 up to 96-99%, and only after this I will start improving other areas, so it's still a long way until transpilation targets engine (unless community contributes this part sooner).

from ts2c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.