How music and drawing taught me how to program

    From the translator: Yi Xian , a programmer from New York, talks about how art helps him practice coding.

    Programming is akin to art. At the same time, other types of art, in particular, music and drawing, can teach a programmer a lot. I hope that they will help you just as they helped me in due time.

    Skillbox recommends: A two-year hands-on course “I am a PRO web developer .

    We remind: for all readers of "Habr" - a discount of 10,000 rubles when writing to any Skillbox course on the promotional code "Habr".

    Focus on the basics

    What do we learn?

    If you like the algorithms, I mean, really like, like the fact that early in the morning you immediately begin to engage in recursion and segment trees, congratulations. You are a pure programmer. But we, the rest, are ordinary people, sometimes we ask ourselves: why solve these puzzles? Only to successfully pass the interview?

    In fact, when you practice something, you need to understand why you are doing it. Want to acquire certain skills? Or strengthen weaknesses?

    I believe that all these puzzles for programmers not only provide specific knowledge, but also better understand the basic elements of the process of creating and writing code. Get or improve basic skills.

    As for the puzzles, they are needed not to solve a problem, but to study the process of finding a solution. These are different things.

    What do you do with a problem - break it into small parts? What helps you to improve your level? What is the difference between some database structures and others? Basic skills are akin to the basic harmonics on which the sonata is built.

    What do experienced professionals know?

    I would say that an experienced artist does not know how to paint Central Park in New York in the fall. But he knows the basics that are needed to create a picture. Using them, he paints a landscape, and as a result it turns out an amazingly beautiful picture.

    An experienced artist does not know how to draw leaves on trees. No, he has a good command of colors and their combinations. He knows how colors behave on the canvas.

    So an experienced programmer does not have to know all the nuances of React, Vue, Ember or other frameworks. An experienced programmer knows how JavaScript works and how a browser works. An experienced programmer understands the benefits of functional programming, he knows why, in a particular case, it is necessary to put React at the forefront.

    Learn the basics, and everything above will form a clear picture of itself.

    Life sketches

    Kopipast vs source

    My familiar artists who are serious about their craft, always make sketches of life. What does it mean? They draw everything they see, everything that interests them.

    They do not draw a photo or model, but draw what they themselves see.

    When someone sketches a landscape from someone's picture, he does not invent, but copies. In programming, the equivalent of this behavior is copy-snippets with Stack Overflow.

    Copy-paste code will never give you the opportunity to get fundamental knowledge. Copying someone's code has a similar meaning: you get a solution, but not experience. Win a battle, but lose the war.

    Universal knowledge

    Fundamental knowledge can be called universal. If you try to solve the problem yourself, you are mistaken and in the end you find a solution, then you get just such knowledge. You learn the principles of work that can be used in future projects.

    Rarely are common decisions when “one size fits all”. In order to get the keys to different locks, you have to work. Sometimes it is useful to do the work without the influence of someone else's decision, independently.


    Purposeful Repeat

    When a musician studies a work, he does not just try to play it from beginning to end, again and again, thousands of times. He searches for weaknesses in his work and liquidates them.

    Otherwise, the performance will be far from ideal, contain the wrong notes (in the case of programming - bugs).

    And although blind repetition is not the best way to learn something, purposeful repetition allows you to get the right experience. You work on your weak points and get better.

    And for a beginner and blind repetition is useful. It develops muscular memory, which in the case of programming can be considered cognitive abilities. After that, you can go to the complex works.

    High level job

    If you are new to using any framework, practice it. Learn its basic elements, create something basic.

    Select a port, create a route, send a request and respond. Then repeat this.

    When the musician finishes studying the difficult part of the work, he does not shake hands and does not speak for himself: aha, well, this is finished. No, he repeats it to eliminate the possibility of an error.

    It’s the same thing with a programmer: if you write a complex program, solve a problem, you can skip the simplest error in the syntax, after which the whole mechanism will refuse to work. We'll have to look for a problem. If, however, to work out the syntax to automatism, the likelihood of a problem decreases.

    Then you do not have to worry. A musician who has brought his skills to automatism will not worry about the reproduction of individual notes of a concert. It focuses on the melody as a whole, and not on its individual elements.

    Training and Sketches

    An example of da Vinci

    If you have ever studied the work of really great artists, for example, Leonardo da Vinci, then you probably know how many sketches, sketches, training canvases they made. Leonardo was famous for his attention to detail - he made sketches of body parts, plants, animals, people and their groups.

    Novice artists also practice a lot, for example, they constantly paint still lifes. But why, because they are not nerds? No, this is all targeted training. Beginners gain experience and knowledge in working with color, light and shade.

    Some programmers work in a similar way, breaking one big problem into several small ones and then working on them all.

    Programmers Sketchbook

    How can you remember this function, in what context is it used? Do I need to call super () in every component of React, or is it worth learning a bit about ES6 classes? How to integrate asynchronous HTTP requests?

    You can understand all this by opening Repl or JSBin. Small studies can deepen the understanding of more common things, learn how to work with large projects.

    When an artist draws an apple or a tree, this does not mean that a particular object is of interest to him. He just works a little to use the experience on a big one.

    Look at the hands of Gioconda - they are perfect in terms of technology.

    Portraits and dependency trees


    I think that the main task of many ends (including programmers) is composition. It is about how to combine the particular into a whole in such a way that it is a masterpiece.

    There are several methods to achieve this. One of them is to start with a layer with a minimum of dependencies. And already from this base layer go up.

    If you draw an analogy with the artist, he does not start with the eyelashes. He starts with a primer. The same eyelashes, their location depends on the shape and size of the eyelid. The eyelid is dependent on the size and position of the eyeball, which, in turn, is associated with the peculiarities of the structure of the skull. The whole portrait, if we are talking about a portrait, is a multitude of dependencies.

    If one element is positioned incorrectly, the impression of harmony and integrity disappears. The same with the software project. Having made one mistake, you start to produce entities that spoil all the work.

    Layer by layer

    When you create a full-stack application, take care of the data layer. Do the tests. Check all items. Only in this case, you can be sure of the reliability of the entire project. But initially it is necessary to understand its essence and see the whole picture. If you have an understanding, you can work on the details.

    Coders - coding

    To each his own. Musicians - music, artists - paintings. Programmers - code. We started the article with the words that the work of a programmer is also an art. And indeed it is. It is worth remembering only that skill can and should be improved by practicing, studying and researching. With the help of practice, novice programmers will be able to focus on the basics, improve their creations and eventually create a cool project as big as the creator’s ambitions.

    Also popular now: