Description
This issue was originally filed by Ray.Rac...@gmail.com
What steps will reproduce the problem?
1.Write Dart code as proposed.
2.
3.
What is the expected output? What do you see instead?
Optional type annotation to be on the right of the identifier. Use of val to replace final and def to denote the start of a method/function definition.
What version of the product are you using? On what operating system?
All
Please provide any additional information below.
- Use of the type annotation on the right allows for better readability and more importantly positions Dart to more easily handle future syntax extension and language evolution. Dart language designers know the pros / cons here already.
val x Int = 3
var y String = 'Gilad'
def rev (s String)String => s.reverse ()
-
Use of val of final is more intuitive, pithy aligns code nicely with var and def.
-
Placing the type on the right supports (requires) the use of a keyword to denote a method / function definition. Use of 'def' is suggested.
Primary Reason Not to Change.
The stated reason to keeping type annotations on the left is familiarity for the mainstream programmer as (I assume) many of the new Dart new comers will be from C#, Java.
-
There are as many non-Java people coming to Dart who will not have any basis. Those from JS, Ruby, Python will be familiar with 'def' for example.
-
Universally Java/C# people coming to Scala have been positive with this syntax as cleaner and enhancing readability. (Scala adoption issues center on the complex type system and not its base declaration syntax).
-
It is apparent that Dart has been painted, unfairly, as "its just Java". These small syntax changes,off a sense of "freshness" to the Dart language that will soon be appreciated by new comers.
Adaption has shown the barrier to new syntax is very low barrier and immediately appreciated by the majority of Java users for its basic elegance and cleaness.
People will be much more receptive to Dart from such a sense "newness" and "freshness" about it from such minor syntax cleanups yet retains all the core familiar concepts.