4 ms·
This is such nice work that I hesitate to bring up a minor point of coding style... But the use of names_with_underscores looks out of place in JavaScript. Jav
by Stratoscope 13y ago
This is such nice work that I hesitate to bring up a minor point of coding style... But the use of names_with_underscores looks out of place in JavaScript.
JavaScript code traditionally uses PascalCaseNames for constructors and camelCaseNames for variables, properties, and methods. You do see UPPERCASE_NAMES_WITH_UNDERSCORES used sometimes for "constants", but that's about it.
Of course, names_with_underscores work just as well as any other names, and some people use them in their own JavaScript code, but I think libraries should follow the traditional native conventions of their language.
It would be like releasing a Ruby library that used camelCaseNames for its method names. It would work, but many Ruby developers would feel that those names were a bit out of place in a language where method names customarily use underscores.
Mentioning it here basically just as a reminder for other library developers: "When in Rome..."
- ars 13y agoI don't think the language gets to decide the coding style. Only the programmer gets to do that. Especially if you program in multiple language it can be jarring to switch styles for each language.
- Stratoscope 13y agoThat's a good point, and I run into that problem myself. I prefer camelCaseNames over names_with_underscores in just about any language. When I write Ruby code for myself I sometimes use camelCaseNames just because I like them better. But if I'm writing code for someone else I try to follow the language's conventions if possible. Especially if it's a library that will be combined with other libraries and application code that does follow native conventions. After all, it's also jarring to write code in one language that has to use multiple styles because it integrates libraries that weren't consistent with the common language conventions.
- taspeotis 13y agoSure, but a lot of languages are so closely related to their "standard library" that you adopt the style of the "standard library" Take C# and the BCL. C# is a language but you'd be hard pressed to avoid using the BCL in any meaningful C# program. String.Format("Hello {0}", stringVariable); All (nearly all?) the function names in the BCL are UpperCamelCase, and a lot of C# code follows that as a convention. Repeat for class names, interfaces prefixed with I, public properties etc.
- Kudos 13y agoPython adopted a styleguide and I don't think I've seen any modern Python using camel case since. If anyone was to use camel case, they would be presumed to be a beginner. http://www.python.org/dev/peps/pep-0008/ http://www.python.org/dev/peps/pep-0008/
- rtpg 13y agoI change keyboard layouts depending on (natural) language, though that's just personal preference. I think that flexibility of style has been getting less and less favor recently : a lot of languages are starting to "force" some elements (such as indentation) , and go has done the most intelligent thing ever and ships with a formatter so that there's only 1 "right" way to write things. Formatting issues is the source of so much bike-shedding, despite that it really shouldn't be much of a productivity sink in 99.9% of situations.
- deathanatos 13y agoXMLHttpRequest.
- Tloewald 13y agoTo be fair — introduced by microsoft.
- WickyNilliams 13y agoConstructor, so is valid
- deathanatos 13y agoCare to elaborate how you think a constructor validates it?
- ams6110 13y agoI've seen both conventions; also in other languages, CSS class names ('-' vs '_' vs camelCase), e.g. anywhere a "name" is created to refer to something. Do try to not get hung up on it, it's mostly a matter of developer preference and you'll never get universal agreement unless the language itself enforces or excludes a particular convention.