Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: Karlos on February 25, 2003, 11:55:07 AM

Title: C/C++ learning
Post by: Karlos on February 25, 2003, 11:55:07 AM
Hi all,

There's been a lot of discussion on programming recently. It seems to be the case that there is much interest (both positive and negative) in C/C++. One thing that was clear to me is that there are quite a number of people who want to learn but are put off for different reasons.

Something Atheist wrote, suggesting you won't learn from a message board got me thinking. Does anybody think a series of posted tutorials in C/C++ would be useful for those interested?

Assuming some C/C++ coders could find the time to organise it, that is...

I got thinking, each tutorial could be a seperate thread and people could post their queries on that topic rather than a large monolithic thread. The basic rules would be that questions are answered (where possible) and no arguing over semantics and C vs BASIC etc :-), unless it clarifies a point relevent to the subject matter.

Once the language is covered, those with the relevant expertise could introduce Amiga specific coding.

I wouldn't mind contributuing to a such a project if it could be organised.

Suggestions?

Peace out,
K
Title: Re: C/C++ learning
Post by: z5 on February 25, 2003, 12:00:59 PM
Well, i for one would be really interested (i just bought a book on C++)!!
Title: Re: C/C++ learning
Post by: Bodie on February 25, 2003, 12:04:00 PM
Quote

z5 wrote:
Well, i for one would be really interested (i just bought a book on C++)!!



Same!

Hasn't someone, Sidewinder i think, already started a tutorial on their webpage?
Title: Re: C/C++ learning
Post by: sgm on February 25, 2003, 01:05:53 PM
About good books on C++, you don't want to miss the ones below:

Mid-experienced C++ programmer:
http://www.amazon.com/exec/obidos/tg/detail/-/0201924889/qid=1046178128/sr=8-1/ref=sr_8_1/102-0744621-9284963?v=glance&s=books&n=507846 (http://www.amazon.com/exec/obidos/tg/detail/-/0201924889/qid=1046178128/sr=8-1/ref=sr_8_1/102-0744621-9284963?v=glance&s=books&n=507846)

Advanced C++ programmer:
http://www.amazon.com/exec/obidos/tg/detail/-/020163371X/qid=1046178128/sr=8-3/ref=sr_8_3/102-0744621-9284963?v=glance&s=books&n=507846 (http://www.amazon.com/exec/obidos/tg/detail/-/020163371X/qid=1046178128/sr=8-3/ref=sr_8_3/102-0744621-9284963?v=glance&s=books&n=507846)
Title: Re: C/C++ learning
Post by: holbromf on February 25, 2003, 01:21:50 PM
Ira Pohl has usefull books on the use of C++ syntax to support Object Orientation when you have some experience in C++.

                                                       Cheers     Mike
Title: Re: C/C++ learning
Post by: Themamboman on February 25, 2003, 02:55:10 PM
How about C++ tuts specifically aimed at Amiga programming?
Title: Re: C/C++ learning
Post by: Karlos on February 25, 2003, 03:20:07 PM
Quote

Themamboman wrote:
How about C++ tuts specifically aimed at Amiga programming?


Well, I feel that just learning C/C++ would be better for the majority of would be recipients.

Once you know a language well, understanding the SDK for a platform is often a good deal easier anyway.

If you get into C++ big time, then like me, you'll probably find that you tend to abstract away the AmigaOS dependent stuff behind your own preferred classes anyway ;-) All of which helps more than you might realise. A fully debugged Window class that encasulates your basic intuition window can save you lots of time later when you want to write another app and can't be bothered having to recode all the window/event handling stuff!
Title: Re: C/C++ learning
Post by: jdiffend on February 25, 2003, 04:27:18 PM
There are lots of web sites with C/C++ tutorials.
You can find a lot of stuff here (http://www.thefreecountry.com/index.shtml) and Amiga example source on Aminet.
Title: Re: C/C++ learning
Post by: iamaboringperson on February 25, 2003, 06:20:38 PM
who would be interested in starting up an amiga programming tutorial site?
a number of people could contribute, i would like to help in such an activity


oh and if anybody would like to know of a good reference for C:
C: The Complete Reference
& its by Herbert Schildt, so you know it must be bloody good
 :-)
Title: Re: C/C++ learning
Post by: Sidewinder on February 25, 2003, 07:57:37 PM
I already have started an Amiga programming tutorial site (http://www.liquido2.com/tutorial).  I'm always looking for contributions by other programmers or ideas of what should be covered in the tutorials.  It would most definately be best to have a single, comprehensive resource, than to have 100 different tutorials that repeat the same information.
Title: Re: C/C++ learning
Post by: Karlos on February 26, 2003, 09:52:39 AM
Hi Sidewinder,

That's an interesting site you got there. Nicely laid out and easy to nagivate.
I do have one or two comments if I may be so bold. Also this isn't intended to be a criticism, just observation...



I hope you don't think I'm being to picky, but according to the ANSI 2.0 C rules, either you do not define the signature of main(), or if you do define a return type/arg list, you should also specify a return value, else it goes undefined:

either (old style)

#include
main() /* no signature */
{
   printf("Hello World\n");
}

or (preffered as of 1999 amendment)

#include
int main() /* returns int, no args passed*/
{
   printf("Hello world\n");
   return 0;
}

Using 'void' to signify no arguments is depricated (behaviuor adopted from C++).



Back to tutorials, I do feel that there is a bit of a leap for beginners moving from 'hello world' to opening an intuition window in the second lesson. I realise that it was a demonstration only, but could look quite daunting to those new to the language.

Well, enough said - youre probably ready to climb through the monitor and kick my ass by now ;-)

Going back to my original post, what I had in mind was something that would introduce the language itself, structured something like this

1) What is C?
     Origin, about compiler v interpreter etc.
     Source code arrangement, #includes etc'

2) Hello world
    The canonical 1st program.

3) Variables & Types
    Variables, types, arrays, enums, constants etc.
    Scope, duration.

4) Operators
     Overview of C operator syntax, precedence rules etc.

5) Programming constructs
    if/else
    switch/case/default
    loops
    goto (and misuse of)

6) Functions
    Procedural programming paragdim.
    Argument passing.
    return types etc.

7) IO
    More detailed look at basic ANSI C IO.
    Formatted IO.
    File streams.
    Binary IO.

8) Pointers
    The dreaded lurgy explained ;-)

9) Structures
    Cocept, uses, arrays of structures etc.

10) Additional topics
    Advanced pointers, function pointers, lists etc, vararg functions, unions etc.

That would basically cover C as a language.

I would begin on C++ only once sufficient C was understood to make sense of what was going on syntax wise. Probably introduce the concept of classes once C structures had been covered and move on from there.

As for AmigaOS specific coding, I would aim to start on that once C functions had been covered and not before.

Disclaimer : All of the above is IMHO ;-)
Title: Re: C/C++ learning
Post by: FuZion on February 26, 2003, 10:04:19 AM
I would certainly be interested in using a site like this.
Karlos seems to have a bit of know how too, for a beginner like  ;-)
I like the idea of individual forums on each tutorial too helping to focus on each one individually.

Is there anything anyone can do to make this happen?
Title: Re: C/C++ learning
Post by: Karlos on February 26, 2003, 11:07:12 AM
Hi again,

Quote

FuZion wrote:
Karlos seems to have a bit of know how too, for a beginner like  ;-)


Why, ya' cheeky beggar like, erm, I think... :-P

I'm not new to C/C++, though not as knowledgable as I'd like to be, especially when it comes to AmigaOS specific coding and the V3 C++ STL.

Even so, knowing something is one thing, teaching it however, is another matter :-)

I did do a stint as an undergraduate supervisor during the first (and only) year of my ill-fated chemistry PhD. That involved quite a lot of designing tutorials, interactive tuition and the like.

Quote

I like the idea of individual forums on each tutorial too helping to focus on each one individually.


Yeah, I thought that would be quite handy since it gives a degree of interactivity which is often essential for learning. You'd need a few ground rules about off topic posts and stuff, as I mentioned at the start.

Quote

Is there anything anyone can do to make this happen?


I was thinking that it needs a few people to work on it. Maybe Wayne could open up a teaching zone in the forums? That could pave the way for all sorts of handy stuff, everything from AmigaDOS scripting to web design.

Even without that, it wouldn't be too bad just to write a tutorial and post it normally in this forum. I do admit, I've yet to find a way to preserve certian essential formatting such as indentation - it always ends up with the whitespace stripped out after I post!
Title: Re: C/C++ learning
Post by: Atheist on March 02, 2003, 10:08:33 AM
Hi Karlos,

Just noticed this thread. This a great idea if someone is willing to set it up.

Like you said, it would have an additional set of rules to the ones already being used, concerning OT talking, etc.etc.

For me to participate, even more rules are needed.

Yes, more.

A) 68k and A1 should be separate, people can always look across the fence.
B) We all use the same Version no. and brand of C or C++ (orANSI) compiler, debugger, linker, etc. (I'm a beginner, so don't have a preference).
C) Everyone has to have the same SDK.

A very specific list of every item needed to participate, easy to find the list, and a http:// where to buy the items.

Maybe, by chance, you read about my ridiculous difficulties in making a RAM disk work on my w98se?

We all have to be on the same wavelength. I'm not stupid, but, when I'm learning something, even a trivial thing like everybody in the classroom having different keyboards is enough to make me give up. When you say, pick this menu item, I expect it to be exactly where you tell me to look. Type this in, I will type it letter for letter.


I'm not a quitter, but I need solid reference points.

Amiga! Lets change the world!
Title: Re: C/C++ learning
Post by: Mikey_C on March 02, 2003, 10:19:07 AM
I for one, would be interested in such a project here on Amiga.org. Perhaps a seperate Tutorial Forum could be set up?

Also, what compiler should we all be using?
(so that I can purchase one in advance, if the idea goes ahead. - I hope it does.)

Mikey C
Title: Re: C/C++ learning
Post by: Kronos on March 02, 2003, 11:05:42 AM
@MikeyC

These are the options:
a) SAS-C: only 68k, C++-part very primitive.
b) StormC: 68k, WOS complete C++ with IDE, easy to use.
c)HiSoft/MaxonC: 68k, one could say roughly an older version of StormC.
d) vbcc: 68k,WOS,PuP(?),MOS,free,no C++,no IDE
e) gcc: 68k,WOS,PuP,MOS,AROS,OS4,free,full C++, no IDE.

GoldED can serve as an (limited) IDE for the lasrt 2.
Title: Re: C/C++ learning
Post by: Dietmar on March 02, 2003, 01:17:33 PM
Quote
GoldED can serve as an (limited) IDE for the last 2.


Actually, GoldED integrates with any C compiler out there via the "generic" variant of its C/C++ mode. It's not an IDE in the strict sense,  rather running, making, etc. via toolbars and general C/C++ support, such as synax highlighting, makefile generation, symbol lookup, etc. Some variants of the C/C++ mode add support for specific compiler features: breakpoints for StormC3, scmsg for SAS/C and options programs for gcc and vbcc, etc. But does not limit the C/C++ mode to these compilers.
Title: Re: C/C++ learning
Post by: Mikey_C on March 02, 2003, 01:30:43 PM
Off topic.

BTW, Dietmer, I have been meaning to ask you this for ages. (As a registered user of GoldED 6)

Why, do you feel the need to only sell copies of the latest GoldEd through your website only? I ask because IMO a program as good as GoldED should be available internationally via retailers. I brought GoldEd 6 from Kicksoft, why can't such an arrangement like that be made again?

Surely selling extra copies benefits you?

Mikey C
 
Title: Re: C/C++ learning
Post by: Kronos on March 02, 2003, 01:41:26 PM
@MikeyC
Allready answered here (http://www.morphzone.org/modules/newbb/viewtopic.php?topic_id=27&forum=16)
Title: Re: C/C++ learning
Post by: Dietmar on March 02, 2003, 06:27:18 AM
Quote
I brought GoldEd 6 from Kicksoft, why can't such an arrangement like that be made again?


It's been great working with Kicksoft and Ray, he's helped tremendously with distribution in England (and still is, by  offering GoldED6 well below the price of the AIX version). Regrettably, the number of Amiga users kept spiraling down and at some point, working with distributors no longer made financial sense (a distributor receives a solid share of the retail price, for expenses and services, something like 50%-75%). There are other, technical reasons, too, but I'm not getting into those now, they are secondary.
Title: Re: C/C++ learning
Post by: Karlos on March 04, 2003, 10:19:38 AM
Hi Atheist,

As it happens, I'm thinking of putting together that set of topics I mentioned earlier and banging it up on a free host somewhere. I'd post links to each tutorial (each as its own thread) in this forum each time I add a topic. Questions and (hopefully) answers could then be posted, courtesty of those nice people at Amiga.org.

As for your points about platform seperation etc, my original intention was to give tutorials on the pure ANSI C language so the choice of compiler would be down to the user.

I realise however, this may not suit the absolute beginner (we all were in that situation once), so there will be reccomendations. For example I was thinking StormC v3 is good enough for ANSI C coding, comes on the developer cd v2.1 (which would be useful for Amiga specific stuff later in the course) and has a nice IDE that is friendly enough for the beginner.

Each topics' turorial/example code will be guarenteed (hopefully) to work with the suggested set up (i.e. I'll actually test it myself ;-) beforehand)

People used to gcc etc. wouldn't really have much need for this tutorial site anyhow ;-) It's aimed at all those who want to learn C but are put off for the sorts of reasons that have cropped up in this forum (strange syntax etc. etc.).

Once the ANSI C is covered sufficiently, I'd hopefully introduce AmigaOS specific coding. Unfortunately, this is still something I'm learning myself ;-), so maybe I'll leave this to the experts!

Depending how it goes, I'd want to set up a C++ set of topics of a similar structure (but without the groundwork of the C syntax).

Finding the time is going to be the killer :-D

Suggestions folks?
Title: Re: C/C++ learning
Post by: jahc on March 06, 2003, 03:03:25 AM
I keep pointing out that theres already good tutorials on the web, just go to google.com and search for "C tutorial" or "C++ tutorial"..

check these out for example:

http://www.cplusplus.com/doc/tutorial/
http://www.cprogramming.com/tutorial.html
Title: Re: C/C++ learning
Post by: jahc on March 06, 2003, 03:07:19 AM
sorry, amiga specific tutorials would be good, but people need to learn ANSI C/C++ first..
Title: Re: C/C++ learning
Post by: Karlos on March 06, 2003, 09:17:23 AM
Hi Jahc,

That's what I'm talking about dude :-D
AmigaOS stuff would come after...

-edit-

Also, it wouldn't just be static tutorials, each one would have feedback via (this) forum...