Comment Addendum to Intro to Coding: Part 1 - Create a Script

  • As mentioned in my previous post: Comment Addendum for Intro to Coding: Functions 2 - Instances and Particles, this is Part 1 of the comment series.
  • I am looking for someone to review my comments (“code”) for technical accuracy and semantics. Please keep in mind I am learning this stuff myself; I am not a professional developer. Although I do have an instructional design background, I am simply looking to fill the gaps of the tutorials with information that I find particularly useful when new terms and jargon are introduced.
print("Hello world!")

-- The print("Hello world!") statement is automatically generated by Roblox 
-- Studio when a new script object is created, such as this script file. 

-- COMMENTS, INTERPRETERS, and COMPILERS:

--[[ Comments are lines of code that are ignored by the Lua interpreter.  
Generally speaking, an interpreter is a program that converts the 
easy-to-read Lua script code (or any other interpreted programming 
language such as Python) into executable code and then executes it without the 
need to for intermediate "middle-men".  The interpreter is typically installed
with the program that executes it, such as Roblox, Roblox Studio, or, in the 
case of Python programmjing language, Python.  Without the interpreter, 
program code cannot execute and exists only as plain-text script files or 
underlying support files.

Interpreted languages exist in contrast to traditional compiled code, such 
as C or C++ or C# programming languages, which require a compiler to 
translate easy-to-read programming code into lower-level assembly code or 
machine code (or both). Compiled code is converted from one file type, 
such as "my_program.c", into an executable program such as "my_program.exe" 
(exe is the file extension for executable programs in Microsoft Windows). The 
compiler will compile the code into executable code that is compatible with 
the underlying system hardware and operating system (OS); otherwise, the 
program cannot execute on the system.  For example, a program compiled for
Microsoft Windows will not execute on a system running macOS and vice versa,
at least without some kind of emulator or third-party program.

Why the need for two different types of languages? Well, "in the old days", 
compiled languages were much faster when executed.  This speed advantage had
its own trade-offs; to acheive execution speed, compiled programs require 
the time to compile and then the compiled file(s) need to be distributed to 
end-users, and finally installed on the compatible systems.  Updates to a 
compiled program required re-compiling, re-distributing, and re-installation
in the form of a complete re-install or a software update.  While the steps
performed are somewhat lengthy (the internet has helped decrease updates and 
distribution speeds dramatically!) the performance payoff was great.  Fast 
forward to today, compiled programs retain their performance payoff but not
by much.  Interpreters are compiled programs so the interpreter such as 
Roblox Studio or Python just need to be installed periodically.  The scripts 
that the interpreters run can be updated on-the-fly without any down time.  
Thanks to improvements in the underlying hardware, interpreted code can be
interpreted very quickly.

Almost all programming languages support the use of comments.  As mentioned
above, comments are ignored by the interpreter (or in the case of compiled
languages, the compiler).  In Lua syntax, single-line comments are designated
with the double-hyphen -- .  As a best practice, a single-line of code should 
be no longer than 80 characters.  This is actually a throw-back to the very 
old days of programming when punch cards were used to program. These cards 
werecomprised of 80 columns and multiple rows.  When monitors came on the 
scene,the terminal windows that displayed code preserved this limit as well!  
If your lines of code exceed 80 characters, it is good practice to separate 
thecode into multiple lines. Lua provides the multi-line comment syntax that 
beginswith two hypens immediately followed by two opening square brackets:
--[[ . Any text following the opening square brackets will be commented out 
until the comment is ended with a pair of closing square brackets, ]]

--[[ Although are not required, in Lua, it is good practice to precede the 
closing square brackets with double hyphens --]]

-- BACK TO THE SCRIPT:

--[[ Begin your script with a short description detailing the purpose of 
the script.  While you may remember why the script was created right now, 
a few months from now when you revist the script, the description may 
provide valuable insight into your own logic.  In addition, if you plan 
on working  with other developers on your project, comments will help them
gain some insight into the design, logic and flow of your decision-making, 
and why decisions in your script and its code were made. Example below: --]]

-- SCRIPT SUMMARY:

--[[
*** This is Intro to Coding 1: "Create a Script".  In this tutorial,
*** developers are introduced to script files and supporting details.
--]]

-- SCRIPT LOCATIONS:

--[[ Scripts can be created in almost every location in Roblox Studio.
All of these locations, use-cases, advantages and disadvantages will be
covered in later lessons.  Typically, scripts are stored in: 
ServerScriptService for server-side scripts, ReplicatedStorage for 
client-side AND server-side scripts, and ReplicatedFirst or 
Starter{Player | Pack | Gui} folders for Client-side (local) scripts.
--]]

--[[ This particular script should be stored in the ServerScriptService 
folder in Roblox Studio.  ServerScriptService is a "special" folder that is 
designated for the ServerScriptService API.  APIs will be covered later.  
Suffice to say the ServerScriptService folder uses the ServerScriptService.  
Scripts in the ServerScriptService location are run solely on the server - 
not the client, meaning the individual player's system.  Per the Roblox API 
documentation, this "allows for the secure storage of important game logic".  
When the service runs, such as when you press "Test and Play" in 
Roblox Studio, the scripts and code in this container are automatically 
executed. --]]

-- SCRIPT BEST PRACTICES:

--[[ A best practice is to rename your scripts.  Per Lua and Roblox best
practices, rename your scripts using PascalCase, where the first letter
of each word in your label is upper-case.  Examples include:
ThisIsPascalCase, SoIsThis, and This. Names should be short but descriptive,
such as DestroyFirePart, RespawnCharacterAfterLavaDeath (assuming there are
multiple scripts for respawning characters; otherwise RespawnCharacter 
is preferred!) --]]











3 Likes

BRUH, we can also know this is the blog from roblox studio

Do you mean without the need for an intermediate "middle-man"?
Also, can you clarify what the middle-man is?

Typo

Other than that, the info in your tutorial about compilers and interpreters looks to be correct. Note that I am also not a professional programmer, so you may need to get more opinion on this.