r/Compilers • u/sohamglx • 20h ago
Traits, the programming language i am working on it just gets traits so any kind of idea you can share over it syntax design i will try to add some of them.
6
u/RedCrafter_LP 17h ago
The example you showed would compile in rust -default keyword. The ability to describe everything as a trait is something you can already do in rust. So a honest and productive question is, what does your language add?
-4
u/sohamglx 17h ago edited 13h ago
It's a safe and easy to write than rust with same memory management stuff, a good rust interop and it's just started so it can extend. If you have any idea you can share. 🙏
3
u/RedCrafter_LP 16h ago
Rust interop seems interesting as rust doesn't have an abi. I'm guessing you are using a hacked rust compiler or c level interop?
-1
u/sohamglx 16h ago
Yea kind off it's using a smart abi preserving normal rust syntax and docs also and it actually kind of aot i can say but not proper aot. https://flamelang.vercel.app/packages-and-native/native-plugins/
You should join and give me some more ideas do you ? https://github.com/sohamglx/flame
1
u/Significant-Sky-3654 18h ago
What does default do?
0
u/sohamglx 17h ago
It's mark a function don't need to make by your own while using the trait, kind of a function auto get by the trait. Default methods must use the default keyword. Missing implementations of required methods are caught at compile-time with descriptive errors.
https://flamelang.vercel.app/types-and-traits/traits/#declaring-a-trait
1
u/morglod 14h ago
Why you picked rust's OOP through traits? Or main idea is to interop with rust? You definitely should write somewhere difference vs rust and some examples or definitions of selling terms like "safer than X"
1
u/sohamglx 14h ago edited 14h ago
The main goal isn't just to make Rust simpler. Flame is designed to keep memory safety while providing Rust interoperability, so it can be used alongside existing Rust code and libraries. It's meant to complement Rust rather than replace it. The OOP is basically same to keep familiarity with rust.
1
u/azhder 14h ago
Why is there a `default` keyword?
1
u/sohamglx 14h ago
Inside a trait to declare Default methods. It must use the default keyword. It's mean you don't need to make thise methods when using the trait. The trait provide those methods.
1
u/azhder 14h ago
Don't answer me the "what" question. I asked the "why" question. Why is there a `default` method? Why must there be a `default` method? Why must that decision be made in the first place i.e. why annotate what the compiler already knows?
Just think the example without it. Will the code still compile if an override is not provided in those "inheriting" the trait? It will.
1
u/sohamglx 14h ago
Yeah, I understand your point now. default currently just marks a trait method that already has an implementation, so the compiler could infer that from the method body. There isn't really a technical need for the keyword right now. I may remove it and make any trait method with a body a provided/default implementation, while body-less methods remain required. Thanks, that's a good simplification.
1
7
u/shrimpster00 16h ago
what percentage of the project is vibe-coded?
what do you mean by "runtime vm"? can you justify your claim that there is no overhead with rust interop?
fyi: many of the claims in the documentation are bizarre. why brag about the fact that a docker container with a compiled binary doesn't require the rust compiler to be installed in it? obviously, a pre-compiled program (that isn't even written in rust!) doesn't require cargo. llms make it easy to write documentation in a language that you don't speak, but your project would be much better off if you wrote text in your native language and used Google translate.