The difference between being a 10-year Windows programmer and being a 10-year Linux programmer

Source: Internet
Author: User

If a programmer has never developed a program under Linux,unix and has been developing programs under Windows for 10 years, most of the time it will be very different for programmers who have developed 10 years under Linux,unix. I write this article is not to belittle the development of windows under the people, do Windows development people may feel uncomfortable, I do not mean, I just say my own feelings, I first began to learn programming is also under the windows, Learning VB, and then go to VC + +, At that time with the VC6.0, do windows under the development of 5 years after the development of Linux, began to do under the Linux development, but also done a lot of windows under the project, Under the Linux to do development is indeed more than I do in the development of windows to learn a lot of things, from the open source code to absorb the rich nutrition, I do not mean that I am a master, just say under the Linux study, you will progress faster.

But I need to emphasize that what I'm saying here is "most of the cases", meaning "in the same hard work, same effort, same basic knowledge, same working years, and also for application development", if it's not right, I hope you will post your views below.

Perhaps members will wonder why such a situation arises.

Listen to me slowly!

First: Closed sources and open source

Windows under the Basic program is closed source code, especially 10 ago, under Windows can be said to find available open source software, now the situation is much better than before, many Linux under the open source program is ported to Windows, But the open-source programs under Linux are adding more.

Used to write applications under Windows, need to use mfc,winsock,odbc,file IO, etc., can find information is mainly Microsoft Official documentation MSDN, but only MSDN is the most complete place, down is a third-party website Vckbase, CSDN, CodeProject these several websites. But the code found from these sites is for a specific small function, in order to demonstrate how to implement this small function and write code, the level of writing code is uneven, different styles, are some of the demo nature of Small Things, a simple study to see the code can be integrated into their own applications. How to build a complete application, a well-architected application, the university will not teach you, everything depends on their own, in the company to do projects to improve, until the project commercial, later maintenance changes in code, look back to write the code, only to deeply realize that the code structure of their writing at that time is how unreasonable, Maintaining the changes is so difficult. If you do not find the information on the Internet, you can only rely on their own to think of some way to achieve, although the completion of the function, may be completed when there is a sense of accomplishment, but the day you suddenly found that someone to achieve this function, and used a clever method, it is you suddenly pitiful, why I did not think so realized? Developed under Windows, it is not easy to find an open source project that you can refer to that is similar to what you want to accomplish. Everything has to be on its own. But under Linux is not the same, when you want to develop a new project, you can think of any open source project also completed a similar function, you can download to the source code to do a reference, the algorithm, architecture design, etc. to do a detailed understanding, and then the development of their own time will be more handy, You can avoid other people's mistakes and take a lot of detours. http://hovertree.com/menu/windows/

Second: The amount of knowledge to learn is different

Learning window under development, you need to learn a lot of Windows API, as of September 2009, the total number of Windows API 2,258, and Windows API parameters, parameter types are complex, it is not easy to remember so many things, At least as much as learning a foreign language, college English level four requires a total vocabulary of 4,500 words. It is conceivable, how difficult it is to learn so many API usages. So how many APIs do you want to learn under Linux? Linux under the kernel API, all counted down also only 335, but these kernel APIs only when writing drivers to use, the development of the application is basically not the kernel API, the development of the application API is basically C API, and Linux all C API number is 279, In other words, you only need to master less than 300 API, you can successfully develop the application under Linux, compared to learning the heap of Windows under the API, you can save a lot of time to learn other knowledge?

Let me give you a simple example:

CreateFile
ReadFile
OpenFile
WriteFile
DeleteFile
ReadFileEx
WriteFileEx
CloseHandle

The above API is the Windows under the file operation of the API, a total of 8, look at the parameters of CreateFile bar,

HANDLE WINAPI CreateFile (
__in LPCTSTR lpFileName,
__in DWORD dwDesiredAccess,
__in DWORD dwShareMode,
__in Lpsecurity_attributes lpSecurityAttributes,
__in DWORD dwCreationDisposition,
__in DWORD dwFlagsAndAttributes,

__in HANDLE hTemplateFile);

What are the meanings and types of these parameters, and how much time do you need to take control of them?

We're looking at a few of the C APIs that face file operations under Linux,

fopen, Fwrite, Fread, fclose a total of four, we're looking at the parameters.

FILE *fopen (const char *filename, const char *mode); Two parameters, how much time do you need to take control of it.

Perhaps some people will say that the above C API can also run under Windows AH? Yes, it can run under Windows, but do you have enough control over the cross-platform C API? Do all the people who develop under windows like to use the C API, not the Windows API? Don't you need to learn the API under Windows? Your colleague used the CreateFile function, don't you need to understand him? Don't you need to see your colleague's code? Don't you need to maintain code that someone else has written?

If you still think so, then I can give another example! Take the example of creating a thread, here are 2 examples of creating threads under Windows, the first is to create a secure worker thread, the second is to create an interface thread, and a function I do not put down the surface, is to create unsafe worker threads, the specific principle can be referred to "Win32 multithreaded Programming",

Jim Beveridge & Robert Wiener, Houtie to translate the book.

Thread-safe worker-thread functions

uintptr_t _beginthreadex (
void *security,
Unsigned stack_size,
Unsigned (*start_address) (void *),
void *arglist,
Unsigned initflag,
unsigned *thrdaddr
);

/* Why ask Hovertree.com * *

Interface thread functions

HANDLE WINAPI CreateThread (
__in Lpsecurity_attributes Lpthreadattributes,
__in size_t Dwstacksize,
__in Lpthread_start_routine lpstartaddress,
__in LPVoid Lpparameter,
__in DWORD dwCreationFlags,
__out Lpdword Lpthreadid
);

To do the development under Windows, we must master the above two functions of creating threads. Of course, you can also just need to know _beginthreadex to take all in Windows, but when you see someone else's code using CreateThread, you can not be used to, MFC many people use CreateThread.  Tired of mastering so many APIs? Just as tired as you recite the words when you go to school.

Below I'm listing the functions of creating threads under Linux

int Pthread_create (
pthread_t *restrict Thread,
Const pthread_attr_t *restrict attr,
void * (*start_routine) (void*),
void *restrict Arg);

See, you just need to know this.

C Most of the API can be run under Windows, under Windows to learn to develop, you not only have to understand the C API, you also need to spend more time to learn the Windows system itself API, you might say, so that should be a lot of Windows learning Ah, What I want to say is that you master the API is a lot, but for a software, the most important thing is the system architecture, data structure, architecture design good, to the later code maintenance, functional modification is very critical, this is the code of the Novice write, to the end even he himself is very difficult to maintain the reasons, let alone to others to maintain.

API equivalent to basic skills, system architecture, data structure is internal strength, the faster the basic skills, we will have more time to practice the internal strength. Practice, we have to learn from the master.

In the development of the application of Windows under the road, we need to master more APIs, learning, let our road more narrow, no special rich open source code can refer to, the level of speed is very slow.

Fortunately, many open-source projects are now being ported to Linux under, there are many open source projects are cross-platform, commonly used is the Wxwidget interface library, the use of similar MFC, and QT This interface library, is also very powerful, there is open source 3D engine Ogre, architecture is very good, It's worth learning about its architectural patterns. But the open source Library under Linux is much richer than the open Source Library under Windows, and we can easily learn the data structure from the master code, learn the design pattern, and learn the programming skills, which is the programmer under Linux. may be higher than the level of the programmer under Windows reason, after all, well-informed, familiar with 300 tang poetry, will not be a poem will be Yin Ah!

Recommendation: http://www.cnblogs.com/roucheng/p/daimashi.html

The difference between being a 10-year Windows programmer and being a 10-year Linux programmer

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.