Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Why C?

Options
  • 04-03-2005 12:07am
    #1
    Registered Users Posts: 3,608 ✭✭✭


    I'm in 1st Engeineering and we've been doing some programming in C. Is there any reason to choose this language?

    Thanks


«1

Comments

  • Registered Users Posts: 6,374 ✭✭✭Gone West


    yes. Ive written java vbasic and c++, and I find c is fairly fast and stable. Dont get me wrong im no master 'grammer or anything, but it is the standard for creating windows tools, etc. You will see how useful it is against say vbasic as your course progresses.


  • Registered Users Posts: 5,335 ✭✭✭Cake Fiend


    It's fast, it's easy to learn, it's popular, it's portable, it has great depth, flexibility and power, it's been around for donkeys so it's well-known, there's tons of information and other resources (compilers, libraries, etc) available either commercially or free on the internet, some other very popular programming languages are based on it (C++, Java) so you can use it as a springboard for these languages, people will still be using it in years to come.

    There are of course downsides to it (or rather things about it that have been improved upon by other languages), but all in all, C is a highly versatile language and a great one to get started with.


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    C is the language of the gods.


  • Closed Accounts Posts: 246 ✭✭Mohanned


    ross*k wrote:
    I'm in 1st Engeineering and we've been doing some programming in C. Is there any reason to choose this language?

    Thanks

    Its the basics and most languages link up to it


  • Registered Users Posts: 2,002 ✭✭✭bringitdown


    http://www.cprogramming.com/whyc.html

    Google: http://www.google.ie/search?q=%22why+C%22&hl=en&lr=&client=firefox-a&rls=org.mozilla:en-US:official&start=10&sa=N

    Many arguments for and against, for students I think if you manage C you'll have gotten a great grounding. It is something I would look for in a hire, because you'll most likely emerge from C with some knowledge of low level programming.

    Remember java's first compiler / VM was written in C. :)


  • Advertisement
  • Registered Users Posts: 1,421 ✭✭✭Merrion


    C punishes laziness and sloppy thinking so a course in C will make you a better programmer even if in real life you end up using a more high level language.


  • Registered Users Posts: 2,800 ✭✭✭voxpop


    Im not sure about engeineering and what you get up to (programming wise) but in software developement land - c is rarely used or required in my experience.
    Languages that are used alot are Java,.NET(C#,VB.NET),Delphi,scripting languages (js/vbscript/php). These languages would all generally make slower executing code than c but with todays computers that isnt really a concern unless writing drivers/os kernels (;))/etc.


  • Registered Users Posts: 2,426 ✭✭✭ressem


    For programming close to the metal, C compilers and libraries are sometimes all that are available to you.

    Gives you access and experience to memory addressing, heap, stack, registers, interrupts that are almost untouchable in higher level languages until things break badly.

    On the other hand the standards committee update it at glacial pace, e.g. they don't add safer char array handling functions because they'd be a bit slower. So you end up having to write/research lots of stuff that's supplied at the start in other languages, confirming with your manager that you can use this or that BSD library.


  • Registered Users Posts: 7,276 ✭✭✭kenmc


    Im not sure about engeineering and what you get up to (programming wise) but in software developement land - c is rarely used or required in my experience.
    Languages that are used alot are Java,.NET(C#,VB.NET),Delphi,scripting languages (js/vbscript/php). These languages would all generally make slower executing code than c but with todays computers that isnt really a concern unless writing drivers/os kernels (;))/etc.
    Would totally disagree with this statement. I am a Software Developer with 7 years experience, and the *only* language I use on a day to day basis is C. Occassionally I will go into assembler depending on what I need to do. The reason that I'm in C/ASM is that it's embedded SW - i.e. small footprint stuff typically with 10s of MB of ram - eg 16 MB, and an overall sw size of circa 4 MB flash. C++ would be too bloaty and Java would be both too bloaty and too slow running in these devices. C is an absolute must in my book as it teaches you all the important stuff that others eg Java and so on rely on eg pointers - they're abstracted out in Java, but still underneath. Also teaches you good manners like freeing when done with a malloc etc. AND it gets you down to register level and into the bones of the system.
    If you want to write *user level* programs then you can get away with Java/C++ etc, and bloaty code is not such an issue, but if you really wanna understand how code works and how you can squeeze each and every little KHZ (yeah KHZ, not MHZ) out of a processor go down the C route.


  • Registered Users Posts: 2,800 ✭✭✭voxpop


    c is also the language that gave us buffer overflows and numerous other security exploits because the people using the language didnt understand the subject correctly. C doesnt teach you anything, you have to learn it yourself. Also if you delve deeply into most highlevel languages they also provide some sort of facility to get into heaps/stacks/pointers/etc.

    High level languages mean you dont have to worry about pointers,memory allocation and deallocation, etc. Thats the point, these low level elements are abstracted away so the developer can concentrate on writing good code that does what its supposed to do.

    TBH kenmc, im not recommending a high level language if you are building drivers ,writing os components, doing some types of embedded programming (although remember there are pleanty of java apps and games for mobile phones - this is fairly small footprint stuff) or anything that requires low level i/o and memory management. The fact is that today most companies (software dev companies) are looking for people with OO high level language skills and not C.

    The original question was whether to choose C or not. I think the answer is - it depends on what you are going to be programming. If as an engineer you will be writing sorftware for controllers and other embedded devices then C is the way to go otherwise go for a more high level language.


  • Advertisement
  • Registered Users Posts: 7,276 ✭✭✭kenmc


    Ok, I take your point Angry Penguin regarding the buffer overflows etc etc, but I would still recommend that before anyone learns a high level language that they are exposed at least to some degree to a lower level one eg C, so that they will realise that there are things that are being looked after for them with C++, Java etc. i.e. you can't understand the benefits of something till you see the problems it solves.
    Also it's not unknown for a compiler to make a fcuk up, esp if it's been ported over to a new platform etc, so it can be extremely beneficial to at least know that there are such things as memory leaks that can be investigated when the program starts going off into the boonies, and the code *looks* coherent.
    Also, any tool is only as good as it's driver. What I'm terribly afraid of is people who have never seen C, only C++ and when they go out into the real world and have to write some C and given it's syntax similarity to C++ will not bother to investigate too much and hence not know anything about freeing memory,checking for null pointers, deferencing etc etc.

    Edit :
    If as an engineer you will be writing sorftware for controllers and other embedded devices then C is the way to go otherwise go for a more high level language.
    Unfortunately in college you have no way of knowing what sort of programming (if any!!) you will be doing when you get out into the big bad world. They generally teach you several languages (I did pascal, C, C++, Java, Erlang, 68KASM), so that you get the hang of the practice of programming full stop, and once you are able to program in one language you will be able to learn other languages.


  • Registered Users Posts: 17 InkPot


    I think perhaps the upshot of it all is that.. as a *student*, learning C is an excellent choice, regardless of what you may end up doing after graduation in terms of s/w dev. ( ie., user applications or embedded s/w dev. etc..) .. Learning a programming language that requires the most discipline first is always a good idea. It will make you a better programmer later even if you never actually use C again. Having said that, I would also recommend familiarising yourself (even on your own time) with an OO language (C++/C#/Java).... just because of the different approach you have to take when programming in them. Its a very useful string to have on your bow.


  • Registered Users Posts: 5,335 ✭✭✭Cake Fiend


    Considering the OP is in first-year Eng, it's pretty safe to assume that they'll be learning OOP later on (in fact, I'm surprised they weren't started off on Java TBH). IMO, learning C first will give a good framework for learning C++ or Java later.


  • Registered Users Posts: 261 ✭✭HaVoC


    Friend of mine is doing physic and instrumentation degree
    He used:

    C
    Math lab
    VB + ActiveX

    Through out his studies he used these languages to talk to various instruments voltmeters etc over a serial port.
    C allows you to get more control over things as it’s at a lower level. As c is at a lower level they probably teach it to make you understand what’s happening under the hood in the high level languages like Math lab & VB + ActiveX.


  • Registered Users Posts: 3,608 ✭✭✭breadmonkey


    Thanks for the replies everyone, even if I don't really understand some of the terminology :D

    I doubt I'll ever do any programming after this year since I'll probably be going down the civil route. Or am I wrong? :confused:


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    C doesnt teach you anything, you have to learn it yourself.

    I don't get your point here. Are you saying that with higher level languages you don't have to "learn it yourself"?

    C is being taught to first year college students because it introduces them to structured programming before they delve into the world of OOP - which is very good practice.
    High level languages mean you dont have to worry about pointers,memory allocation and deallocation, etc. Thats the point, these low level elements are abstracted away so the developer can concentrate on writing good code that does what its supposed to do.

    By "writing good code" do you mean well-structured, easy to read code? Or do you mean efficient code? "writing good code" is a massive generalization.

    If you learn C, you'll gain alot more knowledge of how things work than you would with the likes of Java, VB, C#, et al..
    You will be forced to learn how things operate at a low level, and your programs will be stable and efficient, they will not be bloated and slow.

    Learning C before learning another language is a very good practice.


  • Registered Users Posts: 2,800 ✭✭✭voxpop


    sjones wrote:
    Originally Posted by Angry_Penguin
    C doesnt teach you anything, you have to learn it yourself.
    I don't get your point here. Are you saying that with higher level languages you don't have to "learn it yourself"?
    If you read the rest of the thread you will notice that some people claim that C teaches you important stuff and implies that if you start programming with C you will become a fantastic programmer. My point is that working with C doesnt automatically bestow any special knowledge on you - like every other language you have to work at it.
    sjones wrote:
    C is being taught to first year college students because it introduces them to structured programming before they delve into the world of OOP - which is very good practice.
    I think you'll find that in many colleges these day, langauges like Java are taught to first year students,with C,assembly and the like being taught in second year.
    sjones wrote:
    By "writing good code" do you mean well-structured, easy to read code? Or do you mean efficient code? "writing good code" is a massive generalization.
    Everyone knows what "good code" means (hows that for a generalization) - dont be so pedantic
    sjones wrote:
    If you learn C, you'll gain alot more knowledge of how things work than you would with the likes of Java, VB, C#, et al..
    You will be forced to learn how things operate at a low level, and your programs will be stable and efficient, they will not be bloated and slow.
    So everyone who learns C, becomes a great programmer :rolleyes: and you complain that I generalize!


    I think ross*k is happy enough with the feedback, shall we leave it at that.


  • Closed Accounts Posts: 113 ✭✭Pinhead


    sjones wrote:
    You will be forced to learn how things operate at a low level, and your programs will be stable and efficient

    Wow, with C, your programs will be stable and efficient?! Yeah! Maybe with ten years experience... :rolleyes:


  • Registered Users Posts: 614 ✭✭✭dent


    The first language I learned in college was c then C++ then Java. Seems like a logical progression. C is fast and also handy for systems programming in say Linux.


  • Closed Accounts Posts: 7,230 ✭✭✭scojones


    troll.jpg


  • Advertisement
  • Registered Users Posts: 2,281 ✭✭✭DeadBankClerk


    High level languages mean you dont have to worry about pointers,memory allocation and deallocation, etc. Thats the point, these low level elements are abstracted away so the developer can concentrate on writing good code that does what its supposed to do.

    The problem is that these are leaky abstractions:
    http://www.joelonsoftware.com/printerFriendly/articles/LeakyAbstractions.html


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    Thats a fabulous article dbc. Just read it.


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    People go on about java being slow. JIT actually allows you to run it at machine code level. Also the later JVMs will actually recode your application if it is running for a long time to optimize it for speed. Something that compiled exes can't do.

    I've used a number of languages and I would have to say that C is not the best one to start off on. It is not an OO language. It is easy to write piss poor code in that is impossible to maintain. Some languages are bad in this way (Visual Basic being the worst offender).

    If you are going low level I would recommend reading about ASM. It is unlikely that you would program in it (unless its device drivers) but you don't need to know C to do it.

    Writing code in the industry is part of what language is best, speed and maintainability. The last one is a major issue. Companies are big into slotting in new programmers when others leave. Most work in development is maintaining code.

    So go with a language that enforces good coding standards (not by punishing you at runtime), documenting and OO design.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 91,690 Mod ✭✭✭✭Capt'n Midnight


    Merrion wrote:
    C punishes laziness and sloppy thinking so a course in C will make you a better programmer even if in real life you end up using a more high level language.
    given a choice between two similar programs to do the same job one GNU / C and the other Shareware / Visual Basic , almost invariably the C one will be better in all areas apart from eye-candy.


  • Closed Accounts Posts: 92 ✭✭tempest


    given a choice between two similar programs to do the same job one GNU / C and the other Shareware / Visual Basic , almost invariably the C one will be better in all areas apart from eye-candy.
    Assuming that you mean "an application written in" GNU / C ... then I agree with what you say (because you said almost :) ), but would you not agree that perhaps this is more to do with personality/dedication/philosophy/experience of the designers and coders than with the programming language which is used.


  • Registered Users Posts: 7,276 ✭✭✭kenmc


    Hobbes wrote:
    I've used a number of languages and I would have to say that C is not the best one to start off on. It is not an OO language. It is easy to write piss poor code in that is impossible to maintain. Some languages are bad in this way (Visual Basic being the worst offender).

    I would argue that an OO language is not the best one to start off on, because if you become accustomed to OO methodology you would potentially find it quite difficult to go "back" a step to something which didn't handle OO eg C.

    There is no one language that can be called "better" than the others due to the limitations and experience of the programmer that is writing in that language - i.e. a master C programmer would be more than capable of churning out a more stable, secure program faster than a relative newbie in Java or C++ or whatever - it's very dependent on the one who wields the weapon, rather than the weapon itself....

    In my opinion programming is an art more so than a science, (again related to who and what rather than what, hence why it's so difficult to say how long a module will take to write - depends on the writer) albeit a technical art. It is a complex thing to describe in minute detail to a basically dumb machine, what you want it to do. - e.g. how would you tell someone who lives in the jungle how to go about starting a car (assuming they spoke the same language) whats a key. whats the ignition??

    It always goes back to first principles, and the language which can be used in the simplest way (not the same as the simplest language) should be used as a primer, and then the skills built upon. You can't understand how useful classes are until you have experienced not having them firstly. Once someone has an understanding of programming and the thought process behind it, then they can start to worry about how to write secure code. You have to crawl before you can walk before you can run.....

    I've read some interesting articles on the whole art vs science debate also, but I can't for the life of me find them. I did find this though
    http://fresh.homeunix.net/~luke/misc/knuth-turingaward.pdf
    by Knuth which explains why he calls his book "The Art..."


  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    Over the past 3 years (When I started college) I've gone from VB and Assembly in one year to Java and C#. Although the Java was of absolute crap standard... at least what we were taught did C# myself.

    Started in another college and doing much better things with Java far more object orientated and we have recently started with C.

    It is a pain in the ass for me :D
    We have to use a dynamic array in C. Just so used to having collections already there in the API :)

    I would never consider programming a art. Its a trade... at least learning how to do it. To do it correctly is a different story.


  • Closed Accounts Posts: 244 ✭✭osmethod


    Some teaching of C can be from a historical perspective. C was the choice language for the original unix operating system and is still the choice language for sys v/bsd type unix's today and windows oses.

    Computer Engineering tends to look at systems from the systems own point of view. The teaching of C is, in my view, the closest language between systems and human communication.

    With C you need to be able to understand the process involved for a given function to work. If you do not have an understanding of how the system works from its point of view it is difficult to understand how to go about fixing it if it breaks down.

    For example: Within an operating system there is a "Memory Management" subsystem. When a program executes, various parts of the program are mapped into memory. The Os will initially create address space, for the program to execute in. This address space will have the program instructions and data loaded into it. A stack and a heap will be initialised. Stack being a LIFO data structure which stores local variables, functional calls, etc. The heap being a FIFO data structure primarily storing dynamic variables.

    C is an excellent languge for this type of system.

    Software Engineering tends towards higher level languages

    For example: Visual Basic and Database programming on MS systems go hand in hand. Designing a database is more to suit real business processes as in storing company data in tables, designing user friendly forms and structuring queries upon that data. The underlying processes (one as described previously) are of no real concern as these are taken care of. The business in question is concerned about its processes and higher level languages cater for this.

    Hope this clarifies things abit.

    osmethod


  • Registered Users Posts: 7,276 ✭✭✭kenmc


    damnyanks wrote:
    I would never consider programming a art. Its a trade... at least learning how to do it. To do it correctly is a different story.
    Interesting.... why a trade? you mean like a plumber/electrician/plasterer/bricklayer???
    If that's the sort of trade you're likening it to then I don't really understand the link - tradesmen don't do any of the design work involved with whatever they're building - they're just told to build a wall here, plaster it, put sockets here there and everywhere.....
    Whereas in programming/SW engineering it's all about design - least the stuff I do is....
    like the architect designs the house, the programmer/SW engineer designs the system....
    Still reckon it's an art to be honest......


  • Advertisement
  • Registered Users Posts: 4,003 ✭✭✭rsynnott


    Think of C as a form of portable assembly language.

    *hugs C*

    If you want a small, efficient, crossplatform program with minimal dependencies, C is still a good way to go. You can integrate it with Java, or most other things, if you feel like it (Eclipse is one of the more horrifying examples of this).


Advertisement