javascript-tutorial / en.javascript.info

Modern JavaScript Tutorial
https://javascript.info
Other
23.33k stars 3.84k forks source link

Irrelevant details in variable naming section #3608

Closed carlosperez-dev closed 10 months ago

carlosperez-dev commented 10 months ago

Hello, Thank you for maintaining this guide, it's great! Raising this as I think the last two sentences in the variable section are unnecessary as they're neither technical nor stylistic details and add no value to the point being expressed. Moreover the last sentence assumes that English is the only language spoken in other countries, specially given the big push for all translations.

image

joaquinelio commented 10 months ago

I disagree. Imagine the author of this tutorial doing examples in Cyrillic...

If you like your script to be maintainable for others (worldwide!), do prefer basic alphabet and use english var/func names.

carlosperez-dev commented 10 months ago

I think that by using Cyrillic the author would be breaking the international convention, and fewer people worldwide would be able to maintain it. I don't disagree with the point you're making as you're right international standards greatly increase chances it can be maintained internationally. However the sentences in question don't portray that, at least when I read it. As a matter of fact if the point that is trying to be passed on to the reader is: to have the best chance at maintainability stick to international standards, then the way you've described is more eloquent. Perhaps a redaction e.g. "...it may have a long life ahead. By obliging to international standards we greatly increase its chances of our scripts being maintained by others in the future." is better suited for that point.

Alexandre887 commented 10 months ago

English is an officially recognized international language. And, pretty much all programming languages use English to describe the "instructions", the commands that a computer must understand. The vast majority of programming literature, documentation, specifications, manuals - all this is written in English. And the message of the last two sentences is exactly the same: if a programmer wants his code to be readable for people from all over the world, no matter who will work with his code, he should invent such names for various structures in the language that these names will be understandable to everyone who will read the code. An English speaker will not understand variables in Russian, a Russian speaker will not understand variables in Chinese, a Chinese speaker will not understand variables in Korean, and so on. But everyone will understand English, for the reasons I have already listed above.

It specifically says what this tutorial teaches beginner programmers: first of all, provide readability and maintainability of your code. It doesn't matter whether you are writing a 25-line script for some website or a complex 3D engine using extremely complicated mathematical algorithms. Because this script can actually have a long life, which is what the paragraph you quoted states. You can invite your programmer friend to continue writing the code, but together, who, for example, does not speak the language in which you made up the names for your functions.

We can take any software development company as an example - let's say, Google. Google employs tens of thousands of people, and not all of them have English as their native language. Imagine that all these people start writing code using their native languages to describe variables/functions or something else. How will you ensure code maintainability in such a situation? Then, in order to fix a bug in the code, or at least understand what this code does, the programmer should also sit with an open online translator and a lot of dictionaries in different languages?

I don't understand the point of this Issue and the point in deleting these sentences.

carlosperez-dev commented 10 months ago

Fair enough, closing the issue