Qiita Conference 2025

こにふぁー (@konifar)

提案のレベルを上げる - 推進力のあるエンジニアになるための思考法

1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

コメントアウトのフォーマットランキング (Monaco Editorのコード調べ)

Posted at

ソースコードのコメントアウトの形式って言語ごとにいろいろありますが、どういう形式が一番使われてるのか気になったので調べてみようと思いました。

Monaco Editorのソースコード見ると、https://github.com/microsoft/monaco-editor/blob/495d075be0f9e134fe659c0210cb777372c61899/src/basic-languages/typescript/typescript.ts#L12 のように、言語ごとにコメントのフォーマット書いてあるのでこれを集計します。

(VSCodeで調べたほうがもっと良い結果を得られると思いますが、スクリプトでチャチャっと調べるのはCDN使ってMonaco Editorをロードしたほうが楽だったのでこうしました。)

ラインコメント

単一行コメントのランキングです。

  • 1位: // ...
    使用言語数: 38 (言語Id: apex, bicep, cameligo, c, cpp, csharp, cypher, dart, ecl, flow9, fsharp, go, java, javascript, kotlin, less, msdax, objective-c, pascal, pascaligo, php, postiats, powerquery, proto, pug, qsharp, rust, scala, scss, sol, aes, st, swift, systemverilog, verilog, typescript, typespec, wgsl)
  • 2位: # ...
    使用言語数: 16 (言語Id: azcli, coffeescript, elixir, graphql, hcl, ini, mips, perl, pla, powershell, python, r, ruby, shell, sparql, yaml)
  • 3位: -- ...
    使用言語数: 5 (言語Id: lua, mysql, pgsql, redshift, sql)
  • 4位: ' ...
    使用言語数: 2 (言語Id: sb, vb)
  • 5位: ; ...
    使用言語数: 1 (言語Id: scheme)
  • 5位: ;; ...
    使用言語数: 1 (言語Id: clojure)
  • 5位: * ...
    使用言語数: 1 (言語Id: abap)
  • 5位: COMMENT ...
    使用言語数: 1 (言語Id: lexon)
  • 5位: REM ...
    使用言語数: 1 (言語Id: bat)

ラインコメントなし
言語数: 17 (言語Id: csp, css, dockerfile, freemarker2, handlebars, html, julia, liquid, m3, markdown, mdx, razor, redis, restructuredtext, tcl, twig, xml)

ブロックコメント

複数行かけるコメントのランキングです。

  • 1位: /* ... */
    使用言語数: 37 (言語Id: apex, bicep, c, cpp, csharp, css, cypher, dart, ecl, flow9, go, hcl, java, javascript, kotlin, less, msdax, mysql, objective-c, pgsql, php, powerquery, proto, redshift, rust, scala, scss, sol, aes, sql, swift, systemverilog, verilog, typescript, typespec, vb, wgsl)
  • 2位: (* ... *)
    使用言語数: 6 (言語Id: cameligo, fsharp, m3, pascaligo, postiats, st)
  • 3位: <!-- ... -->
    使用言語数: 4 (言語Id: html, markdown, razor, xml)
  • 4位: ### ... ###
    使用言語数: 2 (言語Id: coffeescript, mips)
  • 5位: --[[ ... ]]
    使用言語数: 1 (言語Id: lua)
  • 5位: ''' ... '''
    使用言語数: 1 (言語Id: python)
  • 5位: { ... }
    使用言語数: 1 (言語Id: pascal)
  • 5位: {{!-- ... --}}
    使用言語数: 1 (言語Id: handlebars)
  • 5位: {/* ... */}
    使用言語数: 1 (言語Id: mdx)
  • 5位: {# ... #}
    使用言語数: 1 (言語Id: twig)
  • 5位: #| ... |#
    使用言語数: 1 (言語Id: scheme)
  • 5位: <-- ... -->
    使用言語数: 1 (言語Id: freemarker2)
  • 5位: <# ... #>
    使用言語数: 1 (言語Id: powershell)
  • 5位: =begin ... =end
    使用言語数: 1 (言語Id: ruby)

ブロックコメントなし
言語数: 24 (言語Id: abap, azcli, bat, clojure, csp, dockerfile, elixir, graphql, ini, julia, lexon, liquid, perl, pla, pug, qsharp, r, redis, restructuredtext, sb, shell, sparql, tcl, yaml)

あとがき

僕がSQL書いてる時ときどきうっかり//ってコメントアウトしちゃうのは//が圧倒的にメジャーだからいけないんだ!という言い訳の材料にできそうです。

にしてもブロックコメントの種類多いな。

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

@ota-meshi's pickup articles

ota-meshi

@ota-meshi(ota)

会計パッケージ開発10年、独立系SIer10年経験。主にフロントエンドエンジニアやってます。ES6+、TypeScript、Java8+、Vue、Svelte、ESLint、Stylelint、Vite、Webpack。会社のOSS CheetahGridのメンテナ。Vue、Svelte、Stylelint、ESLintのメンバー。自分の備忘録としても使うので小さい情報も書いていきます。

Comments

nmcr5575
@nmcr5575

コメントアウトのフォーマットランキング

ソースコードのコメントアウトの形式

コメントアウトとは、コードとして認識されないようコメント化する行為を指す言葉であって、コメントと同義ではありません。

0

Let's comment your feelings that are more than good

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details

Being held Article posting campaign

1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Login to continue?

Login or Sign up with social account

Login or Sign up with your email address