Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do interpreted/scripting languages rarely have multi-line comments?

Of the interpreted languages I know (Python, Perl, R, bash), multi-line comments seem to usually involve some misuse of another feature of the language (e.g. multiline strings).

Is there something inherent to the type of parsing which interpreters do that makes multiline comments hard? It doesn't seem like it should be significantly different from, say, multiline strings.

like image 549
Xodarap Avatar asked Nov 04 '22 21:11

Xodarap


2 Answers

No, there's no reason for scripting languages to not support multiline comments. JavaScript, Groovy, Lua, PHP, REXX, Smalltalk, and Dart all support multiline comments.

like image 198
munificent Avatar answered Nov 14 '22 21:11

munificent


In truth, I'm sure there is no significance when it comes to implementing any form of multi-line comments (based on the methods that most parsers utilize to read/execute the script). In my personal opinion, scripts need multi-line comments the most because of distribution and explanation (most high level languages are usually compiled and only a percentage of it is open sourced anyways). I do know that Lua, a scripting language, does provide multi-line comments:

--[==[
COMMENT
]==]--

I'm sure it's just a fluke that many languages don't support this. It is commonly acceptable to just use single line comments to create a multi-line comment.

//*****************************************\\
//**                                     **\\
//**            JOHN SMITH               **\\
//**        COPYRIGHT 2008-2011          **\\
//**                                     **\\
//*****************************************\\

Lots of people will also utilize single line comments to create a cool image (ASCII ART) using the comment character to start off the image (kind of what is displayed above, where // is the commenting character(s)/phrase).

like image 24
Freesnöw Avatar answered Nov 14 '22 22:11

Freesnöw