You are not logged in.

#1 2009-03-03 19:08:54

genisis300
Member
From: Uk
Registered: 2008-01-15
Posts: 284

c or c++

hi all,

It's time for me to learn a new something new. I thinking of learning c or c++ but not sure which one to go with.

Could anyone make some good sugestions? and possible reasons for using on over the other
my history so far is as follows
Qbasic
Vbasic 6
vb.net
python
PHP


Kind Regards
Matthew


"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson

Offline

#2 2009-03-03 19:16:48

TheBodziO
Member
From: Dukla, Poland
Registered: 2006-07-28
Posts: 230
Website

Re: c or c++

Is learning new language a goal by itself or are you planning to put it in some foreseable use?


It's not the best thing when they call you a "member" you know… wink

Offline

#3 2009-03-03 19:20:46

genisis300
Member
From: Uk
Registered: 2008-01-15
Posts: 284

Re: c or c++

going to put in some use smile sorry, I'm looking at writing a Backup program. so i figure i will learn a new c/c++ while i'm at it.

it's been on my list of to-dos for a long time.

Last edited by genisis300 (2009-03-03 19:21:08)


"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson

Offline

#4 2009-03-03 19:21:18

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,399
Website

Re: c or c++

As pointed out above the use you want from the language should make that decision for you.  That said, I believe that being a C++ coder working on C code is easier than being a C coder working on C++ code.  I prefer C++ mainly because of the STL.

Offline

#5 2009-03-03 19:49:41

TheBodziO
Member
From: Dukla, Poland
Registered: 2006-07-28
Posts: 230
Website

Re: c or c++

I see that you've got some experiences with php which can use some c-like syntax and that gives you some preliminary knowledge. The rest depends on how you look (or would like to learn to look) at your program. If you want to write a program and see objects—choose c++. Other way—choose c. I think it's not so much about learning one or another—it's more about taking procedural or object oriented (not quite in c++ as some purist would say) way. The language used is of lower importance here.

Whichever you'll choose, you'll stay closer to the the other than you think smile.

Also I have to agree with Allan about relative ease of working with c and c++ code.


It's not the best thing when they call you a "member" you know… wink

Offline

#6 2009-03-03 20:03:54

Zeist
Arch Linux f@h Team Member
Registered: 2008-07-04
Posts: 532

Re: c or c++

In general learning either of them will make learning other C-based languages rather easy. C/C++/C#/Objective-C/...and so on really have a lot in common and are incredibly similar.


I haven't lost my mind; I have a tape back-up somewhere.
Twitter

Offline

#7 2009-03-03 20:06:05

tam1138
Member
Registered: 2007-09-10
Posts: 238

Re: c or c++

I am a luddite.  I like C.

Offline

#8 2009-03-03 20:10:50

andre.ramaciotti
Member
From: Brazil
Registered: 2007-04-06
Posts: 649

Re: c or c++

There's no problem in writing object-oriented programs in C. You can use structs and functions that read and write data into these structs (eg. that's what GTK does).

Personally, I'd go with C.


(lambda ())

Offline

#9 2009-03-03 21:23:33

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: c or c++

Why not Lisp?

But if those are your only choices, C. There are better languages than C++ for its intended purpose, but C pretty much dominates its niche. Just don't start misapplying it rather than using a task-appropriate language (e.g. if you're writing a desktop app, you already know three languages more suitable than C).

Offline

#10 2009-03-03 22:22:13

TheBodziO
Member
From: Dukla, Poland
Registered: 2006-07-28
Posts: 230
Website

Re: c or c++

andre.ramaciotti wrote:

There's no problem in writing object-oriented programs in C. You can use structs and functions that read and write data into these structs (eg. that's what GTK does).

I agree as long as you mean "object oriented" wink


It's not the best thing when they call you a "member" you know… wink

Offline

#11 2009-03-04 15:39:05

namegame
Member
Registered: 2008-07-29
Posts: 31

Re: c or c++

Allan wrote:

I prefer C++ mainly because of the STL.

I definitely agree, the STL is a godsend, assuming you know what the STL contains. wink

Offline

#12 2009-03-04 23:46:40

jamesbannon
Member
From: Paisley, Scotland
Registered: 2008-10-24
Posts: 50

Re: c or c++

C++ - you can write C programs using it if you have a mind + it has all the OO "goodies" and generic programming. Be warned though, it's damned complicated! It's also quite unlike any of the other languages on your list, so you have to get used to the differences.

Offline

#13 2009-03-05 04:11:34

genisis300
Member
From: Uk
Registered: 2008-01-15
Posts: 284

Re: c or c++

So far i'm trying C++ i found a nice book that i picked up a while back. i seem to collect programming books for some reason. So far all seems okay. I'm sure i will get stuck shortly mind.

Thanks for all your input i will let you know how i get on smile


"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson

Offline

#14 2009-03-05 07:31:10

Yannick_LM
Member
Registered: 2008-12-22
Posts: 142

Re: c or c++

namegame wrote:

I definitely agree, the STL is a godsend, assuming you know what the STL contains

Same thing for boost wink
All you need is there: smart pointers, filesystem, and so on.
Also a must-have if you plan to be cross-platform.

Offline

#15 2009-03-05 08:22:09

krigun
Member
From: Norway
Registered: 2005-06-06
Posts: 122
Website

Re: c or c++

Yannick_LM wrote:
namegame wrote:

I definitely agree, the STL is a godsend, assuming you know what the STL contains

Same thing for boost wink
All you need is there: smart pointers, filesystem, and so on.
Also a must-have if you plan to be cross-platform.

Yes, there are actually quite a lot of good cross-platform libraries for C++ (boost, TBB, QT), and now that QT has become LGPL it has suddenly become an API at least I want to study further. So, if you combine them all, you get the Java SDK wink

By the way: What is such a fantastic library like TBB (Intel® Threading Building Blocks) doing in AUR, instead of [extra]? The library makes parallel programming in C++ much, much easier.
http://www.threadingbuildingblocks.org/

Last edited by krigun (2009-03-05 08:28:00)

Offline

#16 2009-03-05 09:02:46

archlinuxsagi
Member
Registered: 2008-09-12
Posts: 259

Re: c or c++

mmm. I was a C programmer and later moves on C++.

Below is my thought on when to C or C++.
C - used for linux kernel, drivers and also smaller in size and occupy less memory.
   - also used for linux generic utilities : pacman for example and many others.
C++ - mostly used by GUI programs due to object-oriented nature, use more memory due to constructor and destructor codes.
         But used for GUI programs to easily extends using inheritance and polymorphism.

Offline

#17 2009-03-06 02:18:10

jamesbannon
Member
From: Paisley, Scotland
Registered: 2008-10-24
Posts: 50

Re: c or c++

I think you're being a bit harsh there. A hosted implementation of C++ does require more runtime support admittedly (mostly to do with exceptions and dynamic type queries), but, in general, there is no real reason to say that C++ leads to larger or slower programs.

Offline

#18 2009-03-06 11:43:02

Xilon
Member
Registered: 2007-01-01
Posts: 243

Re: c or c++

TheBodziO wrote:

If you want to write a program and see objects—choose c++.

Or Objective-C (a real superset of C), or just use loosely coupled functions operating on a single struct. All OOP principles can be emulated using C. Glibc, Objective-C, Python, Io, and a bunch of other languages/libraries are proof of this.

jamesbannon wrote:

C++ - you can write C programs using it

Umm, no you can't. C++ and C are different languages and are incompatible with each other.

jamesbannon wrote:

it has all the OO "goodies" and generic programming.

You mean templates? One could argue if that's a good thing tongue

As far as writing a backup utility, I wouldn't really use either languages, unless you require good performance. Use a higher-level language, like Python. If you want to learn a new language then look for some other high-level language. C is especially tedious to work with at times. In the long run it will be a smarter choice to use a higher-level language.

If you wish to learn a new language then C would be a great start. It teaches you a lot about the processor, memory, and generally about programming. It's basically like the Linux of operating systems. If you want a language with OOP support, my favorites are Objective-C (learning C beforehand would be beneficial) and Python. Objective-C is a strict superset of C, meaning that you can compile a C program with an Objective-C compiler. It is strictly typed, but allows for dynamic typing (by using id, much like void * in C). It uses messages rather than calling functions, like Smalltalk. It has properties, so you don't have to write getters and setters. It has a nice system for memory management, and some implementations have garbage collection. It has a bunch of other cool features such as Categories. The biggest downside is popularity and compatibility - it's the main languages used for Mac OS (and iPhone) development, but isn't really used anywhere else. Python is nice because it is multi-paradigm and supports a bit of functional programming. It's duck typing allow for a lot of "magic" and reduces complexity. It has nice support for creating portable programs.

If you want to learn something new then perhaps look into Lisp, Haskell, Erlang, or any of the other functional languages. Haskell is a very interesting one since it is a pure functional language and makes you think a lot more about designing functions. However, it does have quite a steep learning curve.

I would advise against using C++. It might be beneficial to be familiar with it, but in my opinion it's a very ugly language. The most annoying thing is templates. Defining them seems like a hack - having to write the implementation in the "interface" (.h file). Using them isn't that great either. It's mostly just a hacky workaround for being statically compiled and calling functions, rather than sending messages. In Objective-C "templates" are trivial and very natural to implement. You basically specify a protocol, and just send the message. In Python this is achieved by being dynamically typed. I'm not really a fan of overloading operators either. Not so much the concept, but some implementations, which are less than intuitive. I'm sure there are more things that annoy me, but I haven't used C++ for a long time, and I'm not all that familiar with it either, so I'll just link to another rant about C++.

TLDR:
For the backup utility use a high-level language like Python.
If you just want to learn a new language look into functional languages like Haskell.

Offline

#19 2009-03-06 13:35:30

krigun
Member
From: Norway
Registered: 2005-06-06
Posts: 122
Website

Re: c or c++

Xilon wrote:

I would advise against using C++. It might be beneficial to be familiar with it, but in my opinion it's a very ugly language. The most annoying thing is templates. Defining them seems like a hack - having to write the implementation in the "interface" (.h file). Using them isn't that great either.

That silly statement right there is just plain FUD. First of all, nobody forces your hand to create templates when you are writing code in C++. Second, I can't believe you said that C++ is THE HORROR, but Obj-C, now THERE is a real OO language for you. There are so many things wrong with Objective-C that I wouldn't even know where to start.

Thing is that a programming language is a tool - nothing more and nothing less [insert comment about if all you have is a hammer, you'll treat everything as a ...]. Fact of the matter is that most graphics code written today is written in C++, so if you wish to do any kind of graphics programming or physics simulations, you should at least have some familarity C++. If you wish to work with enterprise server applications, then Java would be your best bet. And so on, and so on and so on. No one programming language is good for everything. Sure, you can use Erlang to write a 3D modelling package (oh, look - it has already been done http://www.wings3d.com), but that doesn't mean that there isn't a better suited language for creating such appliactions.

Offline

#20 2009-03-06 13:45:53

archlinuxsagi
Member
Registered: 2008-09-12
Posts: 259

Re: c or c++

mmm.. this is starting to be a flame war between C++ and other language....

Offline

#21 2009-03-06 13:52:14

cleanrock
Member
Registered: 2008-11-17
Posts: 109

Re: c or c++

Imo, C is a subset of C++ .. so go with C++.
I recently bought the book "C++ Primer Plus" to have a modern C++ book, very good book, check it out.

Offline

#22 2009-03-06 14:33:27

genisis300
Member
From: Uk
Registered: 2008-01-15
Posts: 284

Re: c or c++

i've used python before it's nice to use and would be fine for the Backup program i have in mind. i just figured that while i'm working on a new project i would finaly take the plugne and learn c / c++ it would probably be better to use something else but alot of the projects i want to get involved with are using c / c++ i'm not expecting to be able to do much with them just yet but i understand programming concepts. i can often look at code and work out what it's doing(i'm sure there are lots of people that can do this) i was helping a friend with a program for one of the aurduno things (logic boards) that uses c++ and i like the look of it. although the program was so simple it has harldy touched on any of the functions within c++.

i noticed that alot of the stuff within linux is written in either c or c++ along with python and as i can use python already the logical step seems to be to look at c or c++

it's very good to see peoples comments for and against but please don't turn this into a flame war.


"is adult entertainment killing our children or is killing our children entertaining adults?" Marilyn Manson

Offline

#23 2009-03-06 21:48:10

pauldonnelly
Member
Registered: 2006-06-19
Posts: 776

Re: c or c++

krigun wrote:
Xilon wrote:

I would advise against using C++. It might be beneficial to be familiar with it, but in my opinion it's a very ugly language. The most annoying thing is templates. Defining them seems like a hack - having to write the implementation in the "interface" (.h file). Using them isn't that great either.

That silly statement right there is just plain FUD. First of all, nobody forces your hand to create templates when you are writing code in C++. Second, I can't believe you said that C++ is THE HORROR, but Obj-C, now THERE is a real OO language for you. There are so many things wrong with Objective-C that I wouldn't even know where to start.

I don't know much about Objective-C (which seems nice enough, but like I said, I've barely touched it) but I agree with him that C++ is one of the most horrific programming languages I've seen. It's like every single thing about it is wrong.

I don't want to get into an argument about it here — you can read the FQA as well as anybody — I just want to put in another vote for C++ being awful. Wide use is not a guarantor of quality. Miley Cyrus may have even more fans than C++, but that doesn't mean I'm going to program in her.

Personally, I'd write speed-critical programs in C, and if the program had a component that was too interesting to be practical in C, I'd either embed my C code into another language or embed another language into my C program.

Last edited by pauldonnelly (2009-03-07 08:42:29)

Offline

#24 2009-03-07 07:49:18

TheBodziO
Member
From: Dukla, Poland
Registered: 2006-07-28
Posts: 230
Website

Re: c or c++

Xilon wrote:
TheBodziO wrote:

If you want to write a program and see objects—choose c++.

Or Objective-C (a real superset of C), or just use loosely coupled functions operating on a single struct. All OOP principles can be emulated using C. Glibc, Objective-C, Python, Io, and a bunch of other languages/libraries are proof of this.

I agree about Objective-C but since a question was about C or C++ I suggested one of them to keep on topic.

I'm curious about implementation of OO principles in C. Could you elaborate more about it or at least give a couple of links to some examples? I mean a little bit more than packing data and functions into a single struct.


It's not the best thing when they call you a "member" you know… wink

Offline

#25 2009-03-07 08:07:44

daf666
Member
Registered: 2007-04-08
Posts: 470
Website

Re: c or c++

pauldonnelly wrote:

you can read ...

Nice read!... , thanx
"If you are an expert in the intricacies of C++, please consider this knowledge a kind of martial art - something a real master never uses. "

Offline

Board footer

Powered by FluxBB