Tips & Tricks•10 min read•

What Is /* */ Called? Comment Syntax in 25 Languages, and How Much of Real Code Is Comments

Yash Rai
Yash Rai
Founder, TurboType
What Is /* */ Called? Comment Syntax in 25 Languages, and How Much of Real Code Is Comments

The short answer: /* */ is a block comment, also called a multi-line or C-style comment: /* opens it and */ closes it. // is a line comment that runs to the end of the line, and # does the same job in Python, Ruby and shell scripts. We counted every comment in 2.27 million lines of library code in eight languages: 48% of the lines in Rust's standard library are comments, against 5% in Microsoft's C++ standard library, and documentation comments account for almost all of the difference.

Key Findings

  • •

    Comment lines range from 5.3% to 48.4%: Microsoft's C++ standard library at the bottom, Rust's standard library at the top, with Laravel (45.6%) and OpenJDK (45.3%) close behind.

  • •

    Doc comments explain the gap. 88% of the comment lines in Rust and OpenJDK, and 98% in Laravel, are documentation. Ordinary comments fill between 5.3% and 9.6% of the lines in seven of the eight libraries.

  • •

    More than half of the characters in Rust's standard library, 53.3%, are inside comments.

  • •

    C still writes /* */: 95% of the comments in musl, against // for 82 to 91% of the comments in the C++, JavaScript and TypeScript code.

  • •

    TODO-style markers are rare: at most 1.23 per 1,000 lines. Rust writes FIXME instead (330), Python writes XXX (197).

Source: TurboType analysis of 9,001 files and 2,274,712 non-blank lines in musl, Microsoft STL, OpenJDK, Node.js, Vue, Laravel, CPython and the Rust standard library, November 2026.

1. What Comment Symbols Are Called

A comment is text the compiler or interpreter skips. Every language marks it with a symbol or two, and most programmers know them by these names:

SymbolNameWhat it does
//Line comment, single-line comment, double slashSkips the rest of the line
/* */Block comment, multi-line comment, C-style commentSkips everything between /* and */, across lines
/** */Doc comment, docblock; Javadoc, JSDoc, PHPDocA block comment that documentation tools and editors read
/// and //!Doc comments (Rust, C#, Swift; Java since JDK 23)Documentation written line by line; in Rust, //! documents the enclosing module
#Hash commentLine comment in Python, Ruby, shell scripts, PHP and YAML
<!-- -->HTML commentComment in HTML and XML
--Double-dash commentLine comment in SQL, Lua and Haskell
""" """DocstringA Python string, not a comment, that documents a module, class or function
#!ShebangA comment to the language and an instruction to the operating system, on the first line of a script

*/ on its own means "end of comment", and it ends the comment wherever it appears. Block comments do not nest in C, C++, Java, JavaScript or CSS, so /* glob: src/**/*.js */ ends inside src/**/, because **/ contains */, and *.js */ is then read as code. Rust, Swift and Kotlin allow a block comment inside another, which makes commenting out a whole region safe.

Both styles are old. /* */ reached C from PL/I by way of B. // comes from BCPL, went into C++, and only became legal C in 1999. For the names of the other symbols on the keyboard, see our guide to programming symbols.

2. Comment Syntax in 25 Languages

LanguageLine commentBlock commentDoc commentBlocks nest?
C// (C99 and later)/* *//** */ by convention (Doxygen)No
C++///* *//// or /** */ (Doxygen)No
C#///* *//// (XML)No
Java///* *//** */; /// since JDK 23No
JavaScript///* *//** */ (JSDoc)No
TypeScript///* *//** */ (TSDoc)No
Go///* */// directly above a declarationNo
Rust///* *//// and //!Yes
Swift///* *////Yes
Kotlin///* *//** */ (KDoc)Yes
PHP// and #/* *//** */ (PHPDoc)No
Python#None""" """ docstringsn/a
Ruby#=begin and =end# (YARD, RDoc)No
Shell (Bash)#NoneNonen/a
PowerShell#<# #>Comment-based help in <# #>No
SQL--/* */NoneIn PostgreSQL, not in MySQL
Lua----[[ ]]--- (LDoc)No
Haskell--{- -}-- | (Haddock)Yes
Visual Basic' and REMNone''' (XML)n/a
Common Lisp;#| |#DocstringsYes
Assembly (NASM);NoneNonen/a
HTML and XMLNone<!-- -->NoneNo
CSSNone/* */NoneNo
YAML and TOML#NoneNonen/a
JSONNoneNoneNonen/a

Two traps catch people every week. CSS has no // comment, so a line starting with // makes the browser drop the declaration or rule it is attached to, with no error. JSON has no comments at all; the JSONC and JSON5 variants, used for files such as VS Code settings, accept //.

3. How Much of Real Code Is Comments

To see how comments are used rather than how they are written, we took the library source of one well-known open-source project per language: musl for C, Microsoft's STL for C++, OpenJDK's java.base module for Java, Node.js's lib for JavaScript, Vue's core for TypeScript, the Laravel framework for PHP, CPython 3.13's standard library for Python and Rust's core, alloc and std. Leaving out tests, generated files and licence headers, that is 9,001 files and 2,274,712 non-blank lines. A line counts as a comment line when nothing on it is code.

Bars of the share of non-blank lines that are comments, excluding licence headers: Rust standard library 48.4 percent, Laravel 45.6, OpenJDK 45.3, Node.js 16.2, Vue 12.5, CPython 9.6, musl 7.0, Microsoft STL 5.3.
Figure 1. Comment lines as a share of non-blank lines, with the share that is documentation comments in brackets.
LibraryFilesLinesComment linesDoc commentsOrdinary commentsCharacters in comments
Rust core, alloc, std981354,60748.4%42.4%6.0%53.3%
Laravel (PHP)1,761242,31045.6%44.6%1.0%37.7%
OpenJDK java.base3,114991,87645.3%39.7%5.6%45.5%
Node.js lib (JavaScript)435179,25116.2%7.7%8.4%23.4%
Vue core (TypeScript)23954,00512.5%5.8%6.7%17.7%
CPython 3.13 Lib (Python)559221,0979.6%none; 16.6% docstrings9.6%14.6%
musl libc (C)1,62062,1717.0%0.0%7.0%10.5%
Microsoft STL (C++)292169,3955.3%0.0%5.3%12.7%

The spread is ninefold, and the three libraries at the top are not three times chattier than the rest. They are documenting a public interface in the source itself, so the documentation website is built from the comments.

4. Doc Comments Make the Difference

Take the documentation comments out and count only ordinary //, /* */ and # comments, the kind that explain code to the next person reading it, and the libraries line up:

Bars of the share of lines that are ordinary comments, not documentation comments: CPython 9.6 percent, Node.js 8.4, musl 7.0, Vue 6.7, Rust standard library 6.0, OpenJDK 5.6, Microsoft STL 5.3, Laravel 1.0.
Figure 2. Ordinary comment lines as a share of non-blank lines. Python's docstrings are strings and are not included.

Seven of the eight libraries spend between 5.3% and 9.6% of their lines on explanatory comments, whatever the language. The outlier is Laravel at 1.0%: almost all of its comments are docblocks such as @param string $key and @return bool, which editors and static analysers read as type information.

  • •

    Rust puts examples inside its doc comments, and its test runner compiles and runs them, so the documentation cannot drift from the code. That is how more than half of the library's characters, 53.3%, end up in comments. Its ordinary comments include 2,900 that start // SAFETY:, the project's rule for explaining why each unsafe block is sound.

  • •

    Java generates its API reference from Javadoc, so every public method of java.base carries one. OpenJDK files also open with the same GPL licence header; we left those out, and they come to 85,692 lines, more than all 65,346 lines of musl.

  • •

    Python documents with docstrings, which are strings, not comments. Counted with its # comments, 26.3% of CPython's standard library is commentary.

  • •

    musl and Microsoft's STL keep their documentation out of the source: the C and C++ standards define the behaviour, and the reference pages live elsewhere. Their comments are almost all explanations of tricky code.

5. Which Comment Markers Real Code Uses

Counted per comment, so that five consecutive // lines are five comments and a ten-line /** */ block is one:

Library///* *//** *//// or //!#
musl (C)4.5%95.2%0.3%0n/a
Microsoft STL (C++)90.5%9.5%0.0%0.0%n/a
OpenJDK (Java)55.6%5.2%38.3%0.9%n/a
Node.js (JavaScript)85.7%1.4%12.9%n/an/a
Vue (TypeScript)82.1%4.1%13.8%n/an/a
Laravel (PHP)11.4%0.1%88.3%n/a0.2%
CPython (Python)n/an/an/an/a100%
Rust std (Rust)12.5%0.1%n/a87.4%n/a

C is the one holdout. // has been legal C for a quarter of a century, yet 95% of musl's comments are /* */, and our own C practice snippets use /* */ for all nine of their comments. Everywhere else // has won the ordinary comment, and /* */ survives mainly in its doc form. Java's newest form, Markdown doc comments written with ///, arrived in JDK 23 and already appears 831 times in java.base. PHP accepts # comments too, but Laravel uses them 44 times in 1,761 files.

6. TODO, FIXME and XXX

LibraryTODOFIXMEXXXHACKPer 1,000 lines
Node.js2065901.23
CPython402019711.17
Rust std0330030.94
musl19231300.88
Vue core210000.39
OpenJDK74153040.12
Laravel00000
Microsoft STL00000

Each project settles on its own word. Rust's code has 330 FIXMEs and no TODO at all, because the project's style checks reserve TODO for work that must be finished before a change is merged. CPython's old habit is XXX. Microsoft's STL has none of the four, but 573 comments that start // TRANSITION, its marker for a workaround that should go once a compiler bug or ABI limit is gone. Well-run libraries keep the count low: even the highest, Node.js, has about one marker per 800 lines.

7. Typing and Toggling Comments

You rarely type the markers to comment code out. Every major editor toggles comments on the selected lines:

EditorLine commentBlock comment
VS CodeCtrl+/ (Cmd+/ on a Mac)Shift+Alt+A (Shift+Option+A)
JetBrains IDEsCtrl+/ (Cmd+/)Ctrl+Shift+/ (Cmd+Option+/)
Sublime TextCtrl+/ (Cmd+/)Ctrl+Shift+/ (Cmd+Option+/)

On a German keyboard VS Code shows the line comment shortcut as Ctrl+#. Writing a comment is another matter: it is prose, typed like English, between code that is dense with symbols. In our 1,350 practice snippets, which keep comments short on purpose, only 102 contain one, and comments are 1.9% of the characters.

The markers themselves cost different amounts on different keyboards. On US and UK layouts / has its own key, so // needs no Shift; German and Swedish keyboards put it on Shift+7 and French AZERTY on Shift+colon. # is the reverse: Shift+3 in the US and Sweden, its own key in the UK and Germany, AltGr+3 in France. Our keyboard layout comparison covers every code symbol.

8. Method and Limits

We counted the library source of eight open-source projects at these versions: musl 7813e91 (14 Oct 2026), Microsoft STL 0cabaf3 (21 Nov), OpenJDK src/java.base/share/classes 4824e35 (28 Nov), Node.js lib a04590e (30 Nov), Vue core packages 6a04291 (30 Nov), Laravel framework src d0c5969 (29 Nov), CPython 3.13.7 Lib, and Rust library/core, alloc and std b2238fc (30 Nov). Test and benchmark folders and test files were left out. So were generated files, but only those that say so themselves near the top, as in "This file is generated by" or "DO NOT EDIT": 78 files, 65 of them Python codec tables. A tokenizer for each language skipped strings first, so // inside a URL is not a comment, then classified every comment. A non-blank line is a comment line when everything on it is inside a comment; a line of code with a comment after it counts as code. The comment block at the top of a file that mentions a licence or copyright was excluded from the shares: 92,621 lines, 85,692 of them in OpenJDK. /** */ blocks are doc comments, and in Rust, C++ and Java so are /// and //!, but not ////, the rule rustdoc uses. Python docstrings were counted separately, as strings. The counting script (Python, standard library only) and its raw output are free to download; run against the versions above, the script reproduces the library figures in this article.

Limits: one project per language, and a project's house style moves the numbers as much as its language does; another C++ library could document itself in Doxygen comments and land near Java. Libraries document their public interface more than applications do, so application code will usually have fewer doc comments. Lines treat a three-word comment and a thirty-word comment alike, which is why the character shares are given too.

9. Frequently Asked Questions

What is /* */ called?

A block comment, also called a multi-line comment or C-style comment. Everything between /* and the next */ is ignored, across as many lines as you like. It works in C, C++, Java, JavaScript, TypeScript, PHP, Rust, Go, C#, Swift, Kotlin and CSS. A block that opens with /** is a documentation comment, read by tools such as Javadoc and JSDoc.

What does */ mean in code?

It closes a block comment opened with /*. Block comments do not nest in C, C++, Java, JavaScript or CSS, so the first */ ends the comment, even one inside text such as the path src/**/*.js. Rust, Swift and Kotlin allow block comments inside block comments.

What does // mean in programming?

It starts a line comment: everything from // to the end of the line is ignored. It works in C (since C99), C++, Java, JavaScript, TypeScript, PHP, Rust, Go, C#, Swift and Kotlin, but not in CSS or Python. In the library code we measured, // made up 82 to 91% of all comments in C++, JavaScript and TypeScript.

How do you write a multi-line comment in Python?

Python has no block comment. Start each line with #, or select the lines and press Ctrl+/ (Cmd+/ on a Mac) in most editors. A triple-quoted string is a string, not a comment; at the top of a function, class or module it becomes the docstring. In Python's standard library, 9.6% of lines are # comments and 16.6% are docstrings.

What is the keyboard shortcut to comment out code?

Ctrl+/ toggles line comments in VS Code, JetBrains IDEs and Sublime Text, and Cmd+/ does it on a Mac. For a block comment, VS Code uses Shift+Alt+A and JetBrains IDEs use Ctrl+Shift+/. On a German keyboard, VS Code lists the line comment shortcut as Ctrl+#.

How much of real code is comments?

It depends on documentation comments. In eight open-source libraries we measured, comment lines ranged from 5.3% in Microsoft's C++ standard library to 48.4% in Rust's standard library. Count only ordinary comments, leaving out doc comments, and the range shrinks to 1.0% to 9.6%.

Next Steps:

  1. Learn your editor's toggle: select three lines and press Ctrl+/ (Cmd+/) until it is automatic.
  2. Type a few /* */ blocks in C typing practice and some docblocks in the PHP track.
  3. Take the coding typing test and see how your speed changes between code and the prose inside it.