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

Different syntax compared to classes. - Take inspiration from rust #43

Open
Jordan-Hall opened this issue Oct 8, 2024 · 2 comments
Open

Comments

@Jordan-Hall
Copy link

Jordan-Hall commented Oct 8, 2024

Some developers prefer not to constantly use this in classes, as classes in general can lead to larger files and complicate code splitting. They much prefer a functional approach. I believe it would be a good idea, considering memory and parallel processing, to examine the syntax available.

Suggestion: Make structs more like Rust, as many JavaScript tools are leaning towards Rust, taking into account proposals like JSSugar/JS0, where tooling becomes first-class. If type annotations become a reality, it would make sense to adopt Rust syntax for structs, traits (type annotations), and impl for implementation rather than extension.

This would eliminate the limitations surrounding multiple inheritance, which is still restricted to mixins and thus not safe for parallel processing. It also offers a good middle ground between classes and functions, facilitating code splitting. I don't believe it would be good idea to allow structs to be extended like classes if we looking for good memory management

I don’t want to derail the feature, but I have been thinking long-term about an additional proposal. It would be misguided to impose restrictions based on features or syntax that has already been implemented.

@bakkot
Copy link

bakkot commented Oct 8, 2024

The "type annotations" proposal is not adding types to the language, just new syntax for comments. The rest of the Rust stuff doesn't make sense unless the types actually have semantics, which they won't in JS.

@Jordan-Hall
Copy link
Author

i thought that was just the first version. i dont think extending struct is a good idea. Structs will become too heavy

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

2 participants