Learning C++ Linux kernel style the first time

A 5 star hangout for overworked and underpaid system admins.
Post Reply
Rct_Tsoul
Posts: 20
Joined: 2011/04/30 14:21:51
Location: the Mighty American Empire
Contact:

Learning C++ Linux kernel style the first time

Post by Rct_Tsoul » 2019/03/01 22:47:19

I'm about to get back into programming after 30 years.
I want to learn the right way to make my code, the Linux kernel style that is easy to read and edit., such as indent with 8 spaces and such, so if I share or release my code it can be much more productive in a team environment.
Assume I have no knolege of programming what so ever, and please recommend a hard print book for me to buy that uses the most standard Linux IDE that will run on both Linux and Windows, thanks.

User avatar
jlehtone
Posts: 2233
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Learning C++ Linux kernel style the first time

Post by jlehtone » 2019/03/04 09:33:08

There are many styles and conventions. It is up to the team, what style they prefer or require.

Linux kernel style can be found with websearch: https://www.kernel.org/doc/Documentatio ... -style.rst

Note though that there is no "C++ Linux kernel style" because Linux kernel is not written with C++.

Rct_Tsoul
Posts: 20
Joined: 2011/04/30 14:21:51
Location: the Mighty American Empire
Contact:

Re: Learning C++ Linux kernel style the first time

Post by Rct_Tsoul » 2019/03/04 18:38:43

I need to learn C and then eventually to the object orientation, I'm just asking for a way to start learning that will instill good practices such as an indent of 8, keeping each line short, a good way to keep code readable so it can be edited.
Example: when I look at code from the Microsoft coder it's all jumbled up up, not much indent, very difficult to see what's going on as if they are hiding something.
Then I look a CentOS package code that is much easier to read and edit....... simply typing "Make" will compile a useable executable under Linux or even Windows using a MinGW console.
If it was a video game, I can easily find and change the power of a 45cal pistol from dmg = 23 to dmg = 46

The Window game programmer has these setting burried so deep I'll never find the setting, and even if I did find it, that changed setting may mess up other setting that I don't intend to change.

I basically want to learn GOOD PRACTICE that allows me to code quickly vs bad practice that is slow and difficult to find and make changes.
I want to be able to easily spot a mistake and fix it.

Rct_Tsoul
Posts: 20
Joined: 2011/04/30 14:21:51
Location: the Mighty American Empire
Contact:

Re: Learning C++ Linux kernel style the first time

Post by Rct_Tsoul » 2019/03/04 18:42:22

Basically I want a book that will allow me to learn GOOD practice from the start, assuming I have no knolege of programming at all, so I can follow the instructions to learn and at the same time build good habits within myself.

The link you gave above is exactly what I'm talking about, I can clearly see what is going on and reguardless what I'm coding, that's how I want my code to look, I want a book that will show me to code like this.

User avatar
jlehtone
Posts: 2233
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Learning C++ Linux kernel style the first time

Post by jlehtone » 2019/03/05 18:21:24

One can write code that is heavenly gorgeous to look at, yet pointless.

For a book, perhaps:
https://dl.acm.org/citation.cfm?id=993828
https://herbsutter.com/elements-of-modern-c-style/

MartinR
Posts: 442
Joined: 2015/05/11 07:53:27
Location: UK

Re: Learning C++ Linux kernel style the first time

Post by MartinR » 2019/03/05 20:35:19

True, but IMHO rarely write ugly code that is effective.

Post Reply