A list of Comment Syntax in Popular Programming Languages

Recently I had to look up how to write a comment in Python. Since I mostly develop in PHP, I had to turn to Google to find the exact syntax for commenting in Python.

At that time I got an idea that it would be cool to have a single resource which lists commenting Syntax for various Programming Languages. Thus this post was born :)

Enjoy :)

 

PHP

// This is a Comment in PHP

 

 

Python

# This is a comment in Python

CSS

/* This is a comment in CSS */

 

HTML

<!-- This is a comment in HTML-->

 

Javascript

// This is a comment in Javascript

 

ActionScript

// This is a single line comment in Action Script
/* This is a multi-line comment
in ActionScript */

 

Ruby

# This is a comment in Ruby

 

Assembly Language

# This is a comment in Assembly Language

 

Apple Script

-- This is a comment in Apple Script

 

Bash Script

# This is a comment in Bash Script

 

C #

// This is a comment in C #

 

VB

' This is a comment in VB

 

XML

<!-- This is a comment in XML-->

 

SQL

-- This is a comment

 

/* this is a comment in C. This comment syntax is guaranteed to work on every compiler */ and 
// This is also a comment in C. but it might present portability challenges
Source: Link

 

Fortran

! This is a comment in Fortran

 

Java

// This is single Line Comment in Java
/* This is multi line comment.
in Java
*/

 

Erlang

% This is a comment in Erlang

 

Objective C

/* This is a comment in Objective C */

 

CoffeScript

# This is a comment in CoffeScript

 

Clojure

; This is a comment in Clojure

 

Swift

// This is a comment in Swift

 

Perl

# This is a comment in perl

Matlab

% This is a comment in Matlab

 

Scala

// This is single Line Comment in Scala
/* This is multi line comment. 
in Scala
*/

 

Pascal

{*This is a multi-line comment
  in Pascal and it will span multiple lines*}

{This is a single line comment in Pascal}

 

About Ankit

Founder of Spice Forms.
Spice Form is a Drag n Drop tool to create powerful web forms in minutes.

Comments

  1. Programming language expressions can be broadly classified into four syntax structures:

    prefix notation
    Lisp (* (+ 2 3) (expt 4 5))
    infix notation
    Fortran (2 + 3) * (4 ** 5)
    suffix, postfix, or Reverse Polish notation
    Forth 2 3 + 4 5 ** *

  2. PHP Multi Line Comment:
    /* This Echo statement will print out my message to the
    the place in which I reside on. In other words, the World. */
    Refer: http://www.tizag.com/phpT/comment.php

    @Ankit, Maybe you can add multi line comments to this list too!

    Btw, really appreciate the work!

  3. i really got to know this ,
    Appriate

Speak Your Mind

*