Syntax, Comment and File Extension: Demystifying Best Programming Fundamentals (2023 Guide)

VIEW

Last Updated: September 25, 2023

Syntax, Comment and File Extension: Demystifying Best Programming Fundamentals (2023 Guide)

What’s On This Page

Introduction

Before one can write a whole novel in the English language, one must first master the alphabets and move to sentence constructions. Same with coding. Mastering the basics sets the stage for writing robust code. Syntax, file extensions and comments may seem like technical jargons, but they’re the foundation of clean, efficient programming. This post will make these crucial concepts plainly understandable and reveal their pivotal roles in code development. Join me on this enlightening trip to deepen your understanding and elevate your coding skills.

Pro-tip:

Join us on a 14-week journey to master these 5 essential EE engineering programming languages:C, C++, Python, Matlab and Assembly. Click on the link below
https://bit.ly/3sTV8Up

File Extension

File Extension is exactly what it is called: “a file extension”. It is an add-on to the file itself. In general, every file needs an extension. This tells the computer the type of file it is dealing with.

Think of it as you having several exercise books on a table. Without opening them, how can you know the right way to handle each? That’s where the title block comes in. You try to scan the subject area to see if there is any info that can give you an idea about the content of the book.

Similarly, computers have a simple job: to receive, process, output or store data. These data come in files which require specific application /software to properly process them. That’s why the computer first needs to know the kind of file, so it can use the right app or tool to execute the instructions. This even avoids confusion.

I know you are familiar with the common ones; jpg, png, svg, jpeg for image files, doc, docx, txt for text/document files, and mp4, mkv for video files. Let’s concentrate on our interest.

If you want the computer to recognize your saved file as containing a particular programming language and treat it as such, then this is how you need to save that file.

As a case study, let’s use “main” as the file name.

For C, the source code: main.c

For C++, the source code: main.cpp or main.cxx

For Python, the source code: main.py

For Matlab, the source code: main.m

For Assembly, the source code: main.asm


Comment or Commenting

Commenting is a fundamental ground in programming. Knowing it doesn’t only help make your code readable, but also aids in debugging (correcting errors in code).

The compiler (program executing the code) overlooks everything designated as a comment when it’s executing. This means the practice is not for the computer, but you the human to interpret the computer language to a human one so anyone with access to the code (including yourself) can easily understand and follow through.

Comments serve as a form of documentation for the code. They explain the purpose of specific lines or sections, making it easier for developers to understand and maintain the code in the future.

In a team setting, comments are crucial for effective collaboration. They allow multiple developers to work on the same codebase, understand each other’s contributions, and make changes or fixes as needed.

When encountering unexpected behavior or errors, comments can provide insights into the intentions behind the code. This helps with the debugging process, allowing developers to pinpoint and resolve issues more efficiently.

Comments can temporarily disable lines or blocks of code. This is useful for testing alternate solutions, debugging or isolating specific sections without deleting them.

Well-commented code is considered a best practice. It reflects professionalism and thoughtfulness in code development. It also allows for easier code reviews and ensures that others can understand and maintain the code in the future. In industries with strict coding standards or regulatory requirements, comments can be necessary for compliance. They demonstrate adherence to best practices and can serve as an audit trail for code changes.

Comments can capture institutional knowledge that may not be immediately obvious from the code itself. This is especially important when team members change or when code is revisited after a longer period.

A well-structured and well-commented code is easier to read and navigate. It allows the developer to focus on understanding the logic of the code rather than deciphering what the code even means.

In summary, comments serve as the means of communication with the codebase where the developer can provide context and explanations.


Syntax

Conclusion