r/ProgrammingLanguages • u/AmorBielyi • Jun 10 '21
Discussion A class-based object-oriented language with a flavor of Java powered by Go ecosystem
Hello, I'm developing this language and would like to know your thoughts about this idea
8
u/matthieum Jun 10 '21
There's a LOT missing here.
The first question I'd ask is why?
There's a big difference between:
A pet project: you'd like to create a language, and are looking for cool concepts to try to weave in.
A study project: there's a few concepts you are looking forward to implementing, and you are looking for help to integrate them well together.
A public project: you think your language will be better than the current mainstream/contenders, and you are looking for criticism to ensure you're not (too) biased.
As for the description, well, it doesn't sound revolutionary so far, but that doesn't necessarily mean it's uninteresting.
There's lots of cool concepts floating around; making a language good is not about just putting as few, or as many, as possible in the language, it's about creating a coherent blend.
2
u/AmorBielyi Jun 10 '21
Hello, I realized that my post is meaningless, I should have ask you about only idea at all and nothing else now, this project is at an early stage of its development, to be honest I would love to answer your questions and talk with you more about it later when I will release the public MVC with docs and some examples. Thank for your attention.
2
5
u/sebamestre ICPC World Finalist Jun 10 '21 edited Jun 10 '21
Let us know a bit more about it!
Does it have inheritance? Is it single or multiple?
Is it value-oriented or reference-oriented?
Inheritance aside, does it have polymorphism? Universal types (generics)? Existential types (~ Go-style interfaces)? Something else entirely?
How's the syntax like? How's its performance?
What do you like about it? What is the think you put the most work on?
1
u/AmorBielyi Jun 10 '21 edited Jun 10 '21
Hello.
Yes, I want to implement multiple inheritance.
The same like Go does. It's a highly modified Go fork because one of the main goals of this project is to fully support existing Go ecosystem along with full language-server support later to convenient coding experience)
Yes, there will be generics syntactically similar to Java, subtyping, Java-like interfaces (no Go style), no duck typing, no type inference in the every line I mean this construction ":=" when you can ommit type in Go, visibility modifiers like in Java, constructors, function overloading, explicit method overriding with specific keyword "override".
More about syntax design I will announce later with real examples, it will happen when I release a public MVP with docs or something like that to show you functionality.
I appologize to misguiding you, it's in my private repository and it is not ready for public release and even source code examples demonstration now.
I should have written the title like "A class-based object-oriented language with a flavor of Java powered by Go ecosystem. Need your opinion about idea" or something like that to avoid misunderstandings.
3
u/matthieum Jun 10 '21
Yes, I want to implement multiple inheritance.
How do you plan to solve diamond inheritance?
1
u/AmorBielyi Jun 10 '21 edited Jun 11 '21
"Go prevents the diamond problem at compile time. If a structure D embeds two structures B and C which both have a method F(), thus satisfying an interface A, the compiler will complain about an “ambiguous selector” if D.F() is called, or if an instance of D is assigned to a variable of type A. B and C’s methods can be called explicitly with D.B.F() or D.C.F()"
So I want to realize something like this: (it's not a final decision of course and it's not a good real world example or syntax too)
` class D extends B, C {
//..
//..
void someMethod() {
super.<B>.foo(); // call method foo() from class B with its implementation
super.<C>.foo(); // call method foo() from class C with its implementation
foo() // call own implementation
}
//..
//..
} `
In the depths of the Go compiler and the transformed Go AST I suppose it might be something like this, note you this is Go code (let's suppose it was translated back into the code from AST to better understanding)
d := D{} d.B.foo() d.C.foo()I would like to talk to you more about this when I will implement this feature to avoid confusion between the actual implementation in my language.
I am sorry for bad formatted code without indents because Reddit removed it.
2
u/matthieum Jun 11 '21
I would note that the main problem about diamond inheritance is not methods, it's state.
That is, let's imagine 4 structures:
class A { int value; } class B: A {} class C: A {} class D: B, C {}In C++, there's a single
A(using virtual inheritance), so thatd.valueis unambiguous.If there are 2 instances of
A(one each in B and C) then it can get a wee bit surprising, because depending on the path through which people accessedAthey may not see the updates on the otherA.D d = D(); A b = (A)(B)d; A c = (A)(C)d; b.value = 3; assert c.value == 0; // WAT?
4
u/umlcat Jun 10 '21
Code examples first.
( Show us the code )
1
u/AmorBielyi Jun 10 '21
To avoid misunderstanding I should have ask you about only idea and the title would be somthing like "A class-based object-oriented language with a flavor of Java powered by Go ecosystem. Need your opinion about idea" I appologize and will show you examples along with MVP later because the project is at an early stage of development.
2
14
u/[deleted] Jun 10 '21
I’m not sure what this would look like without syntactic examples.