Jump to content

58 posts in this topic

Posted

Please any one help me with your suggestion......

I need a reason for why C.

Share this post


Link to post
Share on other sites

Posted

Most languages are based off of the syntax of C, and it's widely used. Also, it's low level, so you get more experience, but I think Javascript is a better beginner language since it's easier and includes pretty much the same syntax, just a few kinks and new things you can do, and bam, you know C :P

2 people like this

Share this post


Link to post
Share on other sites

Posted

Compared to other programming languages, C is small and low-level. This means that there aren't many concepts in it, and that these concepts closely map to how computers execute code at the machine level. This is both a learning opportunity and a stumbling block, depending on what it is you're trying to learn. As a systems programming language, I think C should be required to learn computer architecture, but as a general-purpose programming language, it's not representative of most popular languages in use today, and its antiquated compilation model and poor standard library features greatly aggravate its learning curve.

 

This is a matter of debate; some CS curriculums start with a high-level language such as Python, others with a low-level language like C. One can argue both ways. I fall firmly in the first camp, as most people today, I think. Therefore I would advise against learning C first and instead use a high-level language with out-of-the-box REPL support such as Python, Ruby or F#. See:

 

http://programmers.stackexchange.com/questions/124783/why-is-python-recommended-as-an-entry-level-programming-language

http://programmers.stackexchange.com/questions/24159/which-programming-language-is-the-best-to-start-learning-teaching-about-programm?rq=1

http://mcsp.wartburg.edu/zelle/python/python-first.html

http://lifehacker.com/five-best-programming-languages-for-first-time-learners-1494256243/1497409477

 

etc.

 

Above all else avoid verbose, complex, multi-paradigm languages like C++ and Java. One thing at a time.

8 people like this

Share this post


Link to post
Share on other sites

Posted

It depends very much what you're looking to do. C is a low level language, so there are less safe guards in place like you would get with higher level languages such as C#, Java, Python et al. You do get a much more direct interface to the underlying architecture though, and it's a very simple language to learn. I know that Andre and I disagree quite a lot in this regard (although he does raise good points, and I respect his opinion), but I think C is a good language to learn early on purely because it's simple, and it gives you an very clear idea what your code is doing with regards to memory management, basic data structures and the like.

 

The caveat of such a simple and low level programming language of course is that building large applications is much more involved compared to higher-level languages, which means that if you want flashy interfaces and are more interested in things like web programming, C probably isn't the way to go. Otherwise, I recommend it. Even for higher level languages, what you learn in C is very transferable.

3 people like this

Share this post


Link to post
Share on other sites

Posted

I would argue that if you can learn to program in C effectively, you'll migrate to higher-level languages with ease.  Going at it the other way around in no way guarantees success.

 

C forces you to think about what it is you're about to do, whereas higher-level languages are more forgiving, so if you only learn those, you'll be developing bad habits and become part of the crowd that thinks "just throw more memory at it" is a perfectly acceptable solution when your software turns into bloatware.

 

That being said, I'm not suggesting you actually try to use C in production applications.  These days I see it as an important learning tool and not much else.

3 people like this

Share this post


Link to post
Share on other sites

Posted

Everybody here makes a valid point. You can do pretty much anything once you have mastered the C++ language, but isn't the easiest and will require dedication to master and find your own programming flaws to learn from yourself.

I myself am a C# programmer and prefer the safety of it as you can write very inefficient and pretty much redundant code in C++ very easily as a beginner or inexperienced programmer (though the newer Visual Studio IDEs do a lot to help).

It all depends on what you want to be able to do on a machine but if you really want to be able to do anything, I'd say FORTRAN or assembly (really dependant on computer architecture) is the way to go, but they have a level of complexity that are not for everyone. C is pretty much universal and I'm in the camp that would say learn a lower level programming language first as the more experienced you become with it, the more you can do, which is a great plus on a CV.

1 person likes this

Share this post


Link to post
Share on other sites

Posted

I know that Andre and I disagree quite a lot in this regard (although he does raise good points, and I respect his opinion), but I think C is a good language to learn early on purely because it's simple, and it gives you an very clear idea what your code is doing with regards to memory management, basic data structures and the like.

A first language should be simple, and C is simple, so that's one good reason to learn it. However, should a first language closely map to hardware-level abstractions, I think is a mistake. It is too far removed from the problem domain space and makes reasoning about algorithmic considerations difficult because the language is so different from mathematics and contains virtually no useful abstractions for algorithmic purposes. This is why the SICP uses Scheme for instance.

 

Also, there's a good reason not to use it, and that's the lack of an REPL, coupled with a complex, rigid compilation system including hand-written metadata (headers) and a linker step which complicates matters uselessly for beginners.

 

Given that there are simple languages that do not present these difficulties and are better suited for reasoning about algorithmic considerations, I think C is not a particularly good choice as a first programming language.

 

I do agree that C should be required learning as part of a CS degree because it's a useful tool to learn about hardware-level abstractions (and one should know at least one systems programming language). But as an introduction to programming, there are better choices.

1 person likes this

Share this post


Link to post
Share on other sites

Posted

[...]

But as an introduction to programming, there are better choices.

 

I'm gonna disagree *if* someone wants to get serious about programming.  If you wanna do it for a hobby, great--stick with the higher-level languages.

 

But one thing C did when I was in college (over 20 years ago now) was to quickly separate those students who actually wanted to program, and those who were there merely because they had heard there was money to be made in this career path.  We started with over 30 students.  After the first semester, we were down to 15 or so (or was it the first *month*?)...the next 2.5 years were all C++...and clearly, I would NOT want those who couldn't handle C/C++ today as coworkers--even though I now haven't written one line in those languages myself in nearly a decade.

 

As for the claim that "a first language should be simple"...again, I'm gonna disagree.  It took some fellow students nearly 2 years to finally figure out that they weren't cut out for programming.  Had the only languages been taught been something simple, they would've started their careers ill-equipped, and would've hit a wall early on.  At least by starting with a "hard" language, the expectations are set more realistically.

Share this post


Link to post
Share on other sites

Posted

But one thing C did when I was in college (over 20 years ago now) was to quickly separate those students who actually wanted to program, and those who were there merely because they had heard there was money to be made in this career path. 

What specific property of the C language do you think helped achieve this? 

 

As for the claim that "a first language should be simple"...again, I'm gonna disagree.  It took some fellow students nearly 2 years to finally figure out that they weren't cut out for programming.  Had the only languages been taught been something simple, they would've started their careers ill-equipped, and would've hit a wall early on.  At least by starting with a "hard" language, the expectations are set more realistically.

But the C language is simple, i.e. it contains very few concepts. There are basically just "regular" free functions and plain old datatypes, only the most basic control structures (if, while, for, switch, etc), very few built-in types, etc. So if you disagree that a first language should be simple, why are you advocating C? 

 

By the way, I am not saying that only simple languages should be taught; just that, like in any other domain, you start out with the lowest possible barrier of entry. You don't teach integral calculus in an introductory course to mathematics. Presenting very complex and quirky languages (say C++) as first exposure to programming may discourage many people that would otherwise have succeeded just fine, because it gives the wrong impression. 

1 person likes this

Share this post


Link to post
Share on other sites

Posted

The first language I was taught was Pascal back in 1997. I thought that gave me a good footing to get into C, however I was thrown into the deep-end with embedded C++ on the Hitachi Workbench which put me off for life. I then migrated to VB5/6 & VBA and a small amount of HTML (back in like 1999) but never made the jump into OOP (.Net), as I changed role to become a test analyst. I still dabble in the odd bit of VB/A and HTML but I'm very much a novice.

Share this post


Link to post
Share on other sites

Posted

What specific property of the C language do you think helped achieve this? 

 

The fact that it's a down-to-the-metal language (well, without going full-blown assembler).  You have to manage memory yourself, you have to get a good grip on pointers before you start avoiding dumb mistakes, there's no built-in routines or libraries for even simple things like sorting, you have to learn about makefiles and compiler/linker settings (to an extent--less so nowadays)...so you're forced to learn the basics that every serious programmer should know if he wants any hope to figure things out for himself when he strays off the beaten path.

 

Maybe it's not the *language* itself that's difficult to master...but the fact that you have to implement everything yourself and have to think about things like memory management, which you don't have to worry about in other languages.  This is why most of the other students dropped out...some had done a bit of VB and were expecting "programming" to be like that.

 

I understand now where you and I diverged on our respective definitions of "simple".

Share this post


Link to post
Share on other sites

Posted

The fact that it's a down-to-the-metal language (well, without going full-blown assembler).  You have to manage memory yourself, you have to get a good grip on pointers before you start avoiding dumb mistakes, there's no built-in routines or libraries for even simple things like sorting, you have to learn about makefiles and compiler/linker settings (to an extent--less so nowadays)...so you're forced to learn the basics that every serious programmer should know if he wants any hope to figure things out for himself when he strays off the beaten path.

 

 

That's my opinion as well. To me teaching someone programming by starting them out on a higher-level managed language is like teaching someone long division by handing them a calculator.

2 people like this

Share this post


Link to post
Share on other sites

Posted

That's my opinion as well. To me teaching someone programming by starting them out on a higher-level managed language is like teaching someone long division by handing them a calculator.

 

That's a brilliant analogy that summarizes my thoughts exactly.  Wish I would've come up with it.  You want to separate the wheat from the chaff--make 'em sweat a little, they'll thank you later.

 

That being said, again, I'm all in favor of letting hobbyists learn the higher-level languages and stick with them.  I just don't want them putting together a large-scale application that I'm gonna have to fix.  :-p

1 person likes this

Share this post


Link to post
Share on other sites

Posted

The fact that it's a down-to-the-metal language (well, without going full-blown assembler).  You have to manage memory yourself, you have to get a good grip on pointers before you start avoiding dumb mistakes, there's no built-in routines or libraries for even simple things like sorting, you have to learn about makefiles and compiler/linker settings (to an extent--less so nowadays)...so you're forced to learn the basics that every serious programmer should know if he wants any hope to figure things out for himself when he strays off the beaten path.

 

Maybe it's not the *language* itself that's difficult to master...but the fact that you have to implement everything yourself and have to think about things like memory management, which you don't have to worry about in other languages.  This is why most of the other students dropped out...some had done a bit of VB and were expecting "programming" to be like that.

 

I understand now where you and I diverged on our respective definitions of "simple".

Thanks for clarifying. I would question whether dealing with headers, linker errors, makefiles and pointer arithmetic (note that most languages have the analogous concept of a "reference", just not pointer arithmetic) is what "programming" is really about, or whether it is just artifacts of a specific language that get in the way of learning basic, general programming concepts. I've never seen, for instance, an intro course using C that touched on parallel and asynchronous execution, although these are in every program today. The SICP, based on Scheme, does. Or how one might implement garbage collection. Or data streams. Or logic programming.

 

I think one can easily make a case that these are more fundamental and relevant concepts in today's world than C's particular difficulties. They're certainly not any easier, but less language-specific and generally applicable.

Share this post


Link to post
Share on other sites

Posted

This is a matter of debate; some CS curriculums start with a high-level language such as Python, others with a low-level language like C. One can argue both ways. I fall firmly in the first camp, as most people today, I think. Therefore I would advise against learning C first and instead use a high-level language with out-of-the-box REPL support such as Python, Ruby or F#.

Personally in a CS curriculum I think it makes much more sense to start at the low level and build up then it does at a top level. If you start at the higher levels of abstraction then people tend to have no idea what is going on under the hood. From an educational point of view this isn't a good situation. When I learned derivatives they made us do it the hard way so we learned where it came from before they taught us the easy way. If your goal is just to "write a game" then sure start out as far along as you can... use an existing game and mod it, if you want more advanced use an existing engine (Unity, Unreal, Crysis, etc.), you probably shouldn't start from the bottom. If you really want to learn to program though and it isn't a means to an end you should start low and build up. Heck when I was in school we learned assembly first. We just wrote a few simple programs over a couple weeks before we moved on but they wanted you to get the basic concept of how registers and such work (it was just a part of the overall "Intro to Computer Science" course.) Have I touched assembly sense, no. But knowing how a processor works and understanding what a register is and what tedious tasks are abstracted from me are valuable. Same with C. You probably won't want to write programs in C on a daily basis but its simplicity and close to the metal nature teach valuable lessons that are important to understand. I would absolutely not recommend starting at a language that isn't even strongly typed. Again not that these things are bad and once you learn to program then maybe you will prefer to use a untyped/dynamically typed language but I feel having that understanding of what types are and how they interrelate is important for a programmer. It really depends though if you really want to learn to program, or you just want to do something else which requires you know some programming to accomplish.

Share this post


Link to post
Share on other sites

Posted

It all depends on what you want to learn.

 

How they do it at our computer science department is starting with basics of object-oriented programming in Java. Why Java? Because it's a very clean and strict object-oriented language that can serve as a good base for other languages.

 

At the same time another course teaches algorithmic thinking (recursion, loops, sorting, ...) using Javascript/Java (depending on the teacher). I think this is a good way to start. 

 

We also had an introduction to x86 assembler (which I really liked).

 

In my opinion there is not that much reason to know about all those deep low-level concepts right away as they might get in the way of good design at first. Getting the right OO principles in from the start makes you think about maintainable, clear, concise code much sooner and stops you from getting used to weird workarounds.

Share this post


Link to post
Share on other sites

Posted

I really think before you use a programming language, you should use a visual programming language. I know, it sounds really stupid, but it can help with learning with logic. You'll face the same programming challenges as you do with any other language except you don't have to memorize syntax. Logic. logic. logic. That's what's important. Then I would recommend a glance over Javascript, to get used to typing programming, syntax, compiler errors, etc. Then I would, as said before, build from low level, like C, to the top.

Share this post


Link to post
Share on other sites

Posted

We can all give you our opinions, but that's just what they are. The only real way you're going to understand the importance of learning C is by writing programs in it.

 

As someone who primarily codes in C, its importance as a first language cannot be overstated. Yes, that's right, I said first language. Some might argue that higher level languages are easier for a beginner, and I can tell you right now that's wrong. Higher level languages like Python and Java are perfectly good languages, but are also very complicated and have lots of concepts to grasp. Conversely, C is simple, perhaps one of the simplest. It has very few keywords and concepts. It's a procedural programming language (sometimes called imperative), which means it's based around functions or subroutines depending on your preferred terminology. This allows the programmer to ignore the nebulous concepts like objects and classes, if he so wishes, that other higher level languages are often based on.

 

Another benefit, which is often overlooked, is that of edification. Learning C can give you an insight into how best to manage program resources, something that is often hidden from the programmer in other languages.

 

As others have said, once you've mastered C, learning pretty much any other language is child's play. It gives you a firm grasp of how real programs work, without the obfuscations of higher level languages. Be warned though, once you get a taste for C, you probably won't want to give it up for anything else ;) I know I don't. 

 

If you're really serious about understanding computers and how software works, grab a GNU/Linux distro (Xubuntu, Mint, Arch, Debian, etc), familiarise yourself with the terminal and essential programs such as screen, and start learning GCC/GDB, VI/Vim, and the Make/GNU Autotools. It's all free and available through a distro's package manager. No bloated IDE's required. Just a powerful and simple terminal is all you need to learn and write standard C.

Share this post


Link to post
Share on other sites

Posted

However, should a first language closely map to hardware-level abstractions, I think is a mistake.

The less obfuscation the better in my opinion. Anyway, it doesn't really map to hardware any differently than C derived languages. Pointer arithmetic is perhaps the exception.

It is too far removed from the problem domain space

Without understanding basic programming concepts, how can one hope to solve problems or make best use of the resources available? Ignoring essential notions such as data structures won't help anyone in the long run. Start at the beginning, and start simple. That's how I've always approaching learning in general.

It's like telling someone to learn the subjunctive mood before they even have a grasp of the basic grammar of a written language.

and makes reasoning about algorithmic considerations difficult because the language is so different from mathematics and contains virtually no useful abstractions for algorithmic purposes. This is why the SICP uses Scheme for instance.

If someone's goal and focus is solely mathematics or related field then I'd agree. But the OP is clearly interested in programming languages and the role of C.

And don't forget, there are many C libraries available that one can plug into. The C standard library itself is just another library. Glib for instance provides support for object oriented style programming, as well as commonly implemented data structures.

Given that there are simple languages that do not present these difficulties and are better suited for reasoning about algorithmic considerations

I'm not sure why higher level languages like C# would be any better for "algorithms considerations", unless you're talking about having built-in stock data structures and functions, all of which as I mentioned above are available in libraries.

Besides, how will a beginner learn anything if the language does everything for them. Or what happens when they decide that the built-in functions don't satisfy program requirements. Then they're really stuck. Learning the fundamentals, including creating basic data structures and algorithms is what computer science is all about. Spoon feeding does them a disservice and discourages critical thinking.

Share this post


Link to post
Share on other sites

Posted

I learned top down (Python first). If I had learned bottom up (C first) I'd have washed out. I did eventually learn C, I didn't realise at the time of 'learning' it that I pretty well already knew it. It's such a simple language. I believe It only appears simple after you've learned other languages though.

 

I should point out I'm not a typical programmer with a mathy brain. I approach code in a more visual and artistic way if that makes sense. But, learning C has shifted my mindset on modern paradigms to the point where I've learned that beautiful, sophisticated code isn't always the best and bare-knuckle, git-er-done functions are sometimes all you need, actually quite often in fact.

 

I can see some peoples reasons for thinking that learning a low-level language first will separate the men from the boys, but I think that's just typical 'Real programmers use X' talk and I see little merit in it. as for the 'Learning low-level gives you a broader understanding of high-level philosophy', I agree completely, but I think that's still achievable after learning a high-level language which is a nicer entry point. Programming doesn't need to scare anyone to prove you can do it long-term as it's really quite simple to program.

 

 

tl;dr: Learn C, eventually, not first.

Share this post


Link to post
Share on other sites

Posted

Personally if you have no experience  I would start with a just a couple days to a week of learning BASIC then start learning C

 

Link to Microsoft Small BASIC http://www.microsoft.com/en-us/download/details.aspx?id=22961

Share this post


Link to post
Share on other sites

Posted

Personally if you have no experience  I would start with a just a couple days to a week of learning BASIC then start learning C

 

Link to Microsoft Small BASIC http://www.microsoft.com/en-us/download/details.aspx?id=22961

I would recommend QB64, you're going the BASIC route.

Share this post


Link to post
Share on other sites

Posted

I learned top down (Python first). If I had learned bottom up (C first) I'd have washed out. I did eventually learn C, I didn't realise at the time of 'learning' it that I pretty well already knew it. It's such a simple language. I believe It only appears simple after you've learned other languages though.

That seems contradictory to me. You said yourself that by the time you learnt Python you already knew most of C. Well that's the whole point. C is tiny compared with Python. Therefore it stands to reason that you would have picked up C even quicker.

I think some people have a misconception that C is somehow difficult. It's not at all. Problems are difficult to solve, not C itself. And the concepts you learn in relation to resource management will teach you valuable information about how computers work. Anyone who's serious about learning programming and computer science should have a grasp of the fundamentals of how software works.

I should point out I'm not a typical programmer with a mathy brain. I approach code in a more visual and artistic way if that makes sense. But, learning C has shifted my mindset on modern paradigms to the point where I've learned that beautiful, sophisticated code isn't always the best and bare-knuckle, git-er-done functions are sometimes all you need, actually quite often in fact.

That's exactly it. While programming in highly abstracted languages is fine and dandy, writing your own data structures and algorithms from scratch is both very satisfying and edifying at the same time. It expands one's horizons. I couldn't ever imagine only writing in high level languages. I'd lose a critical skill.

Share this post


Link to post
Share on other sites

Posted

That's exactly it. While programming in highly abstracted languages is fine and dandy, writing your own data structures and algorithms from scratch is both very satisfying and edifying at the same time. It expands one's horizons. I couldn't ever imagine only writing in high level languages. I'd lose a critical skill.

True, but depends on your goals. Self-enlightenment is always a good thing of course (and one of the few times I'll agree with you).. working under a time-crunch to get a job done so you can pay the bills is something else entirely. It's not the perfect language for every job.

Personally - for a balance of usefulness, extensibility, productivity (so quick to get anything done in it) and just plain easy to wrap your head around, I'd probably pick Python myself and go from there. Stupidly easy to read and you don't have mountains of boilerplate and other hassles you need to deal with like some other languages.

Share this post


Link to post
Share on other sites

Posted

I did OS programming in C for 4 years. God I grew to royally hate C.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.