Click to See Complete Forum and Search --> : Programming use


DrDrake
11-27-2000, 11:15 AM
Ok, bear with me here for a minute:

Why program? Currently I have been on a quest to learn C++, but really what is its use? How do I transform cout << "blah\n"; into a actually useful program? Especially now that many programs (atleast commercial), try and get away from the CLI. How does this language help in the GUI world? How does cout << "blaj\n"; go to a graphical program without spending a overly exorberant amount of time?

Can anyone explain this to me? Or possibly explain how programming in C++ will help me in the GUI world?

Maybe should I learn java instead? I have looked into GTK a bit also. Suggestions please..

DrDrake

[This message has been edited by DrDrake (edited 27 November 2000).]

Stuka
11-27-2000, 11:40 AM
Heck, C++ isn't just about the command line. Just because that's where you start to learn a language doesn't mean that's all it can do. C++ is, IMHO, one of the most powerful languages for modern developers. As for GUI uses, the Qt libraries (used to develop KDE, among other things) are a very good GUI framework written in C++. As to how the language can help in the modern world, look through the classifieds and see how many C++ developers are wanted. Don't get me wrong, there's nothing wrong w/Java, just don't discount the power and usefulness of C++.

DrDrake
11-27-2000, 11:54 AM
I am not saying C++ isnt powerful, I am just reaching a point where I know a few c++ commands etc. I just want to actually show myself I can make something useful, but it just isn't materializing. I still don't understand a pointer (yes I know it points to a memory location.. but why is this useful?), but I do understand class declarations etc. pretty well, but cant program a decent, functional program.. anyone else have this problem?

BrianDrozd
11-27-2000, 11:58 AM
Stick with it. You have to learn to crawl before you can walk you know, so while you're learning it, go ahead and use the standard input and output. When you start doing GUI programming, you'll find you can very similar functions to read from and write to character strings. (It's been a long time since I've used the C++ forms of standard in and standard out, but I know there is a C++ class that provides the read / write functions for a string. Both C and Java have that functionallity, so C++ will as well.)

GUI programming in C++ (or any language for that matter) can be a pain in the @ss as it is, you don't need the added headache of trying to learn how to write or read on top of it.

Besides, when trying to debug a program, it's always good to be able to print some variables to standard out. It's usually easier that way, and then if you happen to forget one debug statement before releasing the code to others who will never see the command line, they won't see the debug statements either.

BrianDrozd
11-27-2000, 12:15 PM
Originally posted by DrDrake:
I am not saying C++ isnt powerful, I am just reaching a point where I know a few c++ commands etc. I just want to actually show myself I can make something useful, but it just isn't materializing. I still don't understand a pointer (yes I know it points to a memory location.. but why is this useful?), but I do understand class declarations etc. pretty well, but cant program a decent, functional program.. anyone else have this problem?

Pointers are useful because they simply point to locations in memory. As such they can referance just about any data. For example, in C++ (amoung other languages) you cannot set up an array that will accept different data types. In other words, array A cannot contain an integer, a floating point value, a string, and a structure. However, we could set up a array of pointers, and then one pointer could point to a integer value, another pointer to a floating point value, and so on. This isn't quite as useful if you don't keep track of the data type the pointer points to as well (which Java does for you, behind the scenes), but it can be very useful in when setting up a variety of structure and classes.

Pointers are almost a necessity when trying to build a data structure with a variable size, like for example a binary tree or a graph structure. By creating a 'node' that contains the needed data and pointers to other nodes, very large and complex graphs can be created and stored in a useful manner.

Also, pointers are useful when you need to pass one funtion to another function. In this way you could write a sorting function that accepts another function that does the comparision. Doing so allows you to use the same sorting function to sort alphabetically, or reverse alphabetically, by name, address, or whatever other selected field you want. This is how a database's sort algorithms are usually writen, for a more practiacle example, so that you can sort by name, address, phone number, age, whatever at run time.

Hope this helped.

DenisL
11-27-2000, 06:57 PM
I was in the exact same position as you were, seven years ago.

I was an ignorant 11 year old thinking I'm going to learn C++ that way I can modify Space Quest and add my own levels. http://www.linuxnewbie.org/ubb/wink.gif

After learning about programming in general (more like after getting frusterated with it) I stayed away for awhile. Then when Linux came around I started playing with C. Then the GTK libraries, and now C++ and QT. My point in all this is that learning to program is very overwhelming as there is a lot to know before you can do anything useful. If you stick with it, eventually you'll be able to code actual software, but it will take lots of time and experience.

I'm now after seven years at the point that I can code very basic GUI apps... It's a gradual progression.

Now that I can (almost) code half decent I sure love doing so. I swear it's an artform... Am I the only one that find code beautifull?

dunno
11-27-2000, 10:41 PM
Wow, that's exactly what I thought when I started. I started to learn C++, but I didn't make any programs, I just read the book, then I dropped it all together when I realize that the book wasn't going to tell me how to create GUI programs.

At least a year later I find myself playing a very basic text-game, a mud. It was so intresting and I thought to myself, how easy could programming a text game be? I don't know graphics, but I know cout and cin! So I learned C, then I switched over to C++ (trust me, C++ is 100 million times better than C, C sux). That's what restarted me, now I can't get enough.

C++ is possibly the leader in the GUI world, but think of GUI as an... "add-on" to the language, you got to know the language first. Then you can learn something like GTK+ or Visual C++ (if you swing that way).

One more thing... pointers don't look important at first, probably because you haven't made any real programs yet. But... LEARN POINTERS REMEMBER POINTERS EAT POINTERS LOVE POINTERS!!! POINTERS!!!

... if you didn't understand the capital lettered semi-statement above, pointers are important.

Oh yeah, I think Java is... S L O W... It took like a minute to compile two lines on my comp, and I have a nice comp. Me and my friend were joking about how long it would take a Java based operating system to load.

(Side note: I'm standing by my thought that C is useless and sux and you should always use C++)

------------------
"I'll get enough sleep when I'm dead."
--Left Behind, The Movie

[This message has been edited by dunno (edited 27 November 2000).]

jemfinch
11-28-2000, 03:05 AM
(Side note: I'm standing by my thought that C is useless and sux and you should always use C++)


That's because you're dumb.

The kernel is written in C. The compiler is written in C. Your shell is written in C. X is written in C. GNOME is written in C. Your mail client is written in C.

Basically, everything good that isn't KDE is written in C. It certainly doesn't "suck" and the day someone can validly call it "useless" is the day processors stop being made with an imperative design model and unix stops being used.

That is, never.

Jeremy

pdc
11-28-2000, 03:40 AM
Jeremy,
you be 'da man! C is a high performance language. C++ is a facilitating language. They both have their place.

but (for dunno) ... do this: create a "hello world" in c and c++, using printf for c and cout for c++ and compare the resultant size of the programs. The last time I tested, there was a doubling of size. The killer is I cannot predict the size with C++ and optimize for architecture. With C, I know that most chips will have a minimum 16kb code stack and a 16bk instruction stack. I can write code that fits that minimum or at least tries to fit into a 64k l2 cache.

Paul

DrDrake
11-28-2000, 08:44 AM
Either way I appreciate his comments, he seems to know exactly what I was going through.. probably what he was referring to is the many addons C++ has for beginners that may not be as easily implemented in C, such as classes, and just doing a cout << variable; rather than printf("%s",variable); . I know I find it much easier to learn C++, and effeciency is neither here nor there on the programs I am writing (On a PIII 733 I dont think it matters at all weather my 10 line text program is written in C or C++...)

Anyways, thanks for all the comments guys, good to see I am not the only one

BrianDrozd
11-28-2000, 09:51 AM
Just wanted to respond to something here.

Originally posted by dunno:
Oh yeah, I think Java is... S L O W... It took like a minute to compile two lines on my comp, and I have a nice comp. Me and my friend were joking about how long it would take a Java based operating system to load.
[/B]

Yes, Java takes a while to compile, though it is much more noticable on small bits of code than on larger code. There's a certain amount of time that it takes just to get the javac program running and that's constant regardless of the amount of code being compiled. Once compiled, my understand as of about a year / year and a half ago is that Java speeds are usually on the same order as the C++ counterparts, and even faster in some cases.

Second, Java could not be used to write an operating system. (Well, it could, but only to the same extent as say VB or COBOL could.) Java cannot give you direct access to any hardware or system resources, which kinda defeats the purpose of writing an OS in Java doesn't it. Java has to go through the JVM first.

Dru Lee Parsec
11-28-2000, 01:23 PM
Second, Java could not be used to write an operating system. (Well, it could, but only to the same extent as say VB or COBOL could.) Java cannot give you direct access to any hardware or system resources, which kinda defeats the purpose of writing an OS in Java doesn't it. Java has to go through the JVM first.

Actually, I'm working part time as a consultant for a company that is building an ARM chip (essentially a flash programmable CPU) where the chip's microcode is Java byte code. When you run java programs on it they will run at assembler language speeds.

Imagine when your PDA's and Cell phones have this little 1/2 inch square chip in them. People can write applications (and games) in an easy to learn language like Java and they will run at light speed.

So no, it's not an OS, but it sort of replaces an OS by eliminating that layer between the applications and the microcode of the chip.

BrianDrozd
11-28-2000, 01:25 PM
Originally posted by Dru Lee Parsec:
Actually, I'm working part time as a consultant for a company that is building an ARM chip (essentially a flash programmable CPU) where the chip's microcode is Java byte code. When you run java programs on it they will run at assembler language speeds.

Imagine when your PDA's and Cell phones have this little 1/2 inch square chip in them. People can write applications (and games) in an easy to learn language like Java and they will run at light speed.

So no, it's not an OS, but it sort of replaces an OS by eliminating that layer between the applications and the microcode of the chip.

I have just one thing to say to that:

http://www.linuxnewbie.org/ubb/cool.gifCOOL http://www.linuxnewbie.org/ubb/cool.gif

dunno
11-28-2000, 05:46 PM
Originally posted by jemfinch:
That's because you're dumb.

The kernel is written in C. The compiler is written in C. Your shell is written in C. X is written in C. GNOME is written in C. Your mail client is written in C.

Basically, everything good that isn't KDE is written in C. It certainly doesn't "suck" and the day someone can validly call it "useless" is the day processors stop being made with an imperative design model and unix stops being used.

That is, never.

Jeremy

I see I stepped on someone's toes! Anyway, I prefer C++ over C because of OOP. Maybe C is not "useless" but I believe "sux" is a valid option based solely on preference. "dumb" is also relative, anyone could be dumb depending on who you compared them to, I'll assume that you are comparing me to yourself or something. Maybe I am not dumb, just ignorant of the awsome value of C, you could have been a little more tactful... unless you just wanted to hurt my feelings. I don't see why you'd want to do that unless you feel I've insulted you. Maybe by saying C "sux" you think I'm saying that all C Programmers sux, well now I'm starting to ramble... anyway, I dislike C because of the way it is "feels", the same reason I dislike Python. I'll take back the "useless" part.

------------------
"I'll get enough sleep when I'm dead."
--Left Behind, The Movie