为什么代码中的注释颜色不同?

发布于 2024-07-22 04:47:59 字数 38 浏览 10 评论 0原文

为什么不同程序中的评论颜色不同? 这只是审美还是有实际原因?

Why are comments different colors in different programs? Is it just aesthetic or is there an actual reason?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

一腔孤↑勇 2024-07-29 04:47:59

这取决于 IDE 或编辑器中的设置。 评论没有固定颜色。 它们只是字母。

It depends on the settings in your IDE or editor. Comments don't have a set colour. They are just letters.

-黛色若梦 2024-07-29 04:47:59

我认为这是为了让它们脱颖而出,这样人们就不会轻易将它们与代码混淆。

I assume it is to make them stand out so people do not easily confuse them with code.

笑红尘 2024-07-29 04:47:59

迷惑色盲经理。

To confuse color-blind managers.

So尛奶瓶 2024-07-29 04:47:59

纯粹审美

purely aesthetic

呢古 2024-07-29 04:47:59

注释的颜色不同,以使它们从代码的其余部分中脱颖而出(使得更容易阅读和跟踪注释路径)。

为什么它们是某些颜色完全取决于相关编辑器的制作者(通常基于可用性研究),但您几乎总是可以使用 IDE 的设置来更改这些颜色。

Comments are colored differently to make them stand out from the rest of the code (making it easier to read and follow along the comment trail).

Why they are certain colors is entirely up to the makers of the editor in question (usually based on usability studies), but you can almost always change these using the settings of the IDE.

欢烬 2024-07-29 04:47:59

正如 Aiden 所说,这实际上取决于实施 IDE 的人来选择。 我很熟悉绿色代码注释,因为 SQL Server Management Studio 和 Visual Studio 默认情况下都是绿色的,但开发人员没有理由不能(例如)在他们的 IDE 中选择紫红色、柠檬黄或黄绿色。 加载到另一个 IDE 中时,“代码注释”将以该 IDE 的颜色显示。

As Aiden said, it's really up to whoever is implementing the IDE to choose. I'm familiar with green code comments, as both SQL Server Management Studio and Visual Studio are green by default, but there's no reason why a developer couldn't (for instance) choose fuschia, or lemon yellow, or chartreuse, in their IDE. Loaded into another IDE, the "code comments" would display in that IDE's colour.

凉城凉梦凉人心 2024-07-29 04:47:59

灰色或绿色用于注释,因为其他颜色具有更理想的属性,因此保留用于代码中更具影响力的区域。

例如,紧密的循环通常是红色的,以使它们运行得更快,而儿童代码通常是蓝色的(出于同样的原因,他们学习蓝色的手写体),以使其不那么困难和更熟悉。 蓝色通常也用于语言关键字和 API,以使其更易于理解。

由于人眼辨别绿色的能力增强,非常重要的代码或注释以绿色显示。

黑色和灰色用于代码中乏味和无聊的区域,以鼓励您查看其他地方,例如明亮且令人兴奋的界面和文档(如上所述为蓝色和绿色)。

病毒、木马等总是以白色书写,因此它们可以逃避大多数桌面主题的检测。

Gray or green are used for comments, as the other colours have more desirable properties and so are reserved for more impactful areas of the code.

For example, tight loops are often in red to make them go faster, and code for children is often blue (for the same reason they learn handwriting in blue), to make it less difficult and more familiar. Blue is often also used for language keywords and APIs to make them easier to understand.

Very important code or comments are in green, due to the increased ability of the human eye to discern green.

Black and grey are used for tedious and boring areas of the code, to encourage you to look elsewhere, such as the bright and exciting interfaces and documentation (which are in blue and green as above).

Viruses, trojans and the like are always written in white, so they can evade detection by the majority of desktop themes.

挽袖吟 2024-07-29 04:47:59

这是严格意义上的审美。 如果您使用好的 IDE 或文本编辑器,您可以将注释的颜色更改为您喜欢的任何颜色!

我在工作中使用 Visual Studio 2008,我看到很多人更改保留字、类名等的颜色。

It is strictly aesthetic. If you use a good IDE or text editor, you can change the color of the comments to be whatever color you like!

I use Visual Studio 2008 at work and I see a lot of the guys changing the colors for reserved words, to class names, to you name it.

热血少△年 2024-07-29 04:47:59

大多数程序允许您自定义配色方案,包括注释的颜色。 对源代码、注释和其他内容进行着色,可以使代码更具可读性。 特定颜色的选择是个人和审美的。

Most programs allow you to customize color schemes, including the color of comments. Coloring source code, comments and other things, allows the code to be more readable. The choice of particular colors is personal and aesthetic.

终难愈 2024-07-29 04:47:59

当您说“不同的程序”时,我假设您指的是“开发环境”。

但总的来说,你是对的。 它既具有美观性,又具有可用性。 开发环境 (IDE) 制造商(例如 Microsoft 的 Visual Studio)进行可用性研究,以确定什么颜色最适合开发。 比如用什么颜色来制作关键词、评论等。

但是这些默认的颜色偏好通常很容易被用户更改。

I am assuming you mean "development environments" when you say "different programs".

But in general, you are correct. There is an aesthetic, as well as usability, component to it. Development Environment (IDE) makers (e.g., Microsoft's Visual Studio) do usability studies to determine what colors are "best" for development. Like what color to make keywords, comments, etc.

But these default color preferences are generally easily changeable by the user.

℡Ms空城旧梦 2024-07-29 04:47:59

它只是为了美观和可用性,它清楚地表明什么会被编译成代码,什么不会被编译成代码,以及为了理解正在发生的事情而需要阅读的内容。

It's just for aesthetics and usability, it makes it clear what will and will not be compiled into code, and what's important to read to understand what's going on.

若水般的淡然安静女子 2024-07-29 04:47:59

我不太确定你的意思,但我假设你想知道为什么不同的 IDE 在语法突出显示中使用不同的颜色作为注释。 它主要只是为了美观,但如果您愿意,通常可以更改颜色。

I'm not really sure what you mean, but I'm assuming you are wondering why different IDEs use different colors for comments in their syntax highlighting. It's mostly just aesthetic, but you can usually change the colors if you want.

鸢与 2024-07-29 04:47:59

以前,屏幕是黑色的,所有字母都是绿色的! 它们有不同的颜色,可以帮助您确定每种颜色的用法(注释、命令、变量等),这不是进步!

back in the day, the screen was black and all of the letters were green! they are various colors to help you determine the usage of each (comment, command, variable, etc.) isn't progress grand!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文