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

What is the difference between this and using TypeScript? #3

Open
vincentrolfs opened this issue Jul 6, 2023 · 3 comments
Open

What is the difference between this and using TypeScript? #3

vincentrolfs opened this issue Jul 6, 2023 · 3 comments

Comments

@vincentrolfs
Copy link

I don't really understand which TypeScript features are not supported. Since functions and string interpolation are included, how is this different from TypeScript itself? Maybe it would be helpful to specify what is not included in TSON.

In other words, is a JS runtime needed to parse TSON?

@loreto
Copy link
Contributor

loreto commented Jul 6, 2023

A lightweight runtime is required but it is bundled as part of the TySON libraries, so that users of TySON don't need any external dependencies (no dependencies on Node or V8). I'll work on documenting the differences w/ full TypeScript, but at a high-level, TySON only supports ES5-ES6 features.

As an example, async/await is not part of TySON.

@scarf005
Copy link

It'd also be nice to have a comparison with deno, as it share some similarities with tyson's. for example, deno runs scripts sandboxed by default, and require fine-grained permission control:

 ~/r/e/deno-security  deno run --no-prompt io.ts     2023 08 11 () 오후 05 59 50
hello
error: Uncaught PermissionDenied: Requires read access to "io.ts", run again with the --allow-read flag
const text = await Deno.readTextFile('io.ts')
                        ^
    at Object.readTextFile (ext:deno_fs/30_fs.js:749:29)
    at file:///home/scarf/repo/etc/deno-security/io.ts:2:25
 !  ~/r/e/deno-security  deno run --no-prompt net.ts
error: Uncaught PermissionDenied: Requires net access to "www.example.com", run again with the --allow-net flag
await fetch("https://www.example.com")
      ^
    at opFetch (ext:deno_fetch/26_fetch.js:73:14)
    at mainFetch (ext:deno_fetch/26_fetch.js:182:59)
    at ext:deno_fetch/26_fetch.js:461:9
    at new Promise (<anonymous>)
    at fetch (ext:deno_fetch/26_fetch.js:424:18)
    at file:///home/scarf/repo/etc/deno-security/net.ts:1:7
 !  ~/r/e/deno-security  deno run --no-prompt run.ts 
error: Uncaught PermissionDenied: Requires run access to "deno", run again with the --allow-run flag
await new Deno.Command("deno", { args: ["--version"] }).output()
                                                        ^
    at spawnChildInner (ext:runtime/40_process.js:162:17)
    at spawn (ext:runtime/40_process.js:348:10)
    at Command.output (ext:runtime/40_process.js:421:12)
    at file:///home/scarf/repo/etc/deno-security/run.ts:1:57

tho deno is quite heavy (109MiB as of in v1.36.1) due to V8 and tools being built-in, so tyson definitely have advantages here. interested to see how tyson grows!

@loreto
Copy link
Contributor

loreto commented Aug 11, 2023

It'd also be nice to have a comparison with deno, as it share some similarities with tyson's. for example, deno runs scripts sandboxed by default, and require fine-grained permission control:

 ~/r/e/deno-security  deno run --no-prompt io.ts     2023 08 11 () 오후 05 59 50
hello
error: Uncaught PermissionDenied: Requires read access to "io.ts", run again with the --allow-read flag
const text = await Deno.readTextFile('io.ts')
                        ^
    at Object.readTextFile (ext:deno_fs/30_fs.js:749:29)
    at file:///home/scarf/repo/etc/deno-security/io.ts:2:25
 !  ~/r/e/deno-security  deno run --no-prompt net.ts
error: Uncaught PermissionDenied: Requires net access to "www.example.com", run again with the --allow-net flag
await fetch("https://www.example.com")
      ^
    at opFetch (ext:deno_fetch/26_fetch.js:73:14)
    at mainFetch (ext:deno_fetch/26_fetch.js:182:59)
    at ext:deno_fetch/26_fetch.js:461:9
    at new Promise (<anonymous>)
    at fetch (ext:deno_fetch/26_fetch.js:424:18)
    at file:///home/scarf/repo/etc/deno-security/net.ts:1:7
 !  ~/r/e/deno-security  deno run --no-prompt run.ts 
error: Uncaught PermissionDenied: Requires run access to "deno", run again with the --allow-run flag
await new Deno.Command("deno", { args: ["--version"] }).output()
                                                        ^
    at spawnChildInner (ext:runtime/40_process.js:162:17)
    at spawn (ext:runtime/40_process.js:348:10)
    at Command.output (ext:runtime/40_process.js:421:12)
    at file:///home/scarf/repo/etc/deno-security/run.ts:1:57

tho deno is quite heavy (109MiB as of in v1.36.1) due to V8 and tools being built-in, so tyson definitely have advantages here. interested to see how tyson grows!

Yeah, I can write up a comparison with deno, but I think you have similar thought to mine already. Basically, deno is awesome, and I whole-heartedly recommend it for someone developing a typescript application. If you are writing an application instead of configuration, go use deno, not tyson. But as an embedded interpreter that can be used from a host-language, deno is very heavy.

tyson is exclusively focused on configuration, so that might lead to other differences down the road too: say, the tyson "standard library" might include utilities useful for defining and validating schemas (something like https://github.com/colinhacks/zod or https://github.com/sinclairzx81/typebox)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants