Let's start the year programming

It is surprising the reception that the good Mario And to tell the truth, it is the first article that I publish that generates more than 10 thousand views, this puts the fence somewhat high for the following ones and I hope not to disappoint you with this 🙂 Thank you very much for finding my writings interesting enough to share them by the way 🙂

Programming Languages

This is a fashionable topic, everyone wants to program, or at least everyone thinks that it is an increasingly necessary skill, and to tell the truth I would like to write a whole book on programming, GNU / Linux, security, and maybe at some point I can, just learn how to write free books and nice format 😛.

Technology advances rapidly

This is one of the reasons why I have not written the book yet 😛 since I want to do something that can overcome the barrier of time in a field where things do not usually last more than a few days in the current way. That is why in this article I want to tell you a little about the concepts rather than the implementations, in this way we can reread these lines in a while and they will continue to be valid.

The principles last longer

Although there are many programming languages ​​today, many of the concepts can be traced back to the same origins. By this I mean that many of the things that are learned today have been valid for a long time, and probably will continue to be, this because programming is done by people and as long as they continue to develop, some concepts will remain.

Knowing the basics

Many courses already exist, some free and some not, that expose much of the syntax of many of the most popular programming languages ​​today. But we are not going to do this here 🙂 I want to tell you a little about what every programmer should think before starting to program in order to do a decent job.

Entering the mind of the programmer is certainly something necessary, already in a somewhat old article we discussed the theme. Now we are going to go into the concepts that allow us to write the code.

Variables and functions

The variables are memory spaces, let's think about the mailboxes that large buildings have, they are designed to store certain types of objects, there are large and small ones, they can be alone or in groups. A variable is a value that you know will be used over time, although you do not exactly know its value in the beginning, if you know it and you know that it will not vary, we are facing a constant.

Functions, on the other hand, are sets of instructions. An instruction is the most basic thing that a processor can do, the reason for being of the functions is to allow the programmer to group sets of orders to be able to repeat them throughout a program. Let's see a simple and detailed example.

Own. Christopher Diaz Riveros

This is a small program written in C, we have the function hand, The variable saludo, and the function printf that comes from the library stdio.h. Let's modify the example a bit and then compile it to see what happens.

Own. Christopher Diaz Riveros

We have added a little function called saludar which takes as an argument a variable called saludo and prints it. This does not change the final result of the program much but it allows us to show a great and useful principle of programming, the abstraction. Let's see the result:

Own. Christopher Diaz Riveros

A simple program, which is full of knowledge and work.

Libraries

The reason I created the function saludar it was simply to show one of the greatest principles of software development, which we have already named: abstraction. Just as we have defined saludarprintf() has been defined somewhere in our operating system (the GNU standard C library), this place is commonly known as a library / module / library. Libraries are sets of functions that allow us to add functionality to our programs without having to reinvent the wheel. In this case, thanks to printf We don't have to worry about all the logic necessary to be able to display the message we want in a terminal.

Libraries are present in almost all current programming languages, since having sections of code to choose from and implement is easier than creating each function from scratch.

Abstraction

Imagine the mail system, we do not need to know all the necessary logistics to send or receive a letter, the same happens with programming, abstracting is essential to generate durable and elegant code. This process allows you to use names general to define processes general  In other words, if we create the function enviarCarta() we know in a way general that said function will take care of sending a letter, but not necessarily what steps are required to do so. And this is another point why abstraction is so good, since it allows us encapsulate process segments.

Encapsulation

Our role saludar It is a clear example of encapsulation, it allows us to have a closed block with specific instructions that we can use one or a thousand times within a program. This makes the code easier to read and easier to debug since if an error arises, we know exactly what the limits of our function are, and we know each statement in a small space. This brings us to a fairly common programming principle in UNIX

Do one thing, do it very well

A good function is one that only It does one thing, but it does it very well. Let's think about this for a moment ... enviarCarta() it would probably do a lot of things, which can't be good if we want to debug the process, while saludar() only does one. Over time, if problems arise, the second will be easier to repair than the first. An option to avoid this problem would be to generate different levels of abstraction for enviarCarta(), this means that within the function there would be others such as verificarSobre() and maybe inside this one like verificarRemitente(). Ultimately this last function (verificarRemitente()) is much more specific than just enviarCarta() and in this way we can encapsulate parts of the code so that they do what is necessary and only one thing at a time.

Practice

Learning the art of programming requires practice, and since I have now taken a very general look at the subject, it is necessary for you to practice with various languages, or various problems. First trying to generate specific functions, then increasing the complexity. As always, if doubts or suggestions or comments arise, they help me a lot to know which aspects to reinforce. Thank you very much and may 2018 be full of successes and amazing projects. Cheers


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Juanjo said

    I am passionate about linux since I changed from windows thanks if you already program in bash and c for system calls thanks

    1.    ChrisADR said

      Great Juanjo! Keep it up 😉 maybe before you know it you'll be helping free and open source software projects around the world. a greeting

  2.   Rodrigo said

    Very interesting, but when I am also about to take my first steps in programming and I am planning that 2018 is the year in which I learn to program. Almost as if you had smelled the ethereal air of the web.
    Thank you for this article, I hope you can enlighten us more on computer security issues that are sorely lacking in computer minds.

    regards

    1.    ChrisADR said

      Hello Rodrigo, because certainly this 2018 will be full of articles on programming and security, as long as I get a job that allows me to do it 😛 but in the meantime I can assure you that the first half of the year I will be able to write often, at least until I finish my studies hahaha

      Greetings and good luck with your purpose of learning to program this coming year 🙂

  3.   Ernest William Vitali said

    Thank you very much for writing such an interesting article. You are a very good teacher.
    The article about Mar.io is going to transcend more than you suspected. It is excellent and very well written.
    Happy New Year!!!
    EG Vitali

    1.    ChrisADR said

      Thank you very much Ernesto, very kind words.

      Certainly it has been more than I thought it would be, and that motivates me to keep writing more and better, and I'm certainly looking for a place where I can do a teaching job, it would be something very rewarding for me and I suppose it would give me the opportunity to write more topics about programming and security and other things that curiosity always brings to mind 🙂

      Greetings and happy new year too 🙂

  4.   Tecprog World said

    Very good post my friend, many greetings from Lima - Peru, we also trust that programming improves people's lives, hoping you continue to publish more entries, we say goodbye, a hug.

    1.    ChrisADR said

      Thank you very much and surely more entries will come, I hope to make a complete series to prepare readers for the collaboration of free software projects. Greetings and successes this 2018

  5.   Anonymous said

    Keep it up, greetings.

  6.   Ricardo said

    The post is brilliant… greetings from Paraguay… hoping that 2018 will be a much better year than the previous ones… that all personal projects come out… and that you continue to contribute with your knowledge… Successes !!!

    1.    ChrisADR said

      Hello Ricardo, thank you very much for the greetings, I certainly hope to continue sharing, surely this year there will be several articles 😉 successes for this 2018 too! Cheers

  7.   JorgeFS said

    What a mania for the Spanish-speaker to say library in reference to «library». They are code libraries, not libraries.
    Greetings.

    1.    ChrisADR said

      hahaha thanks for the information Jorge, unfortunately in Peru we call them libraries, but also modules, although certainly library is more successful, I'll see if I can adjust the text to make it more correct 🙂 Greetings and happy 2018

  8.   aanxhel said

    Very good introduction to programming,
    I hope and you keep making more contributions like this.

    1.    ChrisADR said

      Thank you very much and I hope I can make a complete series, greetings and happy new year!

  9.   damian garcia said

    The article is very good, I just want to contribute something more about my first contact with programming and how practicing it is fundamental. Who is interested in the link is the following http://bit.ly/1HBRCfx
    I hope you find it interesting. Greetings, happy beginning of the year and programming.

    1.    ChrisADR said

      Thank you very much Damian, I had never read the article, or anything on the page, but it looks interesting actually. Thank you very much for sharing, greetings

  10.   Bertin Osborne said

    In my time void main was used, what things, although it was in msdos and the return value did not matter.

    1.    ChrisADR said

      Hello Bertín 🙂 certainly the void main is maintained, it can be used depending on the complexity of the program today, in the same way the return value, but today it is better to continue with the development and the best practices to be able to have software that can be read by more people, as this is vital in community software environments. Greetings and thanks for sharing

  11.   José said

    Your contributions are very good, I hope you continue, this 2018 I want to start programming, the help is appreciated