Can I develop many things after I have learned the C language?

Source: Internet
Author: User

Original post address: zhihu

A person asked such a question in zhihu, and Tao Wu answered the following question.

 

Mario turned into a flower.

What is Mario? A rectangle with 16 × 32 small color blocks, some of which are filled with colors, and others are not. What is flowers? A 16 × 16 square. What is "transformation 」? Turn the brown color in the square of Mario into red, and the red color of the bib into white. What is brown? For the moment, it is a number 0x887000. What is "met 」? Mario's rectangle overlaps the square of flowers. What is "Overlap 」? Suppose this square of Mario occupies the screen (what is the screen? A rectangle that can hold 256x240 small color blocks) in the area between 101 to 116 in the X direction and 21 to 52 in the Y direction, so long as one or more points in this area are also occupied by Flowers (for example, the flowers are in the area between X 116 to 131, and y 21 to 36), we think they overlap.

If two rectangular regions are given with eight values, write a C language program that determines whether the two regions overlap. If you can write it out, congratulations. If you want to write the NES version of "Super Mario" one day, you should at least know what needs to be done to make him transform.

Yes, the C language may be "only" for maths. However, the vast majority of games are running on a constant basis, and the so-called game writing means converting the game's rules and effects into mathematical problems. Many computers have already known how to solve these problems. Other programmers have told them in advance. For example, "ask for a pile of polygon dispersed in the three-dimensional coordinate system at 8 (x−3) −10 (Y + 1) −11 (Z-1) = 0: A projection in a given range on the plane. "or" some vertex connected to each other, find the shortest path between any two points. It takes only one thousandth of a second to solve the problem. What is the purpose of this capability? The fundamental activity of FPS games on computers is to constantly seek the projection of the polygons under the three-dimensional coordinate system on the two-dimensional plane after transformation, and constantly determine whether the two polygons overlap with each other, and keep searching for the shortest path between two vertices, so that the monsters can rush to you and bite you. More than games, other software is similar, and every detail is a mathematical problem-for example, the blue navigation bar background at the top of the page, it is a gradient from the light blue to the dark blue described by CSS-what is the gradient? Two numbers are given to represent the two colors, and the third digit represents a distance, and the numbers and order of a series of colors are obtained to minimize the variation between the two adjacent colors. Math problems. Not to mention the C language, all programming languages can only do mathematical problems, according to the given data, calculate other data, calculate more data, and then store, send or present the calculated data.

But I can understand your confusion. After spending a lot of time reading the tutorial, only a string of numbers can be output in the black box. Does this mean learning programming or paying tribute to 1970s? Is programming an activity that does not give people a sense of accomplishment? Yes, no. Looking at your statement, it should not be a child, because the child will not have a sense of accomplishment because of the few things that the beginner programming can do, or the child who feels that this does not have a sense of accomplishment will not continue to learn. At first, the sense of accomplishment in learning programming simply came from "I can actually direct machines to do something 」, at least when I was a child, I used the Chinese learning machine to compile a program to help me calculate the four arithmetic questions in my summer homework. Writing these programs and using them to solve problems is far more time-consuming than having to write them out. At that time, I still didn't know that the transformation of Mario will come from programming, so I wouldn't want to learn programming.NoWhat to do 」.

However, after a certain age, it is difficult for most people to drive their own programming by the simple and original joy of "I can direct the machine. I have met the world, heard rumors, and my desires and ambitions have become complicated and huge. You want graphic interfaces, music sound effects, AI, and cloud synchronization, but you have learned a few lessons, you can only show a string of numbers in the black box. You suspect that this is a mistake in learning C language, so you have come to know this question.

Your doubts are justified.

If you can learn programming, you will understand in the future that any program is an iceberg, and the interface and functions that the end user can see are only a tenth of the program floating on the water. Zhihu, this website is actually a program running on a computer. What is the tenth you can see written on? HTML, CSS, JavaScript, or objective-C. What are the nine in ten that you cannot see written in? Python. These unobserved Python programs run on some computers in a certain corner of the world, injecting life into your front or palm user interface through optical cables, twisted pair wires, and wireless base stations.

Http://xkcd.com/353)

...... But what is Python written? C language (of course, this is not rigorous. python can be implemented in any other language in theory, but it has already been implemented in many other languages, but this is not the focus ). Any programming language is a tool for implementing a certain function. Python implements most of the functions of this website, while c implements the "write programs with Python" function. Why c?

C is awkward and flawed, but fails. Although there is a coincidence in history, it is indeed because it can meet the needs of such a system implementation language: it has a considerable efficiency to replace the assembly language, it is abstract and fluent enough to describe algorithms and interactions in various environments.
C is quirky, flawed, and an enormous success. although accidents of history surely helped, it evidently satisfied a need for a system implementation Language efficient enough to displace assembly language, yet sufficiently abstract and fluent to describe algorithms and interactions in a wide variety of environments.
-- Father of C language, Dennis M. Ritchie


C is the language used by the first generation of programmers. At that time, the hardware was very expensive and the software had to be efficient. Computer users were professional programmers who had enough knowledge about the hardware. C is close to hardware, which means it is easy to translate into a language that machines can understand, and its designers do not have to worry about the difficulties that ordinary people may learn -- and, to be honest, in fact, it is not very difficult. However, after so many years, the scale of software has become larger and larger, and C is like a hammer and a hand saw. It is easy to build a passenger's cabin and it is not enough to build a skyscraper; however, the C language can be used to create other tools that are more suitable for building a skyscraper, and even make up the prefabricated parts of a skyscraper. It is like using a hammer and a hand saw to create excavators and cranes, concrete slabs, and integrated doors and windows (of course, this analogy is not very relevant. But there is no analogy to describing software engineering, because software engineering is like a lot of things, but nothing like it ).

So, back to your question, yes, learning the C language can really develop a lot of things, but unless the internal force is deep, the situation is appropriate, and it hurts, most people do not use C or just use C to develop too many things. If you only want a language that allows you to "edit a game or software" and use windows, we recommend that you switch to C #. It looks very similar to C, but can quickly write at least a program with a graphical interface, which is also very convenient to use, A mouse click can give you a more intuitive impression on what your program looks like. In addition, C # textbooks are quite easy to find in China. Of course, python is also a good choice.


In addition, there is one more thing you must understand: the so-called modern programming activity, in fact, most of the time it is "reasonably piling up functions already implemented by others to implement new functions 」, the C language is similar. For example, printf is a function made by someone else to output some data to the screen in the specified format. Others have also made many other functions, such as "calling a function you wrote when you press the mouse twice in a short time 」. Learning how to use these functions in C or any other programming language is also a major play in learning programming. When you understand this, you will find the answer to your question.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.