LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-17-2016, 01:05 AM   #1
s4ssecurities
LQ Newbie
 
Registered: Sep 2016
Location: Delhi
Distribution: s4ssecurities
Posts: 1

Rep: Reputation: Disabled
Post What is the basic coding style for a linux developer ?


Tell me the references for a feew websites
 
Old 09-17-2016, 01:26 AM   #2
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
Hello & welcome.

A web-search for: "coding style" returns things like:
http://wikipedia.org/wiki/Programming_style
Adding linux to the search, returns good info, like:
https://www.kernel.org/doc/Documentation/CodingStyle

Add more specifics, to narrow down to your desires.

Tell us a little bit about the 'distro' of Linux you use, your experience [& goals here].

Last edited by Jjanel; 09-17-2016 at 01:31 AM.
 
Old 09-17-2016, 04:25 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by Jjanel View Post
Tell us a little bit about the 'distro' of Linux you use, your experience [& goals here].
s4ssecurities
 
2 members found this post helpful.
Old 09-17-2016, 04:31 AM   #4
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
If you mean kernel programming, then check out The Linux Kernel Module Programming Guide at http://www.tldp.org/guides.html
 
Old 09-17-2016, 10:58 AM   #5
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Really basic?

Make it readable (for humans), the compiler doesn't care about style, only about the code being correct.

Indent. Start a for, indent everything withing that section, including more indents for if - else and other conditions.

If you're using vi/vim, you can set two helpful things in a file .exrc in your home directory, looks like this:
Code:
cat .exrc
set autoindent showmode showmatch
autoindent keeps track of tabs, hit a tab (for indent) and that will line everything up with additional tabs; you "go back" with ^D one indent level at a time. Pretty handy and no clicking on anything.

showmatch gives you a visual indication that you've got the correct number of parens, brackets or braces; the cursor will jump back to the match but won't budge if you're doing too many.

showmode doesn't do much of anything but, every so often, you'll see something happen about what mode you're in. Can't hurt, might help.

You really do not want to write code in a word processor, use the editor instead.

Just a few lessons learned during a wasted youth.

Hope this help some.
 
Old 09-17-2016, 05:56 PM   #6
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
The coding style tends to be the same as they are on the job IME. Just the tools are different. Although the last time that I had a programming job, I didn't do much coding on work nights. The duties of the job left you pretty spent after a days work. But on the weekends you get to focus on your interests. Which for me was silly graphical stuff in java. Versus playing text video games with other peoples data in whatever the company chose to use. Probably platform specific like VB, and probably what it used to be a decade ago when they bought into the platform. And probably on hardware just as old because of policies and such.

About the only style difference is make it work, on the job, and make it pretty, when not getting paid (which is the stuff you'll likely show others). But in general I strove for maintainable and fewest lines of code. At least after I knew enough about a given language. Even if I knew advanced techniques I avoided them. That's the stuff that got broken when the language or platform changed. Plus dumbing it down made it easier on interns (and managers) to review and maintain your past projects.
 
Old 09-17-2016, 07:12 PM   #7
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 3,137

Rep: Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855Reputation: 855
get the code working first then mpretty it up, you can use somthing like astyle for c code wich is quite customizable, available on sourceforge, i use it then do a few minor tweaks for hoa i like the code set out
 
Old 09-17-2016, 08:50 PM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Not a fan of make it work, then fix it methodology. It's fine in a "perfect" world, and what most employers are willing to pay you for. But in practice, the network goes down, the storage devices fill up or become unavailable. The servers you're "waiting on" don't respond. It's better to take your time, to map it out so it's a batch process that can be (re)started from any ONE step in the process. Not really multi-thread-able though. But break your process out, one to identify changes, one to do changes, one to verify changes, one to clean up the mess for the next run. All of which can be the same program, just called with different parameters. Having spent most of my paid experience taking 6 to 24 months cleaning up something that took someone else 3 to 6 months to rush into production. If you do it wrong, not only do you need to fix the problem, but you have to clean up the mess. And that mess can have legal as well as financial implications.
 
Old 09-18-2016, 01:14 AM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,622

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
this is looking like a advertisement for a company " s4ssecurities"
"s4ssecurities " is the distro in the profile -- it is a for pay company

looking a bit botish / SEO'ish

Quote:
Tell me the references for a feew websites
a security comp. that can not use google ????

Last edited by John VV; 09-18-2016 at 01:21 AM.
 
1 members found this post helpful.
Old 09-18-2016, 04:20 AM   #10
seasons
Member
 
Registered: Dec 2014
Distribution: siduction
Posts: 264

Rep: Reputation: 58
The principle I've always seen is to use the coding style already present in whatever you're working on. If you're creating your own project, you get more freedom. Obviously, you should still follow general rules of good code formatting for whatever language you're using, but they're not specific to Linux.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: C development on Linux - Coding style and recommendations - IX. LXer Syndicated Linux News 0 03-16-2012 07:50 AM
GTK coding style MTK358 Programming 7 05-21-2010 08:27 PM
Preferred coding style? MrCode Programming 26 03-27-2010 02:34 PM
is there a basic style lanquage for linux scottsteibel Programming 1 12-15-2006 01:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration