Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
What do you do when working with multiple languages with different capitalization schemes?

When mixing programming languages, is it a best practice to use different standard conventions for different languages?

The standard naming convention for variables and functions in Ruby uses underscores: new_date.

In JavaScript it is CamelCase: newDate.

Would you use both conventions within the same app? Does it get confusing remembering which convention goes with which language?

By the way, the naming example above is just one or many conventions. Others include formatting, etc.

share|improve this question

marked as duplicate by tdammers, gnat, kevin cline, BЈовић, Walter Apr 17 '12 at 23:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
That link deals specifically with naming conventions. This question is more general: it is about all programming conventions. –  B Seven Apr 17 '12 at 13:41
    
@B Seven -- yes, but the most popular answer for that question also answers yours: follow the conventions of the language you are writing. Do not attempt to invent a single style for all languages. –  kevin cline Apr 17 '12 at 18:19
add comment

2 Answers

up vote 3 down vote accepted

Personally I follow the naming conventions of whatever language I'm currently using. So in the OP's example yes I would write Ruby in_ruby_style and write Javascript inJavascriptStyle. Following the conventions of the language makes it easier to follow the code in that language.

share|improve this answer
add comment

If the different languages use different conventions, it is easier to see what context one is in.

For example - if you mix JavaScript and C#, if you using the same brace position, variable name casing and other coding standards, it can be very confusing to remember whether one is looking at C# or JavaScript and adjust your thinking to the correct one.

I don't believe there is a standard as such, but common sense dictates that you should use different coding styles (and try to keep to the idiomatic ones) per each language.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.