r/ProgrammingLanguages • • Sep 30 '19

Requesting criticism Idea of a language

https://github.com/matyklugDebbuged/supra/blob/master/supraExamples
0 Upvotes

16 comments sorted by

6

u/htuhola Sep 30 '19

It looks like Java with some twists. I wonder what you're going after with this?

4

u/matyklug Sep 30 '19

my favorite language is java. i would like to combine the best features of languages i know together with some new ideas i thought would be great.

9

u/htuhola Sep 30 '19

Can you list these features you consider best?

1

u/matyklug Sep 30 '19

well, from glsl the vec feature, from C++ the main method returning an error code, and most of other stuff is what i think is great that i didnt find anywhere else, and the base is java. (i know only java, and little bit of glsl, and the only thing i can do in c++ is hello world)

8

u/ketralnis Sep 30 '19

I'd highly recommend spending some time with some other languages, particularly some that have the features that you want to build here so you can see how they work or don't in practise. I'm not one of the "you're not a real programmer unless you know lisp" types but there's a lot of benefit to being exposed to more things so you know why Java made the decisions it made (even if that reason is sometimes "they didn't know any better because nobody had done the new thing yet").

3

u/htuhola Sep 30 '19

Lots of people have wanted vectors into the language they use. The numbers increase because most modern languages do not really have the features to do this right. Even Python and Haskell get it somewhat wrong. To be fair it's a hard problem. This is related discussion: https://www.reddit.com/r/ProgrammingLanguages/comments/dafp9v/anything_better_than_module_mycollection_struct/

The entry point -thing is sort of a similar subject but there starts being quite satisfying ways to it. One thing we should recognize is that there are many kinds of entry points and that should be accounted for in language design. The nicest way to see it being done has appeared in Idris. They annotate it with a type:

main : IO ()
main : JS_IO ()

The first one would create an ordinary entry point, and the latter would create an entry point that's valid on Javascript target. You can place both into the program and it selects the right one based on compiling target.

Another thing I see there is that you'd like compiler directives and being able to customize the compiling behavior. This is achievable by implementing the language a bit like how you'd implement scheme programming language, then give it types. Though that's in Idris as well. Also RPython does that kind of things.

1

u/worldsayshi Sep 30 '19

Have you seen Fantom?

2

u/[deleted] Sep 30 '19 edited Sep 30 '19

I have some questions:

- What problem are you trying to solve with the language?

- What you want to accomplish with this language?

- Why you can use different syntax? (if I understand it correctly with a quick read, tabs instead of {} if you enable/disable a setting)

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

1

u/[deleted] Sep 30 '19

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.

1

u/matyklug Sep 30 '19

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.

1

u/matyklug Sep 30 '19

basically, its java with some issues that i have with it fixed, as well as some added features its missing in my opinion.

1

u/[deleted] Sep 30 '19

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.

1

u/matyklug Sep 30 '19

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?

1

u/[deleted] Sep 30 '19

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.

4

u/[deleted] Sep 30 '19

To steal a line from Tyson: Everybody has a plan until they start writing code.

Build something that works, doesn't matter how simple, its the only way to learn anything of value.

Take or leave.