If a programmer has never been in linux,unix Under the development of the program , Has been windows The following development program , Same job 10 year , Most of the time with in linux,unix The following development 10 The level of programmers in 2000 will be very different .
I didn't write this article to belittle windows The following developers , do windows Developers may not feel comfortable watching it , That's not what I mean , I'm just talking about my own feelings ,
I first started learning programming in windows Below , What I learned is VB, Later, I turned to VC++, It was VC6.0, do windows The following development 5 It will be transferred to linux The following is the development of , Start in linux Now when we do development , I've done a lot of it windows The following items , stay linux The following development is really better than I am in windows I learned a lot from the development below , From the open source code has absorbed the rich nutrition , I'm not saying I'm a master , It's just that linux Let's learn , You're going to improve faster .
But I need to emphasize , What I'm talking about here is “ In most cases ”, That is to say “ In the same diligence , The same level of effort , The same basic knowledge , Same working years , It's also about application development ” Under the circumstances , If it's not right , I hope you can express your opinions below .
Maybe you'll be surprised , Why does this happen ？
Listen to me slowly ！
First of all ： Closed source and open source
windows The following procedures are basically closed source code , especially 10 Years ago , stay windows It can be said that no open source software is available , It's much better now than before , quite a lot linux The following open source programs are ported to windows The following to ,
however linux The following open source programs add more .
before windows Let's write the application , Need to use MFC,WINSOCK,ODBC,FILE IO etc. , The main places to find information are Microsoft official documents MSDN, There is only a MSDN Is the most complete place , It's a third party website vckbase, CSDN, codeproject These websites .
But the code from these sites , It's all for a specific small function , Code written to demonstrate how to implement this small function , The level of writing code varies , Different styles , It's all some demo Small things of nature , A simple study of the code can be integrated into their own applications .
How to build a complete application , Well structured applications , You won't be taught , It's all up to you to feel for yourself , Get promoted by doing projects in the company , Until the project is commercial , Later maintenance changes code , Looking back at the code I wrote , It's only when you realize that , How unreasonable the code structure I wrote at that time ,
It's so difficult to maintain and modify . If you can't find the information you need on the Internet , You can only think of some implementation methods by yourself , Although the function is completed , Maybe I have a sense of accomplishment when I finish , But that day, you suddenly find that someone has implemented this function , And in a clever way ,
Then you suddenly realize , Why didn't I realize that ？ stay windows The following development , It's not easy to find open source projects that can refer to similar functions you want to complete . It's all on your own . But in linux The following is different , When you're developing a new project ,
Think about any open source projects that do the same thing , Can be downloaded to the source code to do a reference , The algorithm of , Do a detailed understanding of architecture design , Then when I develop it, I will be more handy , You can avoid mistakes that others have made , Less detours .
second ： The amount of knowledge to learn is different
Study window Under the development of , You need to learn a lot Windows API, By the end of 2009 year 9 month ,Windows total API The number of 2258 individual , also Windows API There are many parameters , Parameter types are complex , It's not easy to remember so many things ,
At least as well as learning a foreign language , CET-4 requires a total vocabulary of 4500 Word . As one can imagine , Learn so much API usage , How hard is it . So learning linux Next , How much to master API Well ？ linux Kernel under API,
It's just a matter of counting them all down 335, But these kernels are API You can only use it when writing drivers , You can't use the kernel to develop applications API, Developing applications API Basic it is C Of API, and Linux be-all C Of API The number is 279 individual ,
That is to say, you just have to lose control of 300 One of the API, You can be successful in linux The following is the development of the application , Compared with learning windows The pile below API Come on , Can you save a lot of time to learn other knowledge ？
Let me give you a simple example ：
Above these API yes windows The following file operation API, The total is 8 individual , have a look CreateFile The parameters of ,
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);
The meaning and type of these parameters , How long does it take you to master ？
We're looking linux The following file operation C Of API There are several ,
fopen, fwrite, fread, fclose There are four , Let's look at the parameters
FILE fopen( const char filename, const char *mode ); Two parameters , How much time do you need to master .
Maybe some people will give their opinions , Say it C Of API Can also be in windows Next run ？ you 're right , Is it possible to be in windows Run below , But you can master the cross platform C Of API Is that enough? ？ Is it all in windows The following developers like to use C Of API, Don't use windows Of itself API Do you ？ You don't need to learn windows Below API Do you ？ Your colleagues used CreateFile This function , Don't you need to understand him ？ Don't you need to look at your colleagues' code ？ Don't you need to maintain code that someone else has written ？
If you still think so , I can give you other examples ！ Take the example of creating a thread , Here is 2 It's in windows Here is an example of creating a thread , The first is to create safe worker threads , The second is to create interface threads , There's another function that I didn't put down , It's about creating unsafe worker threads , We can refer to the specific principle 《win32 Multithreaded programming 》,
author ：（ beautiful ）Jim Beveridge & Robert Wiener Writing , Hou Jie translate This book .
// Thread safe worker thread functions uintptr_t _beginthreadex ( void *security, unsigned stack_size, unsigned ( *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr ); // Interface thread function 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 );
do windows The following development , We must master the above two functions for creating threads . Yes, of course , You can also just need to know _beginthreadex Come on windows Take it all , But when you see someone else's code using CreateThread When , Don't get used to it ,MFC A lot of people use it CreateThread. Master so much API Tired ？ Just as tired as reciting words when you were at school .
Now I'm going to list linux Here's the function to create the thread
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 that .
C Of API Most of them can be windows Run below , stay windows Let's learn to develop , Not only do you have to understand C Of API, You need to spend more time learning windows Of the system itself API, You may have to say ,
So it should be windows So much to learn next , What I'm going to say is that you master API A lot , But for a piece of software , The most important thing is the system architecture , data structure , Good architecture design , For later code maintenance , Function modification is crucial ,
This is the code that novices write , In the end, even his own hard to maintain the reason , Let alone let others defend it .
API It's equivalent to basic skills , System architecture , Data structure is an internal skill , The faster you practice basic skills , The more time we have to practice our internal skills . Practice your internal skills , We need to learn from experts .
I'm learning windows The following development and application of the road , We need to master more API, After learning , Let's get narrower and narrower , There is no particularly rich open source code to refer to , The rate of improvement is slow .
Gratifying is that , Now many open source projects have been transplanted to linux below , There are also a lot of open source projects that are cross platform , What is commonly used is wxWidget Interface library , Usage is similar. MFC, also qt This interface library ,
Is also very strong , And open source 3D engine OGRE, The architecture is very good , It's worth learning the architecture model . however linux The following open source libraries are much better than windows The following open source libraries are much richer ,
We can easily learn data structure from the master code , Learning design mode , Learn programming skills , This is the same. linux The following programmers , It might be better than windows The following are the reasons for the higher level of programmers
After all, I'm well-informed , Familiar with 300 tang poems , Can't write poetry can also sing ah ！
If you want to turn linux But I don't know where to start , You can join the group 973961276 Study with you linux. Learning through train >>c/c++ linux Server senior architect