Godot-proposals: Allow opting for C-style syntax in GDScript

Created on 24 Sep 2020  路  6Comments  路  Source: godotengine/godot-proposals

Describe the project you are working on:
Spaceship game

Describe the problem or limitation you are having in your project:
I don't like python syntax as I find it ugly and unnecessary in the amount of indents needed to write code

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Allow a optional syntax for gdscript that is more like c and javascript

here is what I mean..

  • allow us to write ( ) in loops declerations
    while(true):
    for(i in items):

  • allow for implicit property setters

my_field =0
my_property:
    get: return my_field
    set: my_field = value
}
  • allow for c style blocks
func my_func
{

}

class my_class
{

}

while(true)
{

}

if (true)
{

}

my_property
{
  set(value) { field = value }
  get { return field }
}
  • allow for first typed static typing
int a = 0
int my_func(int a, int b):
 return a + b

I think this would help some people feel more comfortable using gdscript that are used to c and java like languages
I think that while users can use a diffrent language its not always ideal as gdscript was specifically made to work with godot.

I also think that it could be made a optional thing in project settings so code is forced to be consistent throughout the project

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
see above

If this enhancement will not be used often, can it be worked around with a few lines of script?:
I would definitely use it and no you can't not without using a language that doesn't have built in editor support

Is there a reason why this should be core and not an add-on in the asset library?:
I think while it would require some work to implement I also think that many of these features are more desirable then the current ones. for example implicit properties are faster to type and look nicer, c style blocks don't force indentation and are good in some multi dimensional loops, first typed static typing takes less time to type and and also supports typed nulls.

besides that its more of a personal opinion to me and what I would assume to be other developers that it just overall looks better.

and a while good programmers are not always comfy programmers, comfy programmers are more likely to enjoy like while writing code.

archived gdscript

All 6 comments

I don't like python syntax as I find it ugly and unnecessary in the amount of indents needed to write code
I think this would help some people feel more comfortable using gdscript that are used to c and java like languages

The exact same argument can be made the other way...
_"I think this would help some people feel more comfortable using gdscript that are used to python like languages"_

I actually prefer c-style languages too with braces {} and parentheses () but just changing the whole language syntax 'just because' is a not a good or helpful idea. Many people use python as their first language and it is beginner friendly, so having similarities between them is not a bad thing. Not all languages need to be the same - there are pros and cons to each style.

As for having it be "optional" syntax... that would be convoluted and confusing for users I think. It would look really messy if you were to mix the styles in one file too... It would also be another thing for the developers to maintain in the future for not much benefit.

allow for implicit property setters

This is being discussed and could potentially be something implemented for 4.0.

allow us to write ( ) in loops declerations
while(true):
for(i in items):

This is allowed already, though? At least, I always use explicit formatting with ifs and whiles. Not sure about for.

Optional syntaxes are never a good idea. I don't know a single language that pulled them off successfully. I know several tried, including https://github.com/forest-lang/forest-compiler

@EricEzaM It wouldn't be changing the syntax it would be adding a new optional one
and your point doesn't really make sense since gdscript already uses python syntax

@pycbouh It doesn't work for for loops it throws a error requiring a identifier

@Zireael07 I don't see any reason why optional syntaxes would be bad besides code consistency.

Optional syntaxes are bad because it's double the code in a language's parser and lexer that someone has to maintain.

maybe this suggestion should be closed for support for custom languages built into the godot editor
EDIT: here is the link https://github.com/godotengine/godot-proposals/issues/1568

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PLyczkowski picture PLyczkowski  路  3Comments

davthedev picture davthedev  路  3Comments

Dorifor picture Dorifor  路  3Comments

wijat picture wijat  路  3Comments

lupoDharkael picture lupoDharkael  路  3Comments