Thread: C programming in linux

  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    1

    C programming in linux

    Hi i just started to take a BCA degree
    i want to know which linux best for C programming
    i have ubuntu 13.04 but i heard that red hat is best for C.
    please reply fast

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    Which distrubution you use really doesn't matter. Pick the one you like the best.

    Jim

  3. #3
    Registered User
    Join Date
    May 2013
    Posts
    66
    Quote Originally Posted by dibinvm View Post
    Hi i just started to take a BCA degree
    i want to know which linux best for C programming
    i have ubuntu 13.04 but i heard that red hat is best for C.
    please reply fast
    when it comes to programing in C, the flavor of linux you run will not matter. What will matter is how comfortable you are with things like gedit and the command line as well as how comfortable you are with Ubuntu running spyware that sells your personal data to companies like Amazon and FaceBook?

    That is the reason i refuse to ever run Ubuntu again. I personally run Fedora as my workstation and have zero issues coding with it at all. Just remember to not only install gcc, but the devel packages or you will not be able to compile.

  4. #4
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Wait, don't all flavors of Linux come with gcc by default anyway? I thought it was because Unix was re-written in C once C was created and ready to go. Or does Fedora not come with it? I know Arch came with and if Arch comes with it then, I mean, c'mon.

    Also OP, Linux C programming best C programming!!!!

    I do like using gedit though other people will use stuff like vim or nano if you want a more command line interface. Also, gedit can come in blue which therefore makes it the superior text editor.

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by MutantJohn View Post
    Wait, don't all flavors of Linux come with gcc by default anyway?
    Depends on installation type you choose.
    of course on Ubuntu it is just a matter of one command to run
    Code:
    sudo apt-get install gcc
    On a bare Debian it a little bit more tricky since first you need to install sudo and add yourself to sudoers list...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #6
    Registered User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    89
    Quote Originally Posted by lleb View Post
    Just remember to not only install gcc, but the devel packages or you will not be able to compile.
    I think that's one of the funny sides of Linux: If you don't install the dev-files, gcc will not compile. So if you only install gcc, you can't compile, so what CAN you do?

    Well, I just think it's kind of funny…

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    On a bare Debian it a little bit more tricky since first you need to install sudo and add yourself to sudoers list...
    The other option would be to just su to the administrator to install the package.

    Jim

  8. #8
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    So I just wikipedia'd "Linux kernel" and I read up a bit. So, it claims :
    Linux is written in the version of the C programming language supported by GCC (which has introduced a number of extensions and changes to standard C), together with a number of short sections of code written in the assembly language (in GCC's "AT&T-style" syntax) of the target architecture. Because of the extensions to C it supports, GCC was for a long time the only compiler capable of correctly building Linux. In 2004, Intel claimed to have modified the kernel so that its C compiler also was capable of compiling it.[61] There was another such reported success in 2009 with a modified 2.6.22.[62][63]
    I take this to mean that just because the kernel is written in C, the OS wouldn't come with the compiler because C spits out just binary files and that's all you fundamentally need. That's so lame though. You need GCC to make Linux but then they'll ship it out without GCC because the user may or may not need it, I guess is the underlying philosophy.

  9. #9
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    You need GCC to make Linux but then they'll ship it out without GCC because the user may or may not need it, I guess is the underlying philosophy.
    Why is this so hard to understand. Look at Windows, a C compiler is required to build this operating system. But they never install a compiler by default. If you want a compiler you'll either have to purchase one or download a free compiler. Unless you plan to rebuild parts of your Linux operating system you don't necessarily require a compiler.

    Jim

  10. #10
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    It's not 'hard to understand.' I just don't get the logic of it which is expected as machines are not humans and vice versa.

    Let's pretend it's 1974 and I got this awesome computer the size of the room I'm in now with its whole 8 MB of RAM. What else would I be doing with it if not writing C code? I can't use the YouTube! Or the Facebook! Or even troll GameFAQs or here! I can't write a novel or listen to music. I can't play videogames. I'm running out of ideas here.

    Sorry, it's just, what else would someone have used an ancient Unix system for if not for writing C code? I could've been Barnes & Hut before Barnes & Hut!

    So, it just seems surprising to me that modern Linux distros would just say, "Nah, the user's probably not going to be needing this any time soon." It seems like it eschews all historical ties and significance. I believe that passing down gcc would sort of be like a passing of the torch, so to speak. I don't know, it just doesn't seem like there's any reason to NOT ship out gcc with a Linux distro or is there some weird philosophy about the purity of the OS?

    If you write your OS in C and compile it with gcc then I don't see any harm in shipping it with gcc.

  11. #11
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Quote Originally Posted by MutantJohn View Post
    I don't know, it just doesn't seem like there's any reason to NOT ship out gcc with a Linux distro or is there some weird philosophy about the purity of the OS?
    All Linux distributions do support GCC and C development libraries. The reason some do not install them by default, is part of a weird philosophy.

    That philosophy is basically "respect users' freedom and community" (fsf.org).

    Each distribution forms a community of like-minded users and developers; people and organizations. (That community is hopefully part of the larger community of Linux developers and users, but that's not relevant to my point here.)

    The idea is that the community around each distribution chooses the default package set that best suits them. They are absolutely free to do so, as nobody sane is going to force them to install some packages by default, just because <any random reason>.

    It should be glaringly obvious that any user is free to install whatever they like on their machines (they have a license to), so it's not like the default installation is in any way limiting to the user. The default package set is all about convenience. To me it is just perfectly natural that the community around each distribution chooses the default package set they feel is best for them.

  12. #12
    Registered User
    Join Date
    Jul 2012
    Posts
    51
    Not all systems are dev environments. Think web servers, firewalls, etc. Not having dev tools might bring an added level of security.

    Technically, Linux *is only* the kernel. GNU compiler is part of GNU.
    https://en.wikipedia.org/wiki/GNU/Li...ng_controversy

    BTW, the best distro is your own: linuxfromscratch.org
    : )

  13. #13
    Registered User MutantJohn's Avatar
    Join Date
    Feb 2013
    Posts
    2,665
    Hmm... I know I say it a lot and I always mean it then too but this time, I really, really mean it: Arch Linux best Linux!

    Ty for the info though, Nominal

    Edit: I will agree with you, vart, but it's only because modern distributions allow the user to do so much without ever requiring gcc. I guess modern distros are the evolution and I guess it technically is an evolution also that people can use their computer for more than just gcc.

    I'm just surprised to learn certain Linux communities aren't all in favor of shipping gcc with their distro. I think Ubuntu comes with it though by default. I don't remember installing it...

    And I get the philosophy, vart, as Arch is like one of three distros that doesn't ship with a graphical shell. I followed all the install instructions and when they said I had a working install, I made that phace phantom always makes "O_o" because all of a sudden it was 1973 again.
    Last edited by MutantJohn; 07-31-2013 at 01:18 PM.

  14. #14
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    Quote Originally Posted by MutantJohn View Post

    So, it just seems surprising to me that modern Linux distros would just say, "Nah, the user's probably not going to be needing this any time soon." It seems like it eschews all historical ties and significance. I believe that passing down gcc would sort of be like a passing of the torch, so to speak. I don't know, it just doesn't seem like there's any reason to NOT ship out gcc with a Linux distro or is there some weird philosophy about the purity of the OS?
    Most distros today give you possibility to download some iso for installation cdrom/dvd/usb with basic set of programs that should satisfy MAJORITY of users, and then give to possibility to easy install the rest by downloading them from repositories.

    Why do you want to make all users to spend their bandwidth on programs that you feeling should be installed due to some historical reasons is beyond me.

    I think correct way would be to support 2 types of distributions - for offline install - "include everything on dvds" and install what asked by user.
    Or online install - give minimal cd image that could take me from original boot-up till the fully functional bare system, where I can download and install everything I need, and not to spends my bandwidth on anything I will never use.

    In any case - do not force-feed me with anything that I need to download just to satisfy some weird philosophy.

    Your philosophy requires to install gcc by default.
    Some other will bring wine with it.
    Going further down this path we could encounter IExplorer installed on Linux just to satisfy some philosophy that says that any user should have something on his comp that obliges him to pay royalties to MS.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  15. #15
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Quote Originally Posted by MutantJohn View Post
    modern distributions allow the user to do so much without ever requiring gcc.
    When trying to learn programming or systems administration, that may also be a hindrance.


    (Please bear with me, this goes back to the original topic at hand.)

    Consider this: How good a C programmer are you, if you don't have an internet connection at all?

    For the sake of sanity, let's ignore all reference aspects, like checking the name of a function, or the type and order of its parameters. (Linux, just like old Unix and current *BSD systems, have man pages, and other documentation included with the packages you install. I personally don't have the brain capacity to reliably memorize even standard C library interfaces, so I don't even try; I use the man pages very often to check those. I consider this a good balance myself, but others may disagree.)

    I posit that if something is abstracted and simplified too far, the understanding of actually what is happening will be only superficial.

    When everything works as it should, that is absolutely fine, but when problems or the need for customization arises that the simple interface does not solve, you may be in deep trouble.

    (This is very common in everyday life. It is also one of the reasons I've found it so difficult to train Windows administrators to become Linux or Unix admins. They expect to work at a specific level of control only, and punt all deeper issues to the vendor; whereas administrators of Linux and Unix systems are expected to at least triage and diagnose deeper problems themselves, before punting the problem upstream. If the problem report does not contain specific details, Linux developers will ignore it. So, it is often easier to teach somebody from scratch, than have someone first un-learn things they know, and only then learn new things.)

    Projects like Raspberry Pi are targeted for this exact same thing: getting past the abstractions, back to the actual "metal", down to the level where things really are simple and your imagination is the limit -- even if you have to sweat a lot to realize it.

    As to C programming, I fear the ubiquitousness of the internet is actually generating programmers with "shallower" learning. Instead of stopping and really thinking about a problem, they fire a quick question on a social site. I fear this causes these programmers to avoid learning how to solve difficult problems themselves.

    Not that there is nothing wrong in asking; many things are already known, and there is no need to invent the wheel over and over again. But, at some point, every programmer should learn to solve the difficult problems, too, and I think it might be good to do that pretty early.

    I learned to program using text-based interfaces, I'm that old already. I don't know if it has affected how good a programmer I am; I slightly doubt that. But, I think that having had to solve a lot of the problems I encountered myself, has helped me to develop those problem-solving skills. Now that I do have an internet access basically all the time, I use those exact same skills -- I believe -- to evaluate the known solutions, and to decide which one of them works best for me, or if I should actually develop my own solution.

    (Needless to say, I like developing my own solutions best. But, I'm not a Not-Invented-Here fanatic, I just love solving problems. I have no problem in describing and helping other apply already known algorithms and implementations to solve a problem.)

    I believe that it is much more important to observe how you use your tools, than to pick the theoretically best set up front.

    Deliberately avoiding the use of the 'net for simple problems -- or at least spending a fifteen minutes or up to an hour just thinking about the problem before asking others for help --, will have a much bigger impact on your learning about C, than any details like which desktop environment you should use. (Learning to use man pages as your first reference will help you avoid the distraction of your web browser, too.)

    Avoid distractions, and even "bling", to help you concentrate on the task at hand. If you listen to music, keep the player offscreen; otherwise part of your brain will spend at least some of its computing power observing the changes in the player.

    At some point you will find you need some distraction. This is normal; typical humans cannot concentrate on a single thing for too long and still be productive. Let yourself relax, be distracted, maybe do something else entirely. Just make sure that when you are solving a problem, you are concentrating on the actual problem.

    The relaxation part is pretty important with respect to programming, too. Whenever I am working, I can take short breaks, letting my subconscious or hindbrain work on some facet of a problem I'm facing, and do something completely different to relax -- and shift back to "work mode" the instant I feel refreshed. Also, when I get one of those sudden thoughts about how to solve a problem (I might not be even facing at that time), I can write a small test example, compile and run it, just because it is so easy on a desktop environment. I don't have to tune my brain to "work mode" for that to happen.

    It helps me a lot that I'm using a system I've tailored to my needs. Because I've tailored it to my needs, I'm also not dependent on using a specific distribution; as long as I can set the few quirks that help me most, and avoid annoying distractions, I'm happy and productive.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linux C programming
    By kate00 in forum C Programming
    Replies: 0
    Last Post: 12-26-2011, 09:24 AM
  2. Programming C on Linux
    By Rahulds in forum C Programming
    Replies: 1
    Last Post: 09-27-2008, 02:42 AM
  3. Windoze programming to linux programming
    By windoze victim in forum Linux Programming
    Replies: 5
    Last Post: 12-05-2002, 02:02 AM
  4. New to linux GUI programming
    By bonkey in forum Linux Programming
    Replies: 5
    Last Post: 10-24-2002, 07:36 AM
  5. Linux Programming
    By Bud in forum C Programming
    Replies: 2
    Last Post: 07-05-2002, 03:25 PM