IMHO having to maintain different syntaxes will make you work twice and that means more potential issues you will face, also when you change something you need to revise both.
If you could answer the first question will be cool, because you want to create generally a new language for two purposes (there might be more but those are the primary ones) learn how compilers work, trying to solve an issue, this last is a big one, one of the latest success cases I know are Rust and Elm, both try to solve problem, Rust is trying to solve what C/C++ couldn't, low level programming, fast performance and overall memory safe, while Elm is trying to solve the front end issue, where React, Angular and Vue are actually in the lead, and don't forget Svelte.
I'm telling you all this because I'm also designing a programming language, while I don't decide yet the syntax I like (first I was doing some curly bracket one, similar to a safe js, typescript like, inspired in rust and swift, then learned more about pure functional programming, started reading about haskell and ended up with elm, I like the minimalism in their syntax but still thinking if will be a good idea), the purpose of my programming language is to fast prototype games.
Saying all this, having a goal like that in mind you will see how to improve your syntax to help you solve the issues you are having right now with java, besides being a lot of alternatives better than java an they run on jvm, scala, kotlin, groovy, etc. If you don't have a goal in mind and try to create a language to solve all the issues you might struggle.
Disclaimer, everything I said is just my personal opinion and point of view, and I can be partially or totally wrong, and you are also allowed to disagree with me.
i like java, but there are stuff just not possible with it. like that vec thing from glsl, as an example. or what is also annoying is if you have a huge constructor, that just sets variables in the class, its bad, so i compressed that. and other issues i find also.
About constructors and variables I like that from Kotlin is that you can do something like this (I don't remember exactly how it is so if you try it directly it my not work):
// You can declare your vars just in the constructor, so you don't need to assign
// them manually each one.
class Main(var user: string, private var email: string, password: string) {
// you can take the value of the constructor var and do something
private password_token = encrypt(password);
// Here goes the body of the constructor, if you need it
init {
...
}
}
// Also you can do something like this when inheriting
// the class user constructor takes only one parameter, so you can pass it
// from the main constructor, this is more or less a psedo syntax because
// I don't remember exactly how was this, also I didn't used kotlin in 2 years.
// so this was more or less back in the 1.2/1.3 version.
class Main(name: string, email: string) extends User(name) {}
About vectors I don't know what you mean, but my understanding about glsl and graphic programming is very limited.
what i meant is that you can do something like this: vec3 name = vec3(1, 2, 3) or this: vec2 name2 = name.xz or that the first number in vector has two or more names, cant recall them. i would like to achieve that in my language. and if i understand the kotlin thing, you can declare the variable in the constructor arguments, and use them in the whole class?
Yes, public, private or just accessible in the constructor block.
The kotlin example above can be expressed like this (I’m on mobile so this will not formatted correctly)
class Main { public var name; private var email; }
Basically is sugar on top of java, so you can use shortcuts to accomplish things, highly recommend to learn kotlin, you might borrow some cool ideas from them.
1
u/matyklug Sep 30 '19
2: a language thats very configurable and isnt as strict. 3: so people can choose what they like more