Is C only for systems, or is it good for general purpose?

Page 1 of 1 [ 11 posts ] 

zacb
Veteran
Veteran

User avatar

Joined: 7 May 2012
Age: 30
Gender: Male
Posts: 1,194

29 Dec 2012, 9:27 pm

I was told originally to learn C. Now Here I am not knowing what to do with it. Should I learn another language if I want to primarily do application programming? Thanks



Fnord
Veteran
Veteran

Joined: 6 May 2008
Gender: Male
Posts: 60,939
Location:      

29 Dec 2012, 9:32 pm

The Arduino Uno Microcontroller uses software that is a simplified derivative of C++.



zacb
Veteran
Veteran

User avatar

Joined: 7 May 2012
Age: 30
Gender: Male
Posts: 1,194

29 Dec 2012, 9:40 pm

I was talking more for desktop use. I guess I want to develop application, and I was wondering if it was more to understand concepts, or if there is an actual use besides low level stuff.



ruveyn
Veteran
Veteran

User avatar

Joined: 21 Sep 2008
Age: 88
Gender: Male
Posts: 31,502
Location: New Jersey

29 Dec 2012, 9:41 pm

One can write mathematical type programs using C.

It does not look quite is "algebraic" as FORTRAN but it is doable.

ruveyn



drh1138
Velociraptor
Velociraptor

User avatar

Joined: 2 Dec 2012
Gender: Male
Posts: 498

30 Dec 2012, 1:44 am

I actually have come to like C/POSIX over C++; some of the facilities provided by C++ over-complicate things and C is a lot more flexible and free-form with structs. I'd also give Python a try if you can't get by without OOP.



Trencher93
Velociraptor
Velociraptor

User avatar

Joined: 23 Jun 2008
Age: 125
Gender: Male
Posts: 464

30 Dec 2012, 7:38 am

C is a general purpose language that can be used to write anything. There is probably more C code today than any other language just because C has been around so long. Other languages can be more productive because they have large amounts of high-level libraries already written. C++ for example has generic data structures that would be possible to write in C, however there's absolutely no justification to take the time to write them when you can use C++. Java has a huge amount of networking code already written, and other code like AJAX libraries on top of that, so while you can write BSD socket code from scratch in C, it's just not worth the time it would take. The flip side of this is overengineering is threatening the collapse of software development under its own complexity. By the time you write a Java program that uses J2EE, EJB, AJAX, Spring, Struts, Hibernate, JDBC, JPA, JDO, and everything else, and do presentation using JSP, JSF, JSTL, EL, HTML, CSS, JavaScript, jQuery, jQuery plug-ins, and everything else, the project collapses like a skyscraper being demolished. I think one more MVC library will be the straw that breaks the camel's back.



stands2reason
Tufted Titmouse
Tufted Titmouse

User avatar

Joined: 27 Dec 2012
Age: 34
Gender: Male
Posts: 39

30 Dec 2012, 10:04 am

Move on to C++. C was literally designed as a high-level assembly language for writing system software, and with a good compiler and programmer, it's basically as efficient. The idea is you can basically visualize what software is doing on a CPU or VM after learning C. When you study comp org or OS, they will often use C-like psuedo-code as the go-to high level assembly language to explain some concept even at the hardware/CPU level.

C++'s template functionality (a.k.a. static polymorphism) is powerful, valuable, and will take some time to learn. It still beats what Java has to offer in generics. Note that C/C++ does not have a built-in library for GUI if that's what you mean by "desktop application", but you can use libraries like Qt (mature and cross-platform).



RazorEddie
Veteran
Veteran

User avatar

Joined: 18 Jan 2012
Age: 54
Gender: Male
Posts: 610

30 Dec 2012, 7:05 pm

For application programming, C++ and other OOP languages definitely have advantages. To be honest, even for system and embedded programming I use C++ when I can.

Remember, C++ is a superset of C. All C syntax and functionality is available in C++ so you can start with C synrax then add in C++/OOP programming styles as you get used to them.


_________________
I stopped fighting my inner demons. We're on the same side now.


Vectorspace
Veteran
Veteran

User avatar

Joined: 3 Oct 2012
Age: 35
Gender: Male
Posts: 903
Location: Germany

30 Dec 2012, 10:23 pm

Knowing C is certainly not wrong. In fact, I think every programmer should know C.
C is still used in a lot of places, but it's often perverted.

When it comes to end-user programs and you're not that worried about efficiency, dynamic high-level languages like Python will give you much quicker success.
But C knowledge is very helpful as a foundation if you want to learn Java or C++ (for more serious programs).

Technically speaking, C++ isn't a strict superset of C, and it shouldn't be considered one. C++ provides certain features that help you to keep your code clean (I'm primarily talking about memory management). You don't have to use them, but you should.
Nevertheless, most C++ code is just rephrased C code, and even if you don't want to use plain C, it's a good idea to know how it works, because C is very close to the actual machine.



stands2reason
Tufted Titmouse
Tufted Titmouse

User avatar

Joined: 27 Dec 2012
Age: 34
Gender: Male
Posts: 39

01 Jan 2013, 4:51 pm

C is still around, will be for a long time. You still need to know classic C idioms but you shouldn't prefer them. There are "C++" projects that either started their life as C projects, or were mostly written by the more engineering types that are more likely to just know C and so that's what they write.

When I say you shouldn't prefer them, C's security/stability flaws can be fixed by using new C++ features (which have since become standard OO features in its descendants Java and C#).

-unchecked array access vs safe containers
-raw mem-copy, vs safe containers and stream objects.
-hidden error flags that are rarely checked vs exceptions that automatically stop the program and propagate information about an internal error up the stack.
-void pointer runtime type casting vs polymorphic classes, which can more safely handle dynamic typing of data.

But you will still deal with C code interacting with old libraries, plus existing code on old projects that does it the wrong way with C idioms (even in a "C++" project). Hopefully you will know enough to debug and fix C related bugs as they will continue to pop up.



MyFutureSelfnMe
Veteran
Veteran

User avatar

Joined: 26 Feb 2010
Age: 46
Gender: Male
Posts: 1,385

02 Jan 2013, 4:46 pm

Learn C first, then learn C++. C++ is still in common use for app development, and will likely have a niche for a long time as the "higher performance" language.