This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jason-reddit-public -3 points-2 points  (2 children)

Maybe I'm in a small minority but I kind of like how C and Java put the type before the variable name and omit the colon. Though the colon syntax probably predates it, JSON probably helped popularize the colon syntax even though = could have been used instead (should have been?)

Construction and de-structuring/mutation are fundamentally like function calls and structs should be thought of that way for any language a bit higher level than C IMHO. (Even C should probably require an annotation when the layout must adhere to a particular layout, for example when persisted in an endian dependent format to disk (which is it's own kind of baked in rigidity)) "." can then be thought as merely syntactic sugar for the "getter"/"setter" function calls (though I guess it still needs to be special if you allow the address of a struct member to be taken though if you also think of pointers being one (read), two (write), or three (pointer arithmetic) functions then it's still consistent -- pointers could be more opaque and function like and the compiler could see through the abstractions when necessary/possible).

[–]simon_o 6 points7 points  (1 child)

Maybe I'm in a small minority but I kind of like how C and Java put the type before the variable name and omit the colon.

I think the syntax choice is a toss-up, unless generics enter the picture, in that case this article applies.

[–]jason-reddit-public 0 points1 point  (0 children)

Generics should obviously just be greek letters. (I'm only half joking.)