type-safety with wing #1187
Replies: 3 comments 4 replies
-
hi! I wrote a small proof of concept program that shows how the Typescript type-checker can be used to analyze an AST. I haven't found a well-defined extension point to register a Parser (which would have been nice), but with a bit of poking into the typescript library at runtime, I got it working. source, here: https://github.com/OlafConijn/fake-parser-poc |
Beta Was this translation helpful? Give feedback.
-
I took some time to take the proof of concept a little further and committed the result in a new repository. The test files (there is one for variable assignments and another where I got started with control flow) take wing code and use the typescript AST to convert this to typescript, javascript and print types of variables. so far I ran into a number of things that I am not entirely sure about. |
Beta Was this translation helpful? Give feedback.
-
This line caught my eye:
Interesting idea to make the bucket itself typed! How do you think about checking these types? For example, if this bucket maps to an AWS S3 bucket, a different program could use a bare S3 client to store an object in it in a way that bypasses checks. Or an older/newer version of the same program could insert an instance of This has (potentially) deeper runtime implications than compile-time type checking. I say "potentially" because you could always do the TypeScript/JavaScript thing, and pretend the problem doesn't exist once it leaves the compiler. But it feels to me like that's an interesting opportunity to define such semantics for the "inflight" phase. |
Beta Was this translation helpful? Give feedback.
-
@OlafConijn
Hi all, when I was reading up on wing-lang a couple of days ago, it got me thinking about type-safety….
I rely heavily on type safety for both static analysis of my program as well as the convenience of being able to use auto-complete. I program primarily in TypeScript and must say I am deeply impressed with TypeScripts type system. Static analysis as described at the end of this section is peanuts.
If i imagine a cloud-native programming language I could imagine it look like the following:
now... i believe the pre-flight code to be assembled differently from the in-flight code. I did notice the compiler for the in-flight code to output javascript code (makes sense), but what I wondered is the following…..
If, instead of assembling in-flights to javascript, the compiler would emit an typescript AST... this might allow you to use the typescript type checker against the AST (including all of its features)
It might also allow re-use of other tools like the VS.language service for typescript or just for rapid prototyping of language features. The AST can (obviously) be used to also emit the javascript code that needs to run in the actual function.
I have not had a lot of change to read about Wing and also am not familiar with the vision you have for the language. Maybe becoming a front-end compiler to typescripts (front-end compiler) is not what you guys are aiming at.
Still thought it was an idea worth surfacing
@lsegal
I think this thread closely matches my takeaway that Wing should much more closely mimic TypeScript's syntax and in should in general just be a preprocessor layer on top of (or worst case a fork of) TypeScript's grammar/compiler so that there does not need to be a reinvention of type system, semantics, optimizations, etc. It would mean spending less time spent having to fix basic things like empty arrays not compiling and more time on the important stuff.
@OlafConijn
that sounds about right!
i don't think it means you'll have to do much concessions on syntax (as long as you keep your own parser). having worked with the typescript compiler before i might be able to come up with a small example of how this works (if/when time permits). would be happy to share
Beta Was this translation helpful? Give feedback.
All reactions