Skip to content

Proposal. How about have two modes "typed strict" and "compatibility"? #19

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

Closed
MaxGraey opened this issue Jan 29, 2018 · 11 comments
Closed

Comments

@MaxGraey
Copy link
Member

Assembly Script is superset of typescript that's mean it should have some compatibility with typescript if I right understand one of the main goal. In this case we might easily portable typescript code to AS with minimal changes. In other hand with WebAssembly we have got int64 arithmetics, atomic operations and etc.

For example in typescript parseInt return double with NaN when something wrong, but in AS we can return i64 which make sense, but we loose compatibility.

My propose is make two macro definitions as compile option modes or string hint. One of them is safe compatibility with JS/TS runtime and other produce code with all wasm capabilities.

Thought?

@dcodeIO
Copy link
Member

dcodeIO commented Jan 29, 2018

Hmm, well, I understand the intention, but at the end of the day there'll always be some things that are not 100% compatible. Take array indexes for examples - we really shouldn't make these f64s.

But this makes me think: Maybe we shouldn't provide parseInt at all and just name the AS implementation i32/i64.parse, with a portable implementation that uses parseInt under the hood but coerces to i32s, without NaNs. Wdyt?

@MaxGraey
Copy link
Member Author

MaxGraey commented Jan 29, 2018

Yes, as an option.
Also AS could provide two std libs for example just like C and C++ do it. I mean libc/cstdlib and libc++ but for TS/JS (compatibility) and for AS (with strong types)

@dcodeIO
Copy link
Member

dcodeIO commented Jan 29, 2018

I see. What can be done today is adding a mechanism to specify the stdib path when invoking asc, making it possible to switch to another one, so everyone can experiment with alternatives. Would that be something you are interested in?

@MaxGraey
Copy link
Member Author

Definitely "yes"

@dcodeIO
Copy link
Member

dcodeIO commented Jan 29, 2018

While thinking of it I figured that this could also be used to extend on stdlib implementations. Replacing the default one could be --noLib --stdLib path/to/other while extending the default one could be --stdLib path/to/other.

@MaxGraey
Copy link
Member Author

And may be better move stdlib out in separate package and repositaties in AssemblyScript organization? With libas and libts names for example

@dcodeIO
Copy link
Member

dcodeIO commented Jan 29, 2018

I'd rather avoid that at this point in time. I already felt that all the packages the prototype had were unnecessarily complex to manage, especially since all these components are usually tightly coupled to a specific version of the compiler.

@dcodeIO
Copy link
Member

dcodeIO commented Jan 30, 2018

Usage:

  • --noLib --lib path/to/mylib to replace stdlib.
  • --lib path/to/mylib to extend stdlib

Similar to stdlib this includes all top-level .ts files in compilation, and exposes their exports as globals.

@dcodeIO
Copy link
Member

dcodeIO commented Feb 22, 2018

Closing this for now. Feel free to reopen if something else is required :)

@otabekgb
Copy link

Assemblyscript is my dream project, thanks for such a good project. I am trying to promote it wherever I can. But full typescript compatibility is the only way to get the whole ts/js ecosystem behind. Otherwise assemblyscript will remain a small island, nobody will try to change their code from standard typescript. We should make it seemless, as easy as possible. Why can't we use V8 API to evaluate/run dynamic language features? Also double should be default number type and other numbers should be exposed advanced users. Please take it serious, I want this project to be successfull

@MaxGraey
Copy link
Member Author

full dynamic features is not possible now and will not expect in future so using any typescript code "as is" without minor modifications is not possible. We want stay independent from any host (and v8 as well) also it require some wasm features which not exists in MVP like anyref. But fully automatic or semi-automatic migration tools already building. See esmbly

willemneal pushed a commit to willemneal/assemblyscript that referenced this issue May 31, 2019
…-update

Update AssemblyScript to latest upstream
radu-matei pushed a commit to radu-matei/assemblyscript that referenced this issue Oct 13, 2020
radu-matei pushed a commit to radu-matei/assemblyscript that referenced this issue Oct 13, 2020
* 'master' of github.com:jedisct1/wasa:
  Fixed the memory leak for Time.sleep (AssemblyScript#33)
  Improve Descriptor (AssemblyScript#25)
  Bump assemblyscript from 0.9.2 to 0.9.4 (AssemblyScript#27)
  Deps
  Optimizations + update dependencies (AssemblyScript#21)
  Bump @as-pect/cli from 2.7.0 to 2.8.1 (AssemblyScript#23)
  Bump assemblyscript from 0.9.1 to 0.9.2 (AssemblyScript#24)
  Fix Date.now to return milliseconds instead of microseconds (AssemblyScript#19)
  Bump assemblyscript from 0.9.0 to 0.9.1 (AssemblyScript#17)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants