Code::Blocks

User forums => General (but related to Code::Blocks) => Topic started by: Newbie0815 on July 29, 2006, 02:51:59 am

Title: Too dumb to get started?
Post by: Newbie0815 on July 29, 2006, 02:51:59 am
This is about my 100s attempt to get started in programming, the previous 99 all ended the same way, I keep trying 2 or 3 days and I give up because I get nowhere, and I donīt understand why this should be so unbelievable complicated
As you can see, I havenīt totally given up yet, I always get back to it a week later or so, but you may still call me the bloodiest noob youīve ever met, so forgive me for asking the dumbest questions

Iīm not absolute new to programming, I know some basics in php/mysql
Iīve searched for online tutorials for beginners in C/C++, found some, and managed to write my first Hello World program to run in a DOS box
After that most beginner tutorials explain some basics about definig variables, get input, calculate and output, loops and stuff, that part isnīt new to me, a bit different syntax, but basicly the same as in php
After that, there comes the transformation of the Hello World program into a win32 application, sounds very easy, even the explanation looks very easy, but this is the point where Iīm getting stuck
All the tutorials I found say something about the difference in code, like I have to use windows.h instead of iostream, but none of them mentions with a single word, that upon opening a new project and choose win32 application I get a main.cpp containing a whole bunch of code already where I have not the slightest clue WHERE to fit in the Hello World

Other tutorials I found are way too advanced for me, I donīt get a single word there
I keep searching, but I wonder, isnīt there an easy tutorial somewhere on the web which doesnīt explain what I already know and then either ends or jumps to a point where I donīt get a word?
Iīd be willing to buy a book, but after this experience I almost expect it would be the same thing, either its about basics I know already or it begins at a point where I donīt understand anything at all

Can someone help me out? An easy tutorial for dummies, titled from web-programming to real programming or something like that?
Title: Re: Too dumb to get started?
Post by: sethjackson on July 29, 2006, 02:56:43 am
This is about my 100s attempt to get started in programming, the previous 99 all ended the same way, I keep trying 2 or 3 days and I give up because I get nowhere, and I donīt understand why this should be so unbelievable complicated
As you can see, I havenīt totally given up yet, I always get back to it a week later or so, but you may still call me the bloodiest noob youīve ever met, so forgive me for asking the dumbest questions

Iīm not absolute new to programming, I know some basics in php/mysql
Iīve searched for online tutorials for beginners in C/C++, found some, and managed to write my first Hello World program to run in a DOS box
After that most beginner tutorials explain some basics about definig variables, get input, calculate and output, loops and stuff, that part isnīt new to me, a bit different syntax, but basicly the same as in php
After that, there comes the transformation of the Hello World program into a win32 application, sounds very easy, even the explanation looks very easy, but this is the point where Iīm getting stuck
All the tutorials I found say something about the difference in code, like I have to use windows.h instead of iostream, but none of them mentions with a single word, that upon opening a new project and choose win32 application I get a main.cpp containing a whole bunch of code already where I have not the slightest clue WHERE to fit in the Hello World

Other tutorials I found are way too advanced for me, I donīt get a single word there
I keep searching, but I wonder, isnīt there an easy tutorial somewhere on the web which doesnīt explain what I already know and then either ends or jumps to a point where I donīt get a word?
Iīd be willing to buy a book, but after this experience I almost expect it would be the same thing, either its about basics I know already or it begins at a point where I donīt understand anything at all

Can someone help me out? An easy tutorial for dummies, titled from web-programming to real programming or something like that?

I'm assuming you want to know how to code Win32 GUI programs right? I think this tutorial is the de facto standard for the Win32 API. :)

http://winprog.org/tutorial/

EDIT:

BTW here is the Win32 API Hello World program. :)

Code: C++
  1. #include <windows.h>
  2.  
  3. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  4.                    LPSTR lpCmdLine, int nCmdShow)
  5. {
  6.     MessageBox(0, "Hello World!", "Note", MB_OK);
  7.  
  8.     return 0;
  9. }
  10.  
Title: Re: Too dumb to get started?
Post by: Newbie0815 on July 29, 2006, 03:06:30 am
thanks for the quick answer, Iīll give it a try (and Iīm sure Iīll be back soon)

Edit:

yeah, back already, didnīt even make it through chapter 1 of Getting Started

Quote:
If you don't know what a macro or a typedef are, or how a switch() statement works, then turn back now and read a good book or tutorial on the C language first.

I guess I need that good book or tutorial first
Title: Re: Too dumb to get started?
Post by: kidmosey on July 29, 2006, 09:01:09 am
http://kpest.musitu.org/ (http://kpest.musitu.org/)

Check out the C/C++ Tutorials section.

I'm not spamming, honest!  These are the links I used when I got started with programming soooo many years ago.  Most of the links still seem good, too.

[edit]
If I were you, I'd skip down to the Coronado Enterprises Tutorials.  I probably should have placed them first.
[/edit]
Title: Re: Too dumb to get started?
Post by: sethjackson on July 29, 2006, 03:02:13 pm
thanks for the quick answer, Iīll give it a try (and Iīm sure Iīll be back soon)

Edit:

yeah, back already, didnīt even make it through chapter 1 of Getting Started

Quote:
If you don't know what a macro or a typedef are, or how a switch() statement works, then turn back now and read a good book or tutorial on the C language first.

I guess I need that good book or tutorial first

You don't need a book. Just a good C++ tutorial. :) I didn't know what that stuff was either when I started. :)

http://www.cplusplus.com/doc/tutorial/
Title: Re: Too dumb to get started?
Post by: Newbie0815 on July 29, 2006, 06:19:52 pm
well, that tutorial at cpluplus.com is quite nice
I actually got a few steps further than usual, still Iīm getting to the same point
example:
in the chapter control structures there is a paragraph about "switch" which has an exact equivalent in "if-else"
both do the exact same thing and I really donīt get, for what shall a real bloody newbie learn 2 different things which do the exact same?

I can understand, there are differences for advanced users, Iīm sure there are things which can be done easier or faster by "switch" than by "if-else", or something like that, but for someone like me who wants to learn from scratch, when I find 2 different ways to do the exact same, I start reading the chapter until I find out it wasnīt even neccessary to learn this sh*t, because I already know a much easier way to do the same

Canīt a beginners tutorial be restricted to the easiest way to do something?
Why would it be important to a newbie, whether his very first miniature program requires 10 times more processing power? Whats the fortune of learning about the difference between local and global variables while the entire program Iīm writing requires a total of 2 variables
Why should I learn how to pass variables through functions, while my entire experience is restricted to printing "Hello World!" to the screen?"
Hell Iīm not writing a new OS as my first program
I can find several different ways to get from paris to rome, but if I donīt have a map and no clue where rome is located, why should I learn the route by car and by plane at same time? My goal is to get there and unless I know already how to get there by plane, Iīm not interested at all in the fortunes of getting there by car, for a firsttimer the easiest explanation is the best, regardeless whether or not thats the best way to do it for a pro

However, these things make me bypass the rest of a chapter, furthermore makes me suspicious of several further duplicated ways to do the same, making me skip more and more, just to grab the easy way, which obvioulsy leads to the problem, I donīt get a word anymore in following chapters, because the author of the tutorial expects that I have learned ALL options to do the same thing, rather than the easiest one
Title: Re: Too dumb to get started?
Post by: sethjackson on July 29, 2006, 06:31:18 pm
Well a switch statement is like an if else-if. It is (I have been told) faster, and sometimes more efficient to use a switch.

Here is an example.

Code: C++
  1. int main()
  2. {
  3.     int a = 0;
  4.  
  5.     if (a == 0)
  6.         //....
  7.  
  8.     else if (a == 1)
  9.         //....
  10.  
  11.     else if (a == 2)
  12.         //....
  13.  
  14.     else if (a == 3)
  15.        //....
  16.    
  17.     else
  18.         //....
  19.  
  20.     return 0;
  21. }
  22.  

Code: C++
  1. int main()
  2. {
  3.     int a = 0;
  4.  
  5.     switch (a)
  6.     {
  7.         case 1:
  8.             //....
  9.         break;
  10.  
  11.         case 2:
  12.             //....
  13.         break;
  14.  
  15.         case 3:
  16.             //....
  17.         break;
  18.  
  19.         default:
  20.             //....
  21.         break;          
  22.     }
  23.  
  24.     return 0;
  25. }
  26.  

Do you follow that?

EDIT:

Sometimes the easiest way to do something isn't the easiest way to do something else. ;)

Like  10 * 3 = 30. Or 10 + 10 + 10 = 30. Ok not a good example, but I think you get the idea. :) 
Title: Re: Too dumb to get started?
Post by: Newbie0815 on July 29, 2006, 06:40:19 pm
of course I get the idea, if I know how to do something and then I discover an easier way to do it, great, Iīd love to learn the easier way, but as long as I donīt know ANY way to do something, why should I learn 2 differnt ways simultanous? Thats twice the work on start, maybe helpful later on when it comes to complex programs, but on start its boring stuff, taking twice as long to learn the basics and at least for me, investing so many hours in learning a dozen different ways to do the SAME thing doesnīt show much progress towards the general goal and the slower the progress, the more often the idea pops into my mind, at THIS speed I wonīt get anywhere within my lifetime
Title: Re: Too dumb to get started?
Post by: killerbot on July 29, 2006, 07:04:56 pm
Well I have to disagree here. If you want to program in c++ you have to know the language !!!
As the above raised example of switch and if/else. You can NEARLY do the same thing with both, but here's such thing as readability and maintenance of code. Code which is hard to read is BAD code.

Excessive if/else can make code hard to read and understand where in several situations the switch is much easer to read and understand. And for simple tests an if/else is better to read then a switch. The number of language constructs in c++ are not that many.

Next what's easy, what's not.
Character arrays are easy :
  char szTest[] = "This is a test".
Or maybe they are not, concatenation, terminating zero, size issues, allocation, deallocation. Headaches, memor leaks, crashes, ...
Well then STL's string class is easy, no need to worry about those allocation and size problems (well there's the performance level), but hey let's have a look at that string class declaration. Damn that's not so easy anymore : trait's , allocators, templates. Huh, well duh.

Programming in c++ should be taken seriously, I have seen to much stupid, erronous and awfull code because people didn't know the (entire) language.

The same with loops : while() , do while(), for () : many times you can convert one to the other, but sometimes one is much clearer to use in certain circumstances.

It's overtime one get's the feeling which constructs are to be used when and where.

Hey let's even take it more simple :
  int x = 0;
  x = x +5;
    OR
 x += 5;
Well why two ways, come on, why, why, why ? Performance, the latter one is faster. But we need the first one, yes we do : as in : x = y +5;

Ruling out options in the beginning is not wise, get to know all your cards and you will play a better game.

[EDIT] there are probably tutorials how work by means of examples and add language constructs as they go. It's just how the "theory" and "practice" is divided. When I learned driving I first had to learn all traffic signs and rules. And to be honest during my first drive I surely did not came across all those signs. ;-)
Title: Re: Too dumb to get started?
Post by: marfig on July 29, 2006, 07:46:54 pm
You realy cannot learn C++ programming based on tutorials only. You will need to buy a book eventually.

Tutorials make for a good startup. However they have to be generalistic in nature (they wouldn't be tutorials otherwise). The concepts therein are presented lightly and the examples hardly ever have much meaning in real life computing. They are poweful tools though, in the sense they provide an understanding of some of the language features; what are they and how they are used. But, again, they do this at the expense of depthness.

Books, on the other hand, have a lot more space to go into depth about the language features. And that is probably what you are missing. I strongly suggest you buy either Accelerated C++ or C++ Primer.

There is another problem with tutorials. Most of them are amateurish. There are fine tutorials out there, but there are others that do a very bad job at teaching C++. In fact they will only add to the confusion (I guess this is true of some books too). The preciseness of language choices when writing tutorials or books is fundamental when one wants to teach a programming language like C++. There is a big difference between a pointer to an array and an array of pointers, and yet many authors chose to confuse readers by choosing terms like "a pointer array", which can mean both or none at all. Once C++ is understood this choice is no longer a problem. We know what it means from the context surrounding it, but for someone learning the language, the author didn't provide him a good service. Another example is not applying correctly words like "definition", "initialization", "declaration".

Learning C++ can be a frustrating experience already without these problems adding to it. What I strongly suggest you is to follow a few guidelines:

- Concentrate on the programming language first. Learn the language. Get yourself one of those two books above (my personal favorite is C++ Primer) and read them carefully. Experiment a lot. Even if what is being explained to you seems obvious, write the code to prove what the book is saying nonetheless. Read, code, read, code... ad aeternum.

- Write code that intentionally explores the bad practices the book is telling you not to use. See what kind of compilation errors you get. Try to remember them for the future. More important, try to understand why it is a bad practice. For example, when learning about dynamic memory and memory leaks, purposedly provoke memory leaks in your code. Write cout statements inside the object destructor to see if it was ran or not and when it was ran. Explore everything! What you should do and what you shouldn't do. Half of the way to understand C++ is to understand about what you shouldn't do with C++.

- Learn your debugger. This is probably one of the most important things. You absolutely, utterly, without any doubt whatsoever, need to learn how to debug. You are not going anywhere if you don't learn how to debug. It's not complicated, you need to learn mostly about breakpoints and watches. At least for now.

- Learn your debugger. I've put it here again to stress this out ;)

- Do not, I repeat, do not try to write a complete program without having gone through the book at least once. This is important because most people try to put the wagon in front of the horses, only to find out later they they will need to code a feature they haven't learned about yet. Then they go on to read hastily about it, implement it in some bad way, and not gain a clear, in depth, knowledge of it. The reasult is that they think they know how to use it, when in fact, more often then not, they have only scratched the surface. Do not try to write a full program before you are done with the book at least once.

- Be patient and be veeeery slow. Learn everything slow. Be sluggish in your learning of C++. You are not going anywhere and the language will not puff away. Understand that it takes around 2 years to be proficient in C++ and maybe a couple more to feel totally at ease with it. The important thing, what you should concentrate most is understanding that first you need to know what the language provides and how it provides it (C++ features and syntax) and only then you should concentrate on how to effectively use those features. Don't plan your learning process, don't set yourself deadlines. Be patient, slow and sluggish.
Title: Re: Too dumb to get started?
Post by: Newbie0815 on July 29, 2006, 07:49:00 pm
for a good part I can agree there, of course it is important to learn the whole language, but before anyone can learn it all, he has to get started
if you cannot get started, because the plain mass of information to learn exceeds your learning capabilities within the first two chapters, you never make it to chapter 3, or in other words, you end up like me, giving up right after "Hello World"
how am I supposed to learn the basics, if the "Hello World" program as the simplest of all programs already uses 2/3 of the page to show alternate ways of reaching the same goal?
this effect multiplies with every further chapter, there is maybe one tiny little detail per page which is new, the entire rest the author spends on explainig how many different ways this new detail now offers in order to adchieve the same goal, or in other words, the part where I learn something new is reduced to a tiny little fraction of the time invested, the progress I make in learning is < 1% of my working time and I spend 99% of my time reaching the same goal from all possible directions
Iīm not saying its wrong, Iīm not saying its bad, Iīm not saying its not neccessary, Iīm saying this bothers me so much on start, that I never even get started because I give up before I get anywhere due lack of progress

As some wise guy once said (not sure who it was) "If you want to learn how to fly, you first have to learn how to walk"
These tutorials are teaching walk and fly simultanous
Title: Re: Too dumb to get started?
Post by: killerbot on July 29, 2006, 08:20:07 pm
I also advice : Accelerated C++
Title: Re: Too dumb to get started?
Post by: Vampyre_Dark on July 29, 2006, 09:51:10 pm
I never really read a C or C++ book. I learned it all by reading various things on the web, but it took me a lot longer to learn. That wasn't really a problem though, since I just mess around for fun.
Title: Re: Too dumb to get started?
Post by: sethjackson on July 29, 2006, 10:52:19 pm
I read a few C++ books. They were aweful.  :lol: I learned more by reading good tutorials on the internet. :) I would reccommend one book in particular though. It is called "The C++ Programming Language" (third edition) it was written by Bjarne Stroustrup who made the language. It is thick, and can be overwhelming at times, but it is an invaluable reference. :)
Title: Re: Too dumb to get started?
Post by: Vampyre_Dark on July 29, 2006, 11:08:42 pm
I have browsed through some books and I find it dissapointing at times when authors like to take the shortcuts around difficult things to explain and give you some really bad placeholder methods to do things, with some excuse like "it's beyond the scope of this book", and then never mention where to turn to find more info.  :?
Title: Re: Too dumb to get started?
Post by: killerbot on July 29, 2006, 11:33:05 pm
If you want to read good books about c++ (advanced) which do not turn their head for serious issues and good techniques I can advice you the books of (just check addison wesley or amazon) :

- Scott Meyers
- Herb Sutter
- Andrei Alexandrescu
- Josuttis

Those will teach you real (advanced) C++ !!!
Title: Re: Too dumb to get started?
Post by: mdelfede on July 29, 2006, 11:40:36 pm
well, that tutorial at cpluplus.com is quite nice
I actually got a few steps further than usual, still Iīm getting to the same point
example:
in the chapter control structures there is a paragraph about "switch" which has an exact equivalent in "if-else"
both do the exact same thing and I really donīt get, for what shall a real bloody newbie learn 2 different things which do the exact same?

I can understand, there are differences for advanced users, Iīm sure there are things which can be done easier or faster by "switch" than by "if-else", or something like that, but for someone like me who wants to learn from scratch, when I find 2 different ways to do the exact same, I start reading the chapter until I find out it wasnīt even neccessary to learn this sh*t, because I already know a much easier way to do the same

Canīt a beginners tutorial be restricted to the easiest way to do something?
Why would it be important to a newbie, whether his very first miniature program requires 10 times more processing power? Whats the fortune of learning about the difference between local and global variables while the entire program Iīm writing requires a total of 2 variables
Why should I learn how to pass variables through functions, while my entire experience is restricted to printing "Hello World!" to the screen?"
Hell Iīm not writing a new OS as my first program
I can find several different ways to get from paris to rome, but if I donīt have a map and no clue where rome is located, why should I learn the route by car and by plane at same time? My goal is to get there and unless I know already how to get there by plane, Iīm not interested at all in the fortunes of getting there by car, for a firsttimer the easiest explanation is the best, regardeless whether or not thats the best way to do it for a pro

However, these things make me bypass the rest of a chapter, furthermore makes me suspicious of several further duplicated ways to do the same, making me skip more and more, just to grab the easy way, which obvioulsy leads to the problem, I donīt get a word anymore in following chapters, because the author of the tutorial expects that I have learned ALL options to do the same thing, rather than the easiest one

uhmmm... from what you say, it seems to me that you "HAVE TO" learn programming, not "LIKE TO" do it...
That's the same problem in every field : if you don't like what you do, no matter how hard you try, you'll never do it well.
That's my humble opinion, of course.
If you really want to learn programming, reading a tutorial and finding 5 ways to do the same thing, the right question woul be : "mhhh, nice thing, let's see if I can use it to make my code work better !" and not "another boring way to do the same stuff"...
Sorry to say that, but if you find "boring and useless" the explanation of difference from local and global variables, or the way to pass parameters in functions, better you choose another job (or hobby).
When you'll reach classes, pointers and templates you'll be sleeping since long...

Ciao

Max
Title: Re: Too dumb to get started?
Post by: Newbie0815 on July 30, 2006, 12:40:01 am
max, for one, you got me, there is a good part of I "have to" in  my wish to learn it
its something like, through my web-programming in php, I got to a point where I want to develop something which cannot be done in php
Iīd love to do it, but if I want to do it, I have to learn C/C++ first

For the rest, you got me wrong there, I donīt thing differences between global and local variables are useless, I just think it not neccessary to explain it in the very first chapter for newbies
I donīt think passing parameters through functions is boring, I just think for a real newbie, learning what a function is and how the synatx of an entirely empty function look is way more important

Of course, if I want to develop something good, I will have to learn it all, and Iīm aware it will take its time, I just think packing all options for every tiny detail into the first appearance of it in a plain beginners course is way off target
I like the first 2 pages in the http://winprog.org/tutorial/
First page the hello world program as a win32 application, 2nd page the easiest possible window, including explanations how it is setup and what all the code means
but from 3rd page on Iīm lost
the author doesnīt bother anymore to mention WHERE in the code the next piece should be added every other paragraph says: "IF you donīt understand what this means, donīt worry, its not important for now" and I end up with 100s of compiler errors, because I canīt figure out what belongs where
Iīve tried downloading the source code he provides, but thats totally different from the tutorial, because he is using borland and makefile which isnīt mentioned by a single word in the entire tutorial
However, I managed to figure most of it out after a while, but I was about to give up, when a piece of code he has on the "Dialogs" page to display a dialog box brings up a simple "Syntax error"

Thats the point where I really wonder, is it absolute neccessary to understand resource files, object oriented programming, all types of variables and 100s of other things to pop up a simple dialog box? Wouldnīt it be MUCH easier for a newbie to explain FIRST how to popup a dialog box, SECOND how to modify properties of it and LAST how to implement it into a resource file?
To learn how to use a dialog box, there is no resource file needed at all, it could easy be implemented into main, explain how to work with it and AFTER thats clear explain how to put it into a resource file and how to include the resource into main
Title: Re: Too dumb to get started?
Post by: mdelfede on July 30, 2006, 01:43:47 am
max, for one, you got me, there is a good part of I "have to" in  my wish to learn it
its something like, through my web-programming in php, I got to a point where I want to develop something which cannot be done in php
Iīd love to do it, but if I want to do it, I have to learn C/C++ first
I don't understand even the simplest line of PHP, not 'cause I think is too difficult, just because I find it boring and I have absolutely no interest on it. Even so for the web-programming.... I do program for hobby, sometimes (very few) for money, but my job is other thing.
I learned programming starting with basic and assembler (apple II), then pascal, then c, fortran, c++.
I did something in Perl because I needed it, but I can scarcely write a 10 lines perl program, and I avoid to do it if I can.

I think that if you must learn some C++ for a single part of a web project, it's better you ask somebody to do the job for you... You'll spend less time and at the end less money for the same job.
If you think you'll need c++ from now forever, that's another question.

For the rest, you got me wrong there, I donīt thing differences between global and local variables are useless, I just think it not neccessary to explain it in the very first chapter for newbies
I donīt think passing parameters through functions is boring, I just think for a real newbie, learning what a function is and how the synatx of an entirely empty function look is way more important
here I think you're wrong. As I said, I don't know PHP at all, so I can't know if it has local/global variables (I think it has), nor if it has function calls, switches, and so on.
The problem is that in c++ those are fundamental parts of the language. If you don't understand what is a function parameter, how is it passed to a function, you can only cut-and-paste some lines of code and pry that it goes, and 99% of the times it will not go.
When you write a line that looks like this one :

MsgBoxA("SomeText");

You know that "SomeText" will appear on screen in a message box you can change "SomeText" whith "Another text", but that's all. Maybe, reading a bit more, you can write :

char *msg = "SomeText" ;
MsgBoxA(msg);

And here you already have a variable (local or global is unimportant here), and a function call with a parameter.
But then you have also a pointer variable. If you'll want to add some more things to your program, you may try something like that :
char *msg1 = "Some";
char *msg2 = "Text";
char *msg = msg1+msg2;    <--- WRONG !!!!
MsgBoxA(msg);

And that'll not work, because you don't know the difference between strings and pointers of chars; as you see, even the most trivial thing like concatenating 2 strings of text requires a lot of knowledge.
Whorse than that, windows works mostly with pointers of data; if you don't know what a pointer is, what are 'new' and 'delete' operators, what's a pointer ownership, you simply can't do anthing with windows.

Of course, if I want to develop something good, I will have to learn it all, and Iīm aware it will take its time, I just think packing all options for every tiny detail into the first appearance of it in a plain beginners course is way off target
I like the first 2 pages in the http://winprog.org/tutorial/
First page the hello world program as a win32 application, 2nd page the easiest possible window, including explanations how it is setup and what all the code means
but from 3rd page on Iīm lost
the author doesnīt bother anymore to mention WHERE in the code the next piece should be added every other paragraph says: "IF you donīt understand what this means, donīt worry, its not important for now" and I end up with 100s of compiler errors, because I canīt figure out what belongs where
That may be a tutorial fault (if they say "don't worry, it's not important for now" is it indeed a tutorial fault) or you may have chosen the bad tutorial.
BTW, if you want to learn how to program a GUI, you must know BEFORE all the basis of the language.

Iīve tried downloading the source code he provides, but thats totally different from the tutorial, because he is using borland and makefile which isnīt mentioned by a single word in the entire tutorial
I did use Borland tools and they used to be quite good. They're even a good starting point to learn c++ because they give many code examples, from the simple one to the complex one. You could download a trial version of c++builder and try some examples. BTW, they use some extension of c++ that, even IMHO they should be added to c++ standard (__property construct is one of the best things they added to c++), they're NOT c++ standard, so you may get a bit confused.
Of course, if you try to compile a sample from borland cbuilder using VCL with gcc or vc, you'll get tons of syntax errors because of those extensions.

However, I managed to figure most of it out after a while, but I was about to give up, when a piece of code he has on the "Dialogs" page to display a dialog box brings up a simple "Syntax error"

Thats the point where I really wonder, is it absolute neccessary to understand resource files, object oriented programming, all types of variables and 100s of other things to pop up a simple dialog box? Wouldnīt it be MUCH easier for a newbie to explain FIRST how to popup a dialog box, SECOND how to modify properties of it and LAST how to implement it into a resource file?
To learn how to use a dialog box, there is no resource file needed at all, it could easy be implemented into main, explain how to work with it and AFTER thats clear explain how to put it into a resource file and how to include the resource into main
Is I said before, if you JUST want to make a dialogbox, that's not needed. But you'll understand that a dialogbox is not a complete program and, as I did show you, to add even trivial things you must know the language.
What I can say to you is : choose your operating environment at first, then try some examples from it (about all integrated environments comes with many samples), and try to understand what code does.
If you use borland, they have some good tutorials. I think also VC has good tutorials. When you don't understand, look before in help, than search with google, or have a c++ book near you.

Ciao

Max
Title: Re: Too dumb to get started?
Post by: kidmosey on July 30, 2006, 06:23:06 am
It seems the primary difference between tutorials and books is that tutorials give you a program and describe each part in turn, whereas a book is a bit more dry and just tells you the constructs of the language.  So it really depends on your style of learning.

I learned C through tutorials, but C++ was much easier to learn by reading a book ("The C++ Programming Language" (third edition), Byarne Straustrup).

IMO, you should stay away from C++ until you have a firm grip on C.  Some people, namely Java programmers, will say that it isn't necessary (and it isn't), but in the long run it will give you a better idea how everything is working.  If you already know PHP, then you are halfway there (depending on your PHP coding style).  They have many of the same constructs.

I would also suggest not jumping right into Win32 GUI programming if you don't know the basics of C, yet; it is a quick way to get discouraged.  Most windows API tutorials assume prior knowledge of C, and sometimes C++.  It is not necessary to know C++ to program for windows.

The reason tutorials don't just give you a dialog in WinMain is because that is not how Windows applications work.  So how do windows applications work?  It depends on the application.  In general, they register a callback function for events, attach a window(s) to that callback, and then start an event grabbing loop.  The callback procedure can be seen as the "main" function for a given window, so that is usually where all of the "hello world" code will be.

In addition, using resources for dialogs and such is MUCH easier that creating them in code (for most people).

Anyhow, I'm a bit tired, so I don't know how much of this actually made sense or hasn't already been said; but good luck.

Title: Re: Too dumb to get started?
Post by: PDEE on July 30, 2006, 05:05:09 pm
I don't know C. I have asked many people on forums all over the place wether i should learn c first and they nearly all say "don't bother, you will have to unlearn everything when you come to learn C++". So that's what i did. Went straight to C++ and i am doing ok at it. I wanted to learn OOP so that's where i started. I get most of my tutorials online and any questions i have i ask on forums. Works for me but might be different for others. This site is good for advice http://www.parashift.com/c++-faq-lite/ (http://www.parashift.com/c++-faq-lite/)

PDEE
Title: Re: Too dumb to get started?
Post by: killerbot on July 30, 2006, 05:16:44 pm
I don't know C. I have asked many people on forums all over the place wether i should learn c first and they nearly all say "don't bother, you will have to unlearn everything when you come to learn C++". So that's what i did. Went straight to C++ and i am doing ok at it. I wanted to learn OOP so that's where i started. I get most of my tutorials online and any questions i have i ask on forums. Works for me but might be different for others. This site is good for advice http://www.parashift.com/c++-faq-lite/ (http://www.parashift.com/c++-faq-lite/)

PDEE

Quoting Bjarne Stroustroup : "It is better not to learn c first, it's better to learn c++ and then c (if you really need it)".
My personal opinion : you can skip c, it might indeed help, but actually it's a subset of c++, so during the course of c++ you learn nearly the same thing directly with the extra c++ features.
Title: Re: Too dumb to get started?
Post by: sethjackson on July 30, 2006, 06:31:19 pm
I don't know C. I have asked many people on forums all over the place wether i should learn c first and they nearly all say "don't bother, you will have to unlearn everything when you come to learn C++". So that's what i did. Went straight to C++ and i am doing ok at it. I wanted to learn OOP so that's where i started. I get most of my tutorials online and any questions i have i ask on forums. Works for me but might be different for others. This site is good for advice http://www.parashift.com/c++-faq-lite/ (http://www.parashift.com/c++-faq-lite/)

PDEE

Quoting Bjarne Stroustroup : "It is better not to learn c first, it's better to learn c++ and then c (if you really need it)".
My personal opinion : you can skip c, it might indeed help, but actually it's a subset of c++, so during the course of c++ you learn nearly the same thing directly with the extra c++ features.

Yeah I agree. :)
Title: Re: Too dumb to get started?
Post by: kidmosey on July 31, 2006, 05:47:20 am
I have asked many people on forums all over the place wether i should learn c first and they nearly all say "don't bother, you will have to unlearn everything when you come to learn C++".

I don't know what exactly you would have to unlearn, considering C++ is just an extension of C.  You are essentially learning C first, anyhow, even if it is included in the C++ tutorial.  In unversity, they taught us "C++", but it was really C using the STL... It wasn't until the third term that we actually got into namespaces, classes, overloading, templates, etc...

However, after waking up, I do realize it is likely better to learn C++, as long as you learn it from a decent source.  Bjarne Stroustroup's book is actually the only C++ book I've read (Besides "Teach yourself C++ in 21 days"), so I don't really have anything to compare it to.  I suppose the fact that I haven't *needed* to read another book is proof enough at how good it is.
Title: Re: Too dumb to get started?
Post by: kagerato on August 01, 2006, 04:27:23 am
Quote from: kidmosey
I don't know what exactly you would have to unlearn, considering C++ is just an extension of C.

What people actually mean to say when they mention something like this is that C and C++ are different programming models.  C is functional whereas C++ is object-oriented.  While you can write functional-style code in C++, it can be a serious mistake to do so.

It's not that you'll have to "unlearn" functional programming to do object-oriented programming correctly.  It's simply that the two models are very dissimilar, and it's generally not worth learning how to do the former if what you ultimately intend to use is the latter.  This is especially true for graphical userspace application developers; it's rare to need functional programming techniques in this area.  On the other hand, if one intends to become a systems programmer (developing a kernel or a low-level library, for instance) it may be extremely helpful to know functional programming.

C++ is fairly often criticized for allowing the mix-and-matching of the functional and object-oriented paradigms, especially by developers who come from languages that don't permit it (these include Java, C#, modern VB, and quite a few others).  It's uncommon to find these kinds of points being raised by developers using Python and Pascal derivatives because their languages were architected to be flexible, just as C++ was.

Quote from: Newbie0815
Canīt a beginners tutorial be restricted to the easiest way to do something?

The easiest way is not necessarily a good way.  Programming tutorials are not written to show people how to do quick fixes -- you really shouldn't be writing programs if your goal is the most hackish, fastest possible solution.  A well-written tutorial (or book) will inspire, at the very least, decent programming practices.  Then, when your program has grown from 2,000 lines to 20,000 (or even 200,000), you won't be stuck with a nightmarish quagmire.

Quote from: Newbie0815
I can understand, there are differences for advanced users, Iīm sure there are things which can be done easier or faster by "switch" than by "if-else", or something like that, but for someone like me who wants to learn from scratch, when I find 2 different ways to do the exact same, I start reading the chapter until I find out it wasnīt even neccessary to learn this sh*t, because I already know a much easier way to do the same

The If...Else construct is much easier than Switch?  Sure, if you only have a few values to enumerate.  With win32, there's a ridiculous number of window messages (WM_*), and sometimes you need to catch more than a few.  In any case, Switch is pretty simple.  So long as you remember to use the break statement properly, it behaves just as If...Else would -- except the code is cleaner.

Quote from: Newbie0815
this effect multiplies with every further chapter, there is maybe one tiny little detail per page which is new, the entire rest the author spends on explainig how many different ways this new detail now offers in order to adchieve the same goal, or in other words, the part where I learn something new is reduced to a tiny little fraction of the time invested, the progress I make in learning is < 1% of my working time and I spend 99% of my time reaching the same goal from all possible directions

If 99% of your time is spent doing nothing of significance, there's two things to consider:

a.) is this tutorial/book/teacher any good?
b.) am I actually trying to study or learn from the material to the best of my ability, including studying and modifying the provided source?

Quote from: Newbie0815
Iīm not saying its wrong, Iīm not saying its bad, Iīm not saying its not neccessary, Iīm saying this bothers me so much on start, that I never even get started because I give up before I get anywhere due lack of progress

GUI programming, particularly using win32, is tedious.  That's all there is to that.  The win32 API is almost entirely C, and thus if you intend to use it directly you will have to do things the functional way.  That means creating and initializing a bunch of structure instances, and calling a lot of functions directly one after another.  Win32 is not fun, there's no doubt about that.  I would never recommend someone begin learning programming by building straight win32 programs.

Quote from: Newbie0815
As some wise guy once said (not sure who it was) "If you want to learn how to fly, you first have to learn how to walk"

These tutorials are teaching walk and fly simultanous

Since it's quite impossible to learn how to fly from walking, that's some horrible advice.  I think perhaps your analogy is supposed to reference walking and running, no?  In any case, it's not an apt comparison -- with something like the If...Else and Switch constructs, it's two separate means of branching.  Neither is dependent on the other; you could learn either first and it is most certainly possible to effectively learn both at once.  The difference is all syntax, nothing more.

Now, to introduce branching mechanisms before describing statements, types, and the basic operators -- that would be foolish.

Quote from: Newbie0815
max, for one, you got me, there is a good part of I "have to" in  my wish to learn it

its something like, through my web-programming in php, I got to a point where I want to develop something which cannot be done in php
Iīd love to do it, but if I want to do it, I have to learn C/C++ first

C and C++ are not the only programming languages on Earth.  If you weren't aware, you can access C libraries from essentially any language (a programming language that can't interface with C is rarely worth using for application development).  The vast majority of win32 consists of C libraries -- hence if you want to use win32 you can do it from whatever language is most comfortable.

C++ libraries are a different matter.  Only a handful of languages can access them properly, because 1.) the C++ ABI is not as stable as C's and 2.) C++ is a much more complicated language, period.  Python is a good example of a language that interfaces very well with C++; you might consider it if you need a C++ library like wxWidgets or Qt.  A language like Object Pascal, on the other hand, requires an additional interface layer (whose purpose is to essentially translate the C++ interface to a usable C interface).

Quote from: Newbie0815
I like the first 2 pages in the http://winprog.org/tutorial/

First page the hello world program as a win32 application, 2nd page the easiest possible window, including explanations how it is setup and what all the code means

but from 3rd page on Iīm lost

The code snippets in theForger's tutorial can become confusing.  You really must examine the full source to see how the code fits into context.

Other than that, what's so confusing?  Handling messages is a very basic part of win32 programming, and it's absolutely essential.  He didn't stick it into the third section just to annoy people.

If you're getting sidetracked by the ridiculous number of typedefs, that's normal.  Microsoft decided, for whatever asinine reason, to create about a thousand 'distinct' types which are actually all typedefs of standard types (mostly integers).  Furthermore, they decided to name them all with pure caps -- a convention normally reserved for constants.  It's one of numerous problems with win32, and has nothing to do with C++ or any other libraries.

Quote from: Newbie0815
I've tried downloading the source code he provides, but thats totally different from the tutorial, because he is using borland and makefile which isnīt mentioned by a single word in the entire tutorial

The compiler is highly irrelevant to C code.  In terms of software, the C standards are ancient.  Any Windows C compiler can build that code.

By the way, DSP files are provided for each of the code samples.  These are Visual Studio projects, that can be built very easily.  Borland's toolchain is not required, although you could use it to easily build everything at once.

In any case, these applications are so simple that they can be built from the console with a single command.  Consult your compiler documentation if necessary.  For those that use win32 resource scripts, you have to use a resource compiler like GoRC (http://"http://www.jorgon.freeserve.co.uk/") to turn the script (*.rc) file into a compiled resource (*.res) which can easily be linked into the final application.

Quote from: Newbie0815
Thats the point where I really wonder, is it absolute neccessary to understand resource files, object oriented programming, all types of variables and 100s of other things to pop up a simple dialog box? Wouldnīt it be MUCH easier for a newbie to explain FIRST how to popup a dialog box, SECOND how to modify properties of it and LAST how to implement it into a resource file?

What does object-orientation have to do with win32?  The win32 API is functional (or procedural, if you prefer that term).

It's not necessary to learn how to use resource scripts initially.  That's why theForger's tutorial doesn't use them initially; it's section five that introduces them.  Without resource scripts, you can't intelligently build any halfway complicated dialog with win32.  You certainly won't get to building any serious application with pure code driving your windows, unless you want to deal with pure hell.

Modifying dialog properties doesn't belong in a separate section from the basic concepts.  One, it's quite simple itself -- changing the value of a single structure's field, generally.  Two, without modifying any of the default values, you won't be building anything the least bit useful (or interesting, for that matter).

Quote from: Newbie0815
To learn how to use a dialog box, there is no resource file needed at all, it could easy be implemented into main, explain how to work with it and AFTER thats clear explain how to put it into a resource file and how to include the resource into main

The MessageBox function, a basic window, and messages are all introduced before resource scripts.  I'm wondering what order you think would be comprehensible, if this isn't?
Title: Re: Too dumb to get started?
Post by: kidmosey on August 01, 2006, 04:56:33 am
Quote from: kidmosey
I don't know what exactly you would have to unlearn, considering C++ is just an extension of C.

What people actually mean to say when they mention something like this is that C and C++ are different programming models.  C is functional whereas C++ is object-oriented.  While you can write functional-style code in C++, it can be a serious mistake to do so.


Okay, that clears it up.  Thanks :D

And as for the rest of your article... Well said!

Title: Re: Too dumb to get started?
Post by: Der Meister on August 01, 2006, 10:00:20 am
Just to be precise: C is *NOT* a functional programming language. It's an imperative (or procedural, if you like this word more) language. Functional programming languages are languages like Haskell or Lisp.
Title: Re: Too dumb to get started?
Post by: PDEE on August 01, 2006, 03:46:04 pm
Wow kagerato, great post. I learnt something from that. Thanks

PDEE
Title: Re: Too dumb to get started?
Post by: dopyiii on August 01, 2006, 04:21:24 pm
I just thought I'd throw in my 2c.  There's a really good free e-seminar at http://www.mindview.net/ done by Chuck Allison called Thinking in C (currently in Beta 3).  It's basically a series of audio lectures (with slides and example code) on C for those who already know how to program in other languages.  It gives them what they need to know about C in order to effectively program in C++ and/or Java (kind of a warm-up to the Thinking in C++/Java books).  It makes sense since C++ is built on C and much of what Java is comes from C++.

I had Chuck as a professor and I can vouch for his knowledge and teaching ability.  The whole thing takes a few hours, but it would be time well spent.  If you know everything that's covered in this e-seminar, you should have few problems stepping up to C++ or Java.

Hope that's helpful.
Title: Re: Too dumb to get started?
Post by: Newbie0815 on August 01, 2006, 06:51:15 pm
first let me say, Iīm impressed how many real nice and helpful answers Iīm receiving here, thanks to everyone for that

now let me give you a bit update on my progress
in plain console C I got far enough to understand most of the beginners tutorials I found
Iīve written some applications, up to a pocket calculator, pretty unpractical within the console, but it complies without errors and works as expected, so for that part Iīm quite proud, even though I sure am still a beginner

So I dared to look into tutorials for win32 applications, which is somewhat an entirely different world
I got lost almost right away, mostly because there are no 2 tutorials for the same compiler, from videos at MSN how to write applications in visual C++ to plain C++ code I can use in CodeBlocks, they are not compatible, CodeBlocks allows me to import almost any format, but mixing them doesnīt work
Iīve tried learning by taking small pieces of code from the tutorials, pick out what I can use for my plan, modify it to my needs and repeat that with always new modifications so often, until I understand what that piece is actually doing and why

As my first project, to learn by doing, Iīve picked the idea, I want to write a simple chatserver where clients can connect to exchange messages, call it a huge goal for a beginner if you like, I like huge tasks and I got plenty of time, so I figured having a huge goal, involving all kind of tasks is the easiest way for me to learn
Of course I donīt want to download a ready made one, I donīt even need one, I just want to learn how to do it
Of course Iīve downloaded a few examples, just to pick a few ideas out of them
Iīve noticed, most of them are written in VB or VC, Iīve even downloaded and installed Visual Studio Express, but for one the code is so way different from gcc, almost an entirely new language and the options are pretty much limited to what the compiler offers
Iīve tried to translate some code to gcc, but that appears way beyond my skills
So I went back to plain gcc, and I got quite far, Iīve got both, client and server developped to the point where only connection and message exchange is missing, which Iīve replaced by simple message boxes while I have not yet learned how to make the connection

Thats where Iīm stuck now, I found just ONE tutorial that explains it short and easy at http://www.c-worker.ch/tuts/wstut_op.html (in german) but that one is written for borland and my attempts to translate it to gcc have failed so far, meaning I canīt even start implementing it into my project
Maybe someone here can help me out? How to mix code written for different compilers or how to translate it?
The source for both, is direct available on the page
Client: http://www.c-worker.ch/tuts/sock.c
Server: http://www.c-worker.ch/tuts/socksrv.c
Title: Re: Too dumb to get started?
Post by: marfig on August 01, 2006, 07:17:50 pm
I don't think you are really listening to what everyone is trying to tell you from the very beginning of this thread. And that is simply, you need to understand the language before you can hope code for windows. It is really simple as that.

Just, please, learn C++. In the console. Learn about variables, types, functions, references, pointers, the STL library, classes, templates, exceptions,....

Only when you do this, only when you have learnt the fundamentals of the language, only when you have done this in the console and feel somewhat secure you know what there is to know of C++, only then, only at this point, only here... will you be able to make any sense of Win32 books and tutorials. Only then will you realize why some choices were made concerning the order by which things are being taught to you, and only then will you actually learn anything valuable.

Quote
As my first project, to learn by doing, Iīve picked the idea, I want to write a simple chatserver where clients can connect to exchange messages,

Wrong. Bad, bad choice. You will not learn anything. You will quit learning C++ if you try to do this because you will feel frustrated. You use the word simple to describe this project, but I can tell you right here and now it will not be simple. If you think this is the best way to learn C++, I'm sorry to say in 1 or two months you will be looking back at this post and wondering I was right. You will quit, my friend. Mark my words.

Concentrate instead on the language features. Concentrate on learning how to program in C++. Not on how to do things with C++.

Remember your objectives:

Right now your objective is to learn C++, not to code a chatserver.
Title: Re: Too dumb to get started?
Post by: Newbie0815 on August 01, 2006, 08:09:44 pm
well, on this part i might be a bit different from everyone else
first of all, reading a book or tutorial without an actual project to realize is THAT boring for me, i never get past page 2 (or i skip through 90% of the text)

beginning with the C64 in 1985 Iīve ALWAYS learned by doing, my very first program was an assembler code for C64 which was capable to copy ANY file from disk to tape
In PHP I learned the basics over night, took a complete multiplayer strategy browser game as my FIRST goal, realized the first beta within 3 months and a functional version within 6 months, containing some 4MB of php code in over 300 (object oriented) scripts and some 60MB graphics

Object oriented programming isnīt new to me, one of the first things Iīve done while collecting the pieces for my project was to put every piece into a new function and mess around with them until they were perfectly interacting, Iīve already overloaded it with so many functions, separating even the smallest pieces of repeated code, just to understand perfectly how a functions works
I still donīt like the idea of global and local variables, but I do understand the concept
I donīt like the concept of define before first use, making protofunctions and other stuff neccessary, but I understand the concept
And if youīve seen what Iīve written above, I HAVE the client and server ready already, the only thing missing is the connection
When I say "Iīm stuck" there, that means no more than Iīve spent 2 hours or so and havenīt had success yet, but you may bet, I will solve it on my own if I have to, asking around in here is just ment to be a shortcut to save me some time
Title: Re: Too dumb to get started?
Post by: killerbot on August 01, 2006, 08:32:07 pm
@Newbie0815

Well I agree with all the others learn first, but on the other hand you are no plain newbie ;-)

Let me ask you a few questions :
1) did you use inheritance ?

if so :
  2) is the destructor of your base class virtual ?
  3) why inheritance ?


4) hopefully no public variables ?
5) did you use RAII ?

Just a few simple questions ;-)

Cheers.
Title: Re: Too dumb to get started?
Post by: Newbie0815 on August 01, 2006, 11:50:19 pm
well, I sure am a newbie, maybe not that bloody anymore, still I wouldnīt dare to publish any of my products, Iīm by far not out of a stage of messing around with it, just to learn

now let me see whether I can pass your test

1 and 3) I ran into inheritance in a few of the tutorials, I even coded an example from one tutorial just to see how it works
So I know what it is about, I know specially in win32 applications theres a LOT of inherited stuff from the libraries, but other than that Iīm not using it in my current project (yet) because while learning I like to see what Iīm doing within every function, without I have to lookup from where it came, Iīm busy enough to remember (or look up) the unavoidable ones
I know it would give a faster application, but with this mini program speed is my last concern

2) More by chance I was using virtual destructors from start, by the time when I discovered the reason in a sidenote of a tutorial I was already used to it

4) should I rather use 100s of getīs? From php Iīm so much used to have all variables available at all times throughout a complete script, I like my little notepad file aside where I write down all variables Iīm using
5) no, I think Iīve seen something about it, something about easy cleanup, but I guess cleaning up I can do after Iīm done messing up
Title: Re: Too dumb to get started?
Post by: killerbot on August 02, 2006, 12:05:10 am
2) More by chance I was using virtual destructors from start, by the time when I discovered the reason in a sidenote of a tutorial I was already used to it

cool

4) should I rather use 100s of getīs? From php Iīm so much used to have all variables available at all times throughout a complete script, I like my little notepad file aside where I write down all variables Iīm using

yes !!  Information hiding/maintenance/reusability : interfaces are the things you work with and exchange with other parts of the code
Note : a class should have not to many members, if it does this hints your class it doing to much things.
Title: Re: Too dumb to get started?
Post by: sethjackson on August 02, 2006, 12:07:36 am
4) should I rather use 100s of getīs? From php Iīm so much used to have all variables available at all times throughout a complete script, I like my little notepad file aside where I write down all variables Iīm using

yes !!  Information hiding/maintenance/reusability : interfaces are the things you work with and exchange with other parts of the code
Note : a class should have not to many members, if it does this hints your class it doing to much things.

Yes yes yes yes, and yes. :)
Title: Re: Too dumb to get started?
Post by: marfig on August 02, 2006, 12:14:09 am
So, at the light of this... I really suggest you consider learning the programming language first. Least you want to come back in a moth or two complaining you can't learn C++ from the tutorials
Title: Re: Too dumb to get started?
Post by: Newbie0815 on August 02, 2006, 12:22:54 am
@killerbot
okok, Iīll take that advice about private variables
so I donīt get an A in your test, but did I pass?  :D

@marfig
isnīt that what Iīm doing? with the only difference that I have a concrete project to work on, rather than dry studying the theory?

@all
and what about my actual question? how to "translate" code from other compilers? Theres not THAT much different between borland and gcc, I just think since this must be a pretty common problem for those who use prewitten libraries and classes to speed up their development, there should be an easier way than go through the code line by line
Title: Re: Too dumb to get started?
Post by: sethjackson on August 02, 2006, 12:55:08 am
@killerbot
okok, Iīll take that advice about private variables
so I donīt get an A in your test, but did I pass?  :D

@marfig
isnīt that what Iīm doing? with the only difference that I have a concrete project to work on, rather than dry studying the theory?

@all
and what about my actual question? how to "translate" code from other compilers? Theres not THAT much different between borland and gcc, I just think since this must be a pretty common problem for those who use prewitten libraries and classes to speed up their development, there should be an easier way than go through the code line by line

Well if the code you are looking at uses STL not much at all should be different. The code from other libraries may be different, but the code shouldn't be that much difference syntax wise.... Or maybe I misunderstood you.
Title: Re: Too dumb to get started?
Post by: Auria on August 02, 2006, 12:59:59 am
Quote
and what about my actual question? how to "translate" code from other compilers? Theres not THAT much different between borland and gcc, I just think since this must be a pretty common problem for those who use prewitten libraries and classes to speed up their development, there should be an easier way than go through the code line by line

If you had learned the programming language before trying to do an actual project you would maybe know (!) there is no magic way to fix small errors between compilers, you need to know the language, and read the given error messages. If everyone keeps telling you to learn the language it must be for some reason :D

Also, it' s possible (and rather probable) that you didn't link against the right libraries
Title: Re: Too dumb to get started?
Post by: mdelfede on August 02, 2006, 01:14:15 am
isnīt that what Iīm doing? with the only difference that I have a concrete project to work on, rather than dry studying the theory?
Here I agree, for me too it's easier learning doing something that makes me happy when I see it does something useful, instead of coding only small samples. But... keep in mind 2 points :
1- without the theory (which you can learn while doing your test project) you'll not go too far.
2- your result has many, many and many chances to become something horrible and impossible to mantain. so, take it as-is, something to practice on and NOT something beautiful and bug-free. You'll notice it at the end when you'll think "why have I coded it like this ?" That happens to me when I'm in a hurry to see it working; when it's done, I start correcting again and again, up to I give up and rewrite from scratch.

and what about my actual question? how to "translate" code from other compilers? Theres not THAT much different between borland and gcc, I just think since this must be a pretty common problem for those who use prewitten libraries and classes to speed up their development, there should be an easier way than go through the code line by line

As I told you, Borland has some non-standard constructs that you simply can't translate to pure C++, at least for C++Builder 6 which I know.
For example, in C++Builder you can do such a thing :

Code: [Select]
class Test
{
  private :
    int anInteger;

    void setInteger(int i) { if (i >= 0) anInteger = i ; }

  public :
    __property IntProp = {read = anInteger, write = setInteger} ;
};

Test test ;

test.IntProp = 2 ;
int j = test.IntProp ;

Even if I find it a beautiful construct (wondering why it's not included in Ansi C++....), that's NOT standard. In pure C++ you write :

Code: [Select]
class Test
{
  private :
    int anInteger;

  public :
    void setInteger(int i) { if (i >= 0) anInteger = i ; }
    int getInteger(void) { return anInteger ; }

};

Test test ;

test.setInteger(2) ;
int j = test.getInteger() ;

As you see, even with this small code sample, you must change a lot. In C++ builder the __property construct is used widely, as are other non standard constructs. When you use the IDE to make an app skeleton, it gives you code full of such nonstandard constructs. Believe me, takes LOOOONG to convert to pure ansi C++.

Ciao

Max
Title: Re: Too dumb to get started?
Post by: kagerato on August 02, 2006, 01:17:49 am
Quote from: Der Meister
Just to be precise: C is *NOT* a functional programming language. It's an imperative (or procedural, if you like this word more) language. Functional programming languages are languages like Haskell or Lisp.

Correct.  C is sometimes mistakenly referred to as a functional language because the basic unit your imperative statements are organized into is called a function.  Many people (including myself) fail to make the proper distinction.

Semantics regarding this usually do not come into play because there are hardly any functional languages in widespread use outside the academic world.

Quote from: kidmosey
And as for the rest of your article... Well said!
Quote from: PDEE
Wow kagerato, great post. I learnt something from that. Thanks

I simply give my best -- there's no point in saying anything if you don't say something meaningful, I feel.

Quote from: Newbie0815
I got lost almost right away, mostly because there are no 2 tutorials for the same compiler, from videos at MSN how to write applications in visual C++ to plain C++ code I can use in CodeBlocks, they are not compatible, CodeBlocks allows me to import almost any format, but mixing them doesnīt work

Absolutely no clue what you're trying to say.  "Formats"?  Source code is normally stored as ASCII text (or occasionally, using an ANSI codepage or UTF-8 instead).  As for C++ "dialects", read further.

Quote from: Newbie0815
Iīve noticed, most of them are written in VB or VC, Iīve even downloaded and installed Visual Studio Express, but for one the code is so way different from gcc, almost an entirely new language and the options are pretty much limited to what the compiler offers

The standard method of GUI programming using Visual C++ is MFC, the Microsoft Foundation Classes.  As the name suggests, they are an object-oriented wrapper around the win32 API.

That doesn't have much, if anything, to do with the kind of code and samples you appear to be dealing with.  I'm not sure where you picked up the idea that every compiler has its own C++ dialect, completely incompatible with another's.  To a very limited degree, that was true ten years ago.  It's not a matter of concern these days, as C++ has gradually become more and more standardized.

Visual Basic 6 is not in any way compatible with C or C++ code.  It's an entirely different language, one that I would recommend newcomers stay away from.

Visual Basic .NET doesn't have nearly as many glaring problems as VB6.  However, using it ties you to the .NET platform.  (C# has alternate implementations and uses.)  Since the changes made to Visual Basic for the purpose of transforming it into a .NET-compatible language have eliminated several of the original benefits of the language and platform, C# has seen much greater adoption.

By "Visual Studio Express", I believe you mean "Visual C++ Express".  Upon last examination, the entire Visual Studio suite was not available for free as a single entity.  Rather, there are separate packages for each language.

I don't recommend using Visual Studio -- it's huge and it provides little that a free IDE like CodeBlocks does not (assuming we're working with C++).  Furthermore, the Express editions are, in essence, a marketing lure for the .NET platform and other Microsoft-dominated technologies.

Quote from: Newbie0815
Thats where Iīm stuck now, I found just ONE tutorial that explains it short and easy at http://www.c-worker.ch/tuts/wstut_op.html (in german) but that one is written for borland and my attempts to translate it to gcc have failed so far, meaning I canīt even start implementing it into my project

Maybe someone here can help me out? How to mix code written for different compilers or how to translate it?

The source for both, is direct available on the page

Client: http://www.c-worker.ch/tuts/sock.c
Server: http://www.c-worker.ch/tuts/socksrv.c

This code is not "written for borland".  It's win32 C, specifically using the winsock library.  It will build using any C compiler, so long as 1.) the win32 headers are available and 2.) there are no syntax or linking errors.

I successfully compiled "sock.c" using gcc and this command:

Code: [Select]
gcc sock.c -o sock.exe -lws2_32
The linker command must go on the end there.  (Took me a few minutes to remember this.  Had it specified before the source file and was wondering why linker errors were appearing.  The GCC man page warns you about this -- always a good idea to read the documentation.)

The fact that you have to explicitly link (using the -l switch, for GCC) to particular libraries is simply a part of C/C++ programming.  This little winsock example fails just as spectacularly in Visual C++ if you fail to specify the library correctly.

This example is simple because it's a console application using winsock to provide basic networking facilities.  Nevermind that it hardly does anything, let alone provide a "simple chatserver".  Don't deceive yourself into thinking it's a simple matter to scale basic examples into production-quality complete applications.

Quote from: Newbie0815
Object oriented programming isnīt new to me (...)
Quote from: Newbie0815
So I know what it is about, I know specially in win32 applications theres a LOT of inherited stuff from the libraries

Oh? You don't seem to know what inheritance is.  Inheritance does not mean "included from header files".  Inheritance is basing a sub-class on the methods and fields of its parent.  Using the win32 API does not involve inheritance.  You missed the part about win32 being written in C, and hence lacking any object-orientation.

Quote from: Newbie0815
I still don't like the idea of global and local variables, but I do understand the concept (...)

In C, minimizing global variables is essential to preventing name conflicts and increasing the overall readability of the code.  It's a core concept.

In C++, you don't use global variables, period.  Furthermore, encapsulating classes effectively by minimizing the number of public fields and methods is a critical part of writing good code.  Strong usage of encapsulation leads to easy isolation of bugs, among other benefits.

Quote from: Newbie0815
and what about my actual question? how to "translate" code from other compilers? Theres not THAT much different between borland and gcc (...)

Concerning the referenced code, there is no difference.  No compiler-specific feature has been used.  Indeed, it's rare to find an instance of it in C code to begin with.

Your problem is simple.  Either you do not have your compiler installed correctly, or you do not know how to use it (or the IDE, whichever is relevant).
Title: Re: Too dumb to get started?
Post by: marfig on August 02, 2006, 02:08:29 am
I quit. This is a clear case of "you will see" :)
Title: Re: Too dumb to get started?
Post by: kidmosey on August 02, 2006, 07:32:17 am
A few quick comments on encapsulation that were missed earlier.

1. It prevents arbitrary setting of variables.  Instead of the user/programmer setting a member "weight" to a negative value, you just add a constraint to the SetWeight method.  You can make it throw an exception, return an error value, or automatically set the value to zero.

2. You may want certain values to be read-only.

3. (this one was mentioned) You may want to change something later without changing the interface.  Say you have a member m_total.  If you set this as public, you will never be able to do things like returning "width * height" to optimize the size of your class (this also works the other way around).

4. Last I checked, you cannot set class members as virtual.

I'm sure I missed several more, but reading this thread made me tired :D
Title: Re: Too dumb to get started?
Post by: mdelfede on August 02, 2006, 10:36:06 am
A few quick comments on encapsulation that were missed earlier.

1. It prevents arbitrary setting of variables.  Instead of the user/programmer setting a member "weight" to a negative value, you just add a constraint to the SetWeight method.  You can make it throw an exception, return an error value, or automatically set the value to zero.

2. You may want certain values to be read-only.

3. (this one was mentioned) You may want to change something later without changing the interface.  Say you have a member m_total.  If you set this as public, you will never be able to do things like returning "width * height" to optimize the size of your class (this also works the other way around).


A little comment about... I think that Borland with his language extensions made encapsulation better with properties, taking the advantages of both member variables (simpler use in expressions, clearer code) and getters/setters (good encapsulation, optimizations and calculations on-the-fly).
I'd really like such a construct in future c++ standard.

Ciao

Max