Hi,
For context, I am a developer whose first language is Python (I co-authored a Python library with hundreds of stars) and currently works on a JavaScript game that is remixed by children to teach them JavaScript. In other words, I am an educator of computer science tied to the web platform.
Using a more traditional C-like syntax will help JavaScript developers learn the C-like syntax, which will help them move
towards C/D/C++. This will help them expand their horizons quickly.
For languages where types are mandatory, the Rust/Python-ish syntax only increases typing. Typing is often a barrier for children and teenagers that are learning to code.
[[location 0]] var<out> gl_FragColor : vec4<f32>;
fn main() -> void {
gl_FragColor = vec4<f32>(0.4, 0.4, 0.8, 1.0);
return;
}
entry_point fragment = main;
@location!0 @var!out vec4!f32 gl_FragColor;
void main() {
gl_FragColor = vec4!f32(0.4, 0.4, 0.8, 1.0);
return;
}
entry_point fragment = main;
The latter example is 13 characters shorter.
By being too soft and forcing developers to learn a trendier syntax, it will make people learning to code to take a farther route in the long-term. While in the short-term the Rust/Python-like syntax will help people learn WebGPU quickly-- more familiar to users of TypeScript and Python-- it will harm their ability to learn languages with more traditional syntax, such as Swift, C, D, C++, and many more. The aforementioned languages are clear examples of stepping into system programming. Systems programming should be for everyone.
The ! syntax for templates is very D-lang specific and nearly resembles line-noise imo.
I'm curious why you don't include Rust as having traditional syntax.
Closing as a duplicate of #677
I'm curious why you don't include Rust as having traditional syntax.
Python's syntax had types bolted on. So did TypeScript and Flow. Rust inherited its syntax from TypeScript and Python.
FORTRAN, the oldest language still in use today: integer :: i;
function func(i) result(j)
integer, intent(in) :: i ! input
integer :: j ! output
j = i**2 + i**3
end function func
All versions of C: int i;
int func(int i) {
return j;
}
While ML and the Haskell family have a type-after-declaration syntax, WGSL is definitely a language on the imperative tradition, not one on the highly functional tradition.
The ! syntax for templates is very D-lang specific and nearly resembles line-noise imo.
The type argument to the "templated type" is part of the meaning of the type as a whole. You can imagine the "!" as part of the identifier name. For example, vec4!int and vec4!f32 are used for completely different purposes, and the "int" and "f32" parts distinguish them. < and > scream "THIS IS A GENERIC", while "!" let's the type argument take front position.
Rust definitely did not inherit its type syntax from TypeScript and Python. It more likely inherited it from the family of ML (OCaml, et al) and their predecessors. This syntax makes a lot of sense in languages where static type inference is used frequently.
Most helpful comment
Rust definitely did not inherit its type syntax from TypeScript and Python. It more likely inherited it from the family of ML (OCaml, et al) and their predecessors. This syntax makes a lot of sense in languages where static type inference is used frequently.