What's the reasoning behind both camelCase and snake_case?

The official naming guidelines (Documentation - The Zig Programming Language) recommends using camelCase for callable identifiers and snake_case for other things. Now, I don’t mind the naming conventions at all (any convention is good to me), but I’m wondering what is the motivation behind using both snake_case and camelCase. I realize this has some precedence in C++, but there you have an implicit this which often makes it useful to be able to distinguish between fields and methods. What’s the reasoning behind not only using one of the styles in Zig?

1 Like

the differentiation allows you to know the type of each thing in a list of identifiers

ie a.B.c.d_e.fG()

  • a is likely a struct/namespace
  • B is likely a type you can instantiate that also has static members
  • c could either be a struct, union, or enum
  • d_e is either a union or enum
  • fG is a function