How to write better code

How to write better code

Introduction

Hey there! What's Up! I'm Pierre and today, we're gonna learn what's semantics and how we can use that to write better programs. Many devs use that, even though they use it unconsciously.

Let's think about language, btw, I'm still learning this amazing language, English, so if you see any typos or mistakes, you're welcome to correct me. I'd really appreciate it. Anyway, in most languages, we can see building blocks, in English for example, we can see words. In programming the building blocks are a little bit different, we have, numbers, strings, operators, and so on. but through the language, we can say what we want.

What's semantics

But there's a syntax, a set of rules we have to follow, if we wanna sound right, for example, in English we have the grammar, in programming, we have the syntax, if I say you "cat boy dog", this sounds pretty wrong as if I said to a computer "hi"5, they are neither right nor syntactically correct. Unlike "cat hugs boy" or 3*2 they're right! This is the syntax, the structure.

We also have the static semantics where syntactically right strings have meanings. If I say "I are hungry" or "You is beautiful", you understand what I'm saying, though It's static semantic incorrect, I'd have to say "I AM hungry", "You ARE beautiful", some programming languages may verify that. On programming, it'd be like telling a computer 3 + "hi"(I are hungry) and "3" + "hi" (I AM hungry)

Semantics: the meaning associated with a syntactically correct string of symbols with no static semantic errors

image.png

How I can write better coder:

You can use that for writing better code, there're dozen of IDE extensions to help you, or even debugging, testing, making pseudocode, and refactoring your code. If you can learn more about these practices your coding skills would be so better. Btw, they're good ways to learn how to write and make better code, but they'll work just if you use them.

That's It! It's an oversimplification of course, but It may be useful if you wanna get some introduction, or even find out if you like or wanna know more about It.

image.png