Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: FuZion on February 15, 2003, 02:44:50 PM
-
I have always wanted to get programming but.... Didn't.
I've had ideas constantly but could never get anything on the go.
Can anyone point me towards some references & suggest software for the Amiga so I can have a crack at it.
Thanks, FuZion.
-
If you have never programmed before then you
should consider using a scripting language to
start with ( like perl or arexx ) simply because
understanding compiler messages that come back
from coding errors with C or C++ would kill
your enthusiasm real quick.
Once you have got used to the idea of variables,
conditionals and all that gubbis go straight to C,
do not pass BASIC and do not collect PASCAL.
Why?
Because the cross reference for programming Amiga OS calls using any other language than C ( or
C++ if you like to live wild ) sucks.
In fact play with AREXX given it is probably shipped
with your OS. And you might have a manual too....
-
DaveP is right C will drive you nuts if you've never touched it before.
If you have a PC I would recommend you have a crack at learning Java, get one of the Sams Learn Java in 31 days books or something. Although java isn't very powerfull it will get you used to programming techniques (although some say it encourages bad programming practices) and then once you have the grips of it, get a book on C, an IDE and have a crack at C.
-
If you are looking for a quick tutorial on starting Amiga sepcific programming in C you can stop by my tutorial (http://www.liquido2.com/tutorial) and start reading. C or C++ is really the only way to go on the Amiga right now if you want to get some serious work done. Starting with a scripting language (as was already suggested) is also a good place to start. It really depends on your style of learning. If you want to jump into the deep end and learn to swim that way learn C. If you're more comfortable in the kiddy pool at first then go the way of a scripting langauge.
-
I don't think its fair to call scripting languages
the kiddy pool. No need to give a new programmer
a complex or feel that they won't be respected
until they use a certain language.
Scripting languages are just a bit more accessable.
-
If your starting programming on amiga, go for Arexx. It´s pretty simple to programand to run.
-
Then again... Here comes the UNDOUBTLY best way to start learn ANY programming language:
Visit a freind of yours, who have two computers and know how to program. Then you let him introduce you to the language, and when that´s done, you´ll begin yourself. When you encounter problems, you´ll have your freind to help you solve the problems. Every language have a set of typical programming errors, which are difficult to solve for newcommers of the language, but your freind has been through all these, and can therefore help you to overcome them. Also, experienced programmers will more easily give you some inspiration which is needed allway.
Happy programming!!
-
@DaveP
No need to take offense. I did not mean to insult anyone using scriting languages. It is true that scripting languages are very powerful and many things can be done with them much more quickly and easier than the same tasks can be programmed in C or assembly.
When I started programming I started with AREXX, then AmigaBASIC, then AMOS BASIC, and then to C/C++ and assembly. These high level languages certainly did get me into programming quickly and I did some fun and interesting things with the scripting and BASIC languages. But for me it was just as difficult to move from these languages to C as it is for many to start with C from the beginning.
I guess I'm trying to say that if you want to start programming quickly and learn the general concepts of programming you should start with a scripting language. Initially it will be less frusterating than jumping right into C. But, on the other hand, if you then want to move on to C you will still have to suffer through the learning curve.
Some people learn better by jumping right in and thrashing around until it starts making sense. Other people take simple, graduated steps. It's all about learning style, not about good/bad languages.
I for one learn best by jumping right in.
-
@sidewinder
Im sorry. I guess Im a bit protective of people that
start out programming - Id hate to feel that they
felt second class citizens whilst they are using
scripting languages.
-
I have had a little experience with AMOS & Blitz in my time but nothing really worth talking about.
The two programs seemed to crash too often for me to really stick with & feel comfortable with.
I think I'm a "thrown in at the deep end" type of person so I'd bully myself into taking a look at C/C++
Is Storm the tool of choice on the Amiga or should I look elsewhere?
-
I strongly advise you to buy Hisoft C++ rather
than Storm.
-
Why would you consider Hisoft C++ better than the latest Storm C?
How advanced is the editor/debugger? Does Hisoft C++ come with something like the StormWizard GUI RAD?
-
I've begun an MUI and GCC tutorial. Check it out here:
http://www.ezcyberspace.com/gcc/
I'd be interested in any feedback anyone can provide.
Thanks,
IKE
-
i would definently start with C/C++
and i can certainly reccomend Sidewinder's page
it is VERY good!
i used to muck around with blitz basic years ago and i was just wating my time,
just remember that when you learn a language take it step by step, it does start off quite difficult
and its more important to learn the techniques and algorithms than learn a number of languages
stick with one or two languages, but practice your algorithms
-
I would suggest that you take a look at StormC 4 from Haage & Partner (http://www.haage-partner.de/). Currently they are running a special when you can get StormC 4 for only 50 Euros (about $50).
HiSoft C++ (http://www.hisoft.co.uk/) is also a great package and in my opinion has a better IDE than StormC, but StormC has support for modern C++ development using the STL and other more advanced things that are not properly supported in HiSoft C++. However, if you are only planning on programming in ANSI C then HiSoft has a more intuitive interface.
If you want a free package I would suggest looking into Louise's GCC archive. (http://www.innoidea.hu/subsites/amiga/developer/phpwebdev.php)
-
@FuZion
Ignore these creazy guys suggesting you to start with C. It may demoralize you completly and maybe you won't ever come back to the fantastic world of computing programming. C doesn't take you to Nirvana all the times anyway.
Some years ago, I would have suggested you to start with BASIC, but as a modern language, I don't like it because there isn't known widespread dialect. Most BASICs are highly propietary; Amos, Visual Basic, Blitz Basic, etc.
Java may be even more daunting than C because you can't really do anything useful without mastering the OOP paradigm. I abandoned Java many times in the 90s and got back to plain C or Assembler. Nowdays I hardly imagine doing a large project without Objects ;)
Assembler is very easy compared to C because the processor contains a handful of instructions. The problem is that you have to know the OS and hardware arquitecture in order to "speak" to the outer world; i.e. reading the keyboard, saying "Hello World". Please note that RISC processors are a bit more difficult to program in Assembler, in a very optimized way at least.
Start with a scripting language. A scripting language maybe even faster than Java or some other "self contained languages". A good suggestion would be Perl or PHP, with those you will get familiar soon with the C/Java syntax and you'll be able to do interesting dynamic web pages that you can even host on the Amiga. REXX and Rebol may be interesting, they aren't very convention though.
Computer languages are sometimes like spoken languages; there isn't a superior or inferior language, but there are languages that happen to be more appropriate on certain contexts.
Buy a couple of books, download tutorials, ask for help, and program, as much as you can!
-
Sidewinder wrote:
I would suggest that you take a look at StormC 4 from Haage & Partner (http://www.haage-partner.de/). Currently they are running a special when you can get StormC 4 for only 50 Euros (about $50).
Man, what a great deal, but because of the Amithlon fiasco, I thought we were in boycott mode. I was even thinking of getting it, but I despise C.
Amiga! How long must we suffer?
-
Sidewinder wrote:
If you are looking for a quick tutorial on starting Amiga sepcific programming in C you can stop by my tutorial (http://www.liquido2.com/tutorial) and start reading. C or C++ is really the only way to go on the Amiga right now if you want to get some serious work done. Starting with a scripting language (as was already suggested) is also a good place to start. It really depends on your style of learning. If you want to jump into the deep end and learn to swim that way learn C. If you're more comfortable in the kiddy pool at first then go the way of a scripting langauge.
Lets see; Lesson 1
------------------------
#include
int main(void)
{
printf( "Hello World!\n" );
}
------------------------------
I always reccommend Amos Prfessional & Compiler because I have a problem with C.
int main(void)
Why is that statement necessary? I read your page, and there is no real reason for it. Instead of void, what if I put in 9? I mean you say if it's not there it won't work, but does nothing, and yet every company that writes a compiler, won't remove the necesity to place it in the program.
Then there's
#include
I don't see a reason for that, other than every company that makes a compiler, won't remove the neccesity for it. If you don't use it, you can't print on the screen, yet if you use the print statment, clearly you want to print something, so logic clearly dictates that it HAS to be there, so, programming, being based on logic, should INCLUDE include AUTOMATICALLY, and yet again, no SW company will do the logical choice and automatically include, include, if you use the print statement.
Also, I find it annoying that lines have to be ended with ;
Therefore, these annoying things, many others, prevent me from using it. I don't want to memorize, if I use "if...then", maybe I need another #include, or it won't work. It should be handled automatically. I don't like listing variables, their type should be part of their name (i.e. $ is string, % is binary, etc).
printf( "Hello World!\n" )
I totally don't see a necessity for ( ) and " ", when basic easily survives with just " ".
It isn't a logical language.
Amiga! Can't wait to continue with Amos on A1.
-
Hehe, I can`t believe people are recommending C/C++ and JAVA as a first programming language. MADNESS! :lol:
I started on QBASIC (stop laughing!) then was forced onto PASCAL and COBOL I was then forced back onto PASCAL again. Visual BASIC was next (useful if you want to make small, simple apps). After that things got serious. C then C++ followed by the devil`s programming language, JAVA. *CRINGE* Most of that was at college, and most of it was horrible. I`ve used only Blitz BASIC and OPL on my PSION apart from all that, and you know what? The only language I still use is OPL. :-)
-
I always reccommend Amos Prfessional & Compiler because I have a problem with C.
int main(void)
Why is that statement necessary? I read your page, and there is no real reason for it. Instead of void, what if I put in 9? I mean you say if it's not there it won't work, but does nothing, and yet every company that writes a compiler, won't remove the necesity to place it in the program.
It defines the entrypoint to your program. void means
no arguments are supplied. The real signature is
int main( int argc, char*argv[] )
where argc is the argument count and argv is an
array of the strings passed to the program on invocation.
Why have a "main"? Well it allows you to define it
where you want - and you can have C "programs" which are not executable - useful in building libraries.
there's
#include
I don't see a reason for that, other than every company that makes a compiler, won't remove the neccesity for it. If you don't use it, you can't print on the screen, yet if you use the print statment, clearly you want to print something, so logic clearly dictates that it HAS to be there, so, programming, being based on logic, should INCLUDE include AUTOMATICALLY, and yet again, no SW company will do the logical choice and automatically include, include, if you use the print statement.
Because there are different methods of printing. stdio just happens to be one place where printing to the screen is implemented. In fact it contains all console I/O functions that write to stdout, stderr and read in from stdin.
There is fprintf which is used for printing text to a file descriptor, sprintf which is used for printing text into a string.
C is a language with no built in functions you see. It has basic types and operators. This allows you to re-define printf somewhere else ( say make it print to a graphical window ).
Therefore, these annoying things, many others, prevent me from using it. I don't want to memorize, if I use "if...then", maybe I need another #include, or it won't work. It should be handled automatically. I don't like listing variables, their type should be part of their name (i.e. $ is string, % is binary, etc).
printf( "Hello World!\n" )
I totally don't see a necessity for ( ) and " ", when basic easily survives with just " ".
It isn't a logical language.
Au contraire, it is an extremely logical language. ( indicates start of parameters, ) indicates end of parameters so that you can make parameters span multiple lines.
Why should types be part of their name? What benefit does it give you?
; indicates end of statement. Again this is useful for
multi line stuff but also for single line stuff where
you might want to fit multiple statements into one
line ( for example the use of ; in if and while ).
Automatic includes would break the ability to redefine functions.
I would NEVER recommend AMOS pro and compiler
first because it has a bunch of sucky default requesters that allow everyone to spot an AMOS pro program a mile of ( that and everyone forgets to trap CNTRL-A ) and secondly the add on routines for supporting AGA do not work well into the environment and finally because it does not support RTG by itself.
Lastly, it teaches you sloppy programming habits.
-
HiSoft is better because the IDE is more intuitive
and that is vital for beginners. It also doesnt crash
every five minutes like StormC 3 and 4.
Sure it doesnt support STL out of the box but
then most beginners dont want that.
IT doesnt have RAD Wizards ( excuse me while I suppress my urge to mess my pants with excitement ) but it does have an object library for rapid application development. It has a fine debugger.
-
@Atheist
I feel the same. I like things to be logical, and not to have double standards. I bet the compilers
do a few things automatically, but when it comes to the actual programming it gets lazy. I also
think, if its possible, then why not do it?
<-------------Severe logic failure in progress------------->
<---------Please unplug keyboard and press any key--------->
-
@Atheist
you really need to study C, start to program in it, and learn the difference between a structured programming language & a proceedual one
i assure you, there is a good reason BASIC is not used in the real world, and why C & C++ is
you will find that all that #include, (void), & ;, crap is nessesary for structured & OO programming
:-)
-
I recommend to learn 'C' right away. You'd just be wasting time learning a scripting language as you'll probably want to learn 'C' at some point anyway.
Having to "unlearn" the stuff you learned before and then having to relearn the 'C' way of doing things would probably be harder than if you'd just went straight to 'C' in the first place.
Don't listen to people saying its too hard - 'C' is really very simple and powerful language once you've grasped the basic concepts of the language.
Good luck!
-
Personally, I like the C++ language. Here are some free tutorials on C++ :
http://www.cprogramming.com/tutorial.html
http://www.cplusplus.com/doc/tutorial/
These two tutorials rock. They are really really good.
Once you've mastered "ANSI" C++ , then you can learn how to do Amiga specific stuff by getting the Rom Kernal Manuals from somewhere. They are included on the Amiga Developer CD, which should be available from Haage&Partner or any other good Amiga dealer. I got mine from Anything Amiga in Australia for about $45 Australian dollars (cant remember exactly.)
The Amiga Developer CD also has a free C/C++ compiler called StormC 3.0. It's very easy to use.
To anyone who wants to get into coding.. if you really want to program, follow my advice! Good luck! And if you get stuck with something, ask for help on this forum!!
-
@Atheist
It isn't a logical language.
:roflmao:
As was already said, C is an EXTREAMLY logical language, and that's what makes it a pain in the ass sometimes.
Your arguments about the problems with C are moot. The simple fact remains that the grammar of C is one of the most elegant and powerful grammars around. Its syntax is strange, I will grant you that, but its power and flexability is undeniable. With a mere 32 keywords C is able tackle even the most difficult programming tasks. AMOS and C represent the two fringes of the progrmaming language spectrum. C is small and simple, no frills, no excess--anything you need you must make yourself or #include (which, by the way, is the reason for the #include statment). AMOS is at the other end of the spectrum and has hundreds of commands and a simple, yet not very flexable syntax. AMOS has a more difficult time adapting to changes.
Lest you think that I am preaching the superiority of C over AMOS and other such languages, you may wish to note that liquido2.com (http://www.liquido2.com) (which is my domain and where I host my C tutorial) is also the home of the AMOS Factory. In addition I am in the process, even today, of attempting to port the AMOS grammer to the A1 and other systems.
My final statement is this: AMOS and C are different approaches to programming, both have their pros and cons, and there is absolutely no reason why someone cannot learn C as a first programming language if they so choose.
-
FuZion, if i we're you, i would go with a very simple version of BASIC and then move on to C.
Something most people here (i'm assuming you all have learned a number of languages same as i have) seem to have forgotten is there is a hadfull of simple concepts that stretch across all languages. For example, variables, loops, if statements, conditional operators, mathmatical operators, etc. Even in the nitty gritty world of assembler you have operators like JSR, BRE and so on. BASIC lends itself well to the novice programmer because they aren't burdened with a complex and obscure syntax and allows them to 'pick up' the basic ideas first. You won't be writing the newest 3D library in BASIC (ive done 3D stuff though) because its interpereted and as a language very limited. But that's the idea, keep it simple. Arexx i discount because it's mainly used for interprocess communication (the arexx port in your favorite app) and not geared for real applications development. There is only 1 type of variable, it's a script, how about trying to find the offset for any library you want to include in your arexx app and you will soon learn what i mean. And Java is just as complicated as C. On the other hand BASIC usually offers access to a small set of common system library calls through custom functions. Opening windows in Amiga Basic compared to C is worlds apart. Only in C you will have full access to the window at the cost of complexity. And if your just learning how to write code you don't want to be bogged down with pointers and idcmp flags that are all part of the OS side and not the code side.
Once you've learned the basics you can migrate to and from other languages no matter how exotic the language might be. Trust me, if you start off with something complicated like C (even arexx imho) you will find yourself spending more time fighting to figure out how to open a window or make a library call rather than how to structure your code. Something that's at the heart of any piece of code no matter what language you use.
As for which version of BASIC to use, i can't really say. :) Only that AMOS is really a poor implementation (it has it's advantages too) and like someone already said up there, it has a zillion custom calls to replace librarys in C. Amiga Basic will only run on a 1.3 (maybe 2.0) system and it's sort of a hack job. Hey, M$ wrote it for Amiga OS. At least it was a simple enough implementation and not blown out of proportions like AMOS. The only other one i can think of right now is Blitz Basic. Try starting there.
Ivan
-
A propos C development:
--- Release Announcement ---
GoldED Studio C/C++ IDE Updated
The GoldED-based C/C++ IDE for gcc, vbcc, StormC3 and other compilers has been updated.
The latest addition to the Integrated C/C++ Development Environment is clickable output during 'make': Compiler outputs appears in a resizable container. If you click on a file name, the source code is loaded and the cursor is positioned in the erroneous line.
Screenshot:
http://golded.dietmar-eilert.de/images/screen_gcc.gif
Download:
http://hometown.aol.com/goldedfiles/myhomepage/files/envCPP31.lzx
As usual, an updated free version of GoldED can be downloaded, too. The free version is fully functional but limited to editing files not larger than 1000 lines. It includes most add-ons from the commercial distribution (only spell checking and gcc are missing to keep the file size within reasonable
limits).
Download:
http://golded.dietmar-eilert.de/projects/golded/trial.htm
--- end ---
Btw, GoldED includes a small BASIC interpreter, too. Just plain ANSI BASIC, no Amiga functions at all. Should be ok for learning BASIC. But, like others here, I strongly advise against BASIC as first programming language. It spoils your style. If you ever plan to develop professionally, you will have to learn C. Other high level languages or script languages do not prepare you for C. You will learn little to nothing if you start with BASIC and then move on to C. On the other hand, Assembler is good preparation for C, because you'll get a feel for the hardware that will be useful to you later. Just don't do any large project with it. Spend some months (1-3) with assembler, develop a small program, then move on to C/C++. However, whatever you do, you should by now know what kind of software you want to write. Developing software is fun as long as you see results and are motivated. If all you want to do is "learn a language", you might as well stop now. You'll find the experience too frustrating ;-)
-
DaveP wrote:
It defines the entrypoint to your program. void means
no arguments are supplied. The real signature is
int main( int argc, char*argv[] )
where argc is the argument count and argv is an
array of the strings passed to the program on invocation.
So if I put "int argc" as "int 3"
It would accept up to 3 words or numbers, in addition to the name of the cammand, from the shell prompt? Or from being called from another program.
char*argv
This looks like you are multiplying the terms.
Or, are variable names supposed to be placed between the square brackets? I don't get it.
Because there are different methods of printing. stdio just happens to be one place where printing to the screen is implemented. In fact it contains all console I/O functions that write to stdout, stderr and read in from stdin.
When you say, it contains all console functions, the compiled program only gets the portion needed, right?
You see, what gets me is, every time you want to use a command, you have to find the include that matches it.
sprintf which is used for printing text into a string.
??? you mean like A$=Inkey$
C is a language with no built in functions you see. It has basic types and operators. This allows you to re-define printf somewhere else ( say make it print to a graphical window ).
Amos Screen 4
and secondly the add on routines for supporting AGA do not work well into the
environment
Well, Francois Lionet, never got around to doing an AGA version.
Lastly, it teaches you sloppy programming habits.
I can see this being a problem.
I don't know if I'll ever be able to understand what "building a library" means.
I know about half of the Amos commands, but never got a hang of Amal. The awful thing is Amos, even compiled, could never be as fast as C. Nor can you force the computer to do certain things with it. I have a program that 500k in size. 2/3 data statements. I know that I wouldn't have a clue where to start converting it. Especially since, I've looked at programs a couple of pages long, and even knowing, the if then, while, ;, commands, its unreadable. Maybe I don't have what it takes.
Well, at any rate, which C. People say C, C++, then there's ANSI C (and maybe ANSI C++). Is ANSI the name of a company, like Storm is?
I've always considered taking a chance at using it.
-
Atheist wrote:
So if I put "int argc" as "int 3"
It would accept up to 3 words or numbers, in addition to the name of the cammand, from the shell prompt? Or from being called from another program.
That, my good man would be a syntax error. When you define any function C (just as many other languages) the definition says only what types of variables are handed to the function, not what the allowed values are. It's up to you, when you write the guts of the function how it deals with unwanted values etc.
char*argv
This looks like you are multiplying the terms.
Or, are variable names supposed to be placed between the square brackets? I don't get it.
Unfortuantely thats C pointer syntax for you. What 'char* argv[]' actually says is 'argv is a pointer to an array of characters'.
Arrays and pointers in C are also pretty much interchangable. This means that you could also declare it as 'char** argv', which means 'argv is a pointer to pointers to characters'.
Don't worry about it too much yet though...
Here's a simple program (off the top of my head so iut may have bugs) you could try to compile...
/*
A simple C program to show arguments passed
to main()
*/
#include
int main(int argc, char* argv[])
{
int i;
puts("Here's what was passed to main()");
for (i=0; i {
printf ("Argument %d was '%s\'n", i, argv);
}
puts ("All done!");
return 0;
}
Assuming it works and you compiled it as testprog, try running it in a shell as follows
testprog bollocks whatever
Hopefully you'd get something like
Here's what was passed to main()
Argument 0 was 'testprog'
Argument 1 was 'bollocks'
Argument 2 was 'whatever'
All done!
as your output.
Well, at any rate, which C. People say C, C++, then there's ANSI C (and maybe ANSI C++). Is ANSI the name of a company, like Storm is?
I've always considered taking a chance at using it.
Well, ANSI is a standard (Amierican National Standards Institute). Pretty much all modern C compilers conform to this standard so don't worry. It defines a few ground rules that make sure a simple program (such as the one I did earlier) should work everywhere.
C++ is a little more of a mixed bag when it comes to standardisation.
Hope this was useful ;-)
-
AmosPRO Compiler is the best tool to easily learn programming.
WHY ?... :-o
1) A nice & interactive Editor ! You just type, for example "print", you put your cursor under this command and press 'F1'. Immediately, you get an explanation and - very often - a small tutorial.
2) You will quickly check the whole possibilities of programming (sprites, graphics, ...)
3) A lot of tutorials on the Aminet
But... You must work on a Pal Screen :-(
Eniodis
-
DaveP wrote:
It defines the entrypoint to your program. void means
no arguments are supplied. The real signature is
int main( int argc, char*argv[] )
where argc is the argument count and argv is an
array of the strings passed to the program on invocation.
No. The signature for main passes in the parameters
argc and argv into your program. In AMOS would you
define a procedure having an variable called 3? In fact
can you even do procedures properly in AMOS yet or
do you have to resort to GLOBAL ?
It would accept up to 3 words or numbers, in addition to the name of the cammand, from the shell prompt? Or from being called from another program.
It can be called from another program sure enough, but what it
does is tell you in argc how many arguments have been provided
and argv is an array of the strings that have been provided. You
cannot limit what people type into a console. So your program if
you wanted to restrict to just 3 args would say:
int main( int argc, char * argv[] )
{
if ( argc > 3 )
{
return -1;
}
char*argv
This looks like you are multiplying the terms.
Or, are variable names supposed to be placed between the square brackets? I don't get it.
In this context, given it is a procedure/function declaration
its a pointer reference. So argv is a pointer to a character array.
Havent got time to answer the rest just yet.
-
Eniodis wrote:
...
But... You must work on a Pal Screen :-(
Eniodis
...and nothing you ever write will work the moment you shove an accelerator, extra memory, hard disk, change your workbench pattern prefs (joke) etc.
Seriously though, if you want to go along a BASIC route, there are much better implementations available than any incarnation of AMOS I ever saw.
True the editor may be user friendly but there are plenty of source editors available that are just as, if not more powerful.
Ok, I promise not to keep flaming AMOS ;-)
-
Karlos wrote:
...and nothing you ever write will work the moment you shove an accelerator, extra memory, hard disk,
I don't know what you mean by the extra memory. Amos worked when I only had chip ram, and it worked when I got both. I don't have the compiler thogh, but am getting it soon. I know it's free, but I found a store that had it on the original disks, and am waiting to see if it's still available. (Professional Comp)
Are you saying that when Amos Professional, compiles a program, it won't work on what 020, 030...?
If Francois Lionet created a new "library", could it compile to the G4's?
Amiga! Aminet 2.0(4.0) is coming!
-
@ Karlos
1) I find it surprising that the first string is the name of the program itself. Was that correct?
2) I don't get this stuff; I see
For____without a___next
Return___without a____gosub
Return 0____0 what?
You see, it's too cryptic, I didnt' know "argc" was a name for a number, and that I could have put in its place "word_number". I did realize it meant integer though.
3)i++____increment by 1
i++2_____increment by 2?
4) So, is there an ANSI C++?
-
Karlos wrote:
puts ("All done!");
Why were you using
Printf("text")
Then
Puts("Text")
???
argv[]____could I have used____word[]
-
Atheist wrote:
I don't know what you mean by the extra memory. Amos worked when I only had chip ram, and it worked when I got both. I don't have the compiler thogh, but am getting it soon. I know it's free, but I found a store that had it on the original disks, and am waiting to see if it's still available. (Professional Comp)
Are you saying that when Amos Professional, compiles a program, it won't work on what 020, 030...?
Basically, my experience of AMOS has not been a good one. Any Amos program I've ran, be it old custom-chip hacky game style or intuition friendly has fell over at the slightest provocation.
This has been the case on at least three accelerated systems I used (030, 040 and 040/PPC). And yes, one program that used to work in 16Mb 70ns ram crashed continually with 64Mb 60ns ram. Maybe the speed was too much for it, but I don't know. When the machine just restarts on you, you don't get much debug info ;-)
-edit-
Anyhow, me old mate, back to C (neary forgot to answer your other questions)
First off, the first string argument passed to the C main() function is indeed the program name. You didn't misread that.
As for argv, you could indeed have changed the name to 'word' or whatever you wish, just as long as you use the same name in the code, eg
int main(int numberOfArguments, char* argumentString[])
{
/* use numberOfArguments and argumentString
somewhere in here*/
}
would be perfectly OK. It's just that 'argn' and 'argv' are kinda conventional.
As for output, I did use puts() and printf(). There is a reason for this.
Basically puts() is your no-frills console output command that writes a string, complete with a newline ('\n') character on the end. Thats all it can do.
The other function, printf() is a complex beastie that can print formatted strings (hence the 'f' in printf).
Going into the detail of formatted output would take ages. But, just to give an idea:
The string we pass to printf() can embed special codes, prefixed with a percent sign. When the printf() function finds one of these, it substitutes it with the corresponding argument. For example
printf("An integer : %i\nA float : %f\n", 10, 5.5);
should produce the following
An integer : 10
A float : 5.5
as output. There are options that pad, justify, enforce sign, notation conventions etc.
As a final point, printf() doesn't stick a newline on the end of a string by default like puts() does, so you'll see I had to stick the '\n' character in the string myself.
-
Hi again,
Atheist wrote:
@ Karlos
1) I find it surprising that the first string is the name of the program itself. Was that correct?
2) I don't get this stuff; I see
For____without a___next
Return___without a____gosub
Return 0____0 what?
You see, it's too cryptic, I didnt' know "argc" was a name for a number, and that I could have put in its place "word_number". I did realize it meant integer though.
3)i++____increment by 1
i++2_____increment by 2?
4) So, is there an ANSI C++?
1) Yep its true - I think I detailed that in the last post. The name of the executable you ran in the shell is passed as the first string. This implies that there is always at least one string passed to main, so the value of 'argc' should always be at least 1.
2) For/Next
In C/C++/Java, your basic For/Next loop construct has the following syntax
for (; ; )
{
}
sets up the inital values etc in the loop. We can initalise counters and stuff here.
is the criteria that must be true to continue looping.
is an event to do in each loop (usually increase your counter etc).
is the code to execute in each loop.
There is no 'Next', basically everything between '{' and '}' is inside the loop.
Return without a gosub / return 0 what?
Fair point. What you have to think in C is that code exists only inside of functions. So our main program is inside of a function main(), as you saw already. That function is ultimately called by the operating system when you run the program. The return you see goes back to whatever ran the program.
We used 'return 0' because our definition of main() stated that it returns an integer number :
int main(int argn, char* argv[])
{
return 0;
}
Zero is just a nice safe number to return from main. You could return any integer number you wanted. The meaning of the value is operating system dependent. If you returned the value 5, for example, AmigaDOS would regard that a warning.
3) i++ etc..
Welcome to the world of laziness that is C. C was designed to compile into efficient machine code. It so happens that many CPUs can quickly increment and decrement variables and the above operator syntax reflects this ability.
C/C++/Java have a wealth of operate-assign operations. Basically, any dyadic (takes two arguments) arithmetic/logic operation can be written in an operate-assign shorthand for operations like i = i x;
So, to elaborate
i = i + 2 becomes i += 2
i = i * 3 becomes i *= 3
i = i / x becomes i /= x
i = i & 15 becomes i &= 15
etc.
Which you prefer is up to you. Modern compilers almost always optimise the former syntax to the latter during compilation if it can give faster code.
When you see i++, i--, this is a special case syntax for increment/decrement by 1. I should point out that prefix and postfix versions exist:
i++, ++i
i--, --i
What's the difference? The prefix versions (++i) change the value of i first and the new value becomes the result of the whole expression. The postfix versions (i--) do the same job, but the previous value of i is the result of the whole expression
Well an example is best
a)
int i = 5
int j;
j = ++i;
Here, i == 6 and j == 6
b)
int i = 5;
int j;
j = i++;
Here, i == 6 and j == 5;
c)
int i = 5;
int j;
j = --i;
Here, i == 4 and j == 4
You get the idea.
4) ANSI C++
Yes, indeed there is. Unfortunately, C++ is a rather more complex beast and has many features C does not. An inevitable upshot of this is that the defined ANSI C++ standard is not uniformly supported everywhere. If you do get into this, things to watch out for when developing code are
1) STL implementation
2) namespaces
3) templates
4) abstract base references
-
@ Karlos
Well, this is interesting. I understood all the things you said. I've yet to see a book that actually spells it out like that. It seems to me it was deliberately made that way to keep people away from programming.
Like, they could have structured it
For x=1 to 6 step 1
Print X
Next x
instead, and the compiler would just work it out. I can read the above code.
The answer to 1 is really neat, it means you could check to see if someone renamed your program. Sometimes you need to know everthing.
Thanks for the output. Obviously I'm not going to learn C on a message board, but one last important thing.
1) Have every type of C (C, C++, ANSI C and ANSI C ++) been made for Amiga?
2) No RKM's (books) are available for 4.0. Now no custom chips exist. So, the libs: directory will be completely rebuilt for the G4. Do you need 2 different compilers, one for G3, and 1 for G4?
3) I suppose I would need to buy an SDK to get that library information, before I could program in (any) C?
4) Does one need RKMs to program in ADos 1.3, 2.04 etc.? Can you make 1 program, that will take advantage of a CPU, whether it's just a 68000, or a 68030 etc.? Or are separate versions always needed?
We REALLY need to stay with 1 CPU.
For instance, now a C is needed to access the altivec component of CPU's.
Amiga!
-
Hi again,
Atheist wrote:
@ Karlos
Well, this is interesting. I understood all the things you said. I've yet to see a book that actually spells it out like that. It seems to me it was deliberately made that way to keep people away from programming.
I'm glad you found it useful. C isn't the nicest language for beginners. The syntax looks weird at first but it really is worth the time to get to know it. It's a structured language and you eventually come to understand and even appreciate the layout. Then BASIC ends up looking weird ;-)
Like, they could have structured it
For x=1 to 6 step 1
Print X
Next x
instead, and the compiler would just work it out. I can read the above code.
Well, after a bit, you come to realise that the C style looping mechanisms are unsurpassed in flexibility.
The basic 'use a counter' style looping is just the start. You can create much fancier loops that can iterate through lists of objects without needing a coutner or even knowing the number of objects.
But, that's something for a much later tutorial ;-)
The answer to 1 is really neat, it means you could check to see if someone renamed your program. Sometimes you need to know everthing.
I suppose you could. Here's an example that might work
/* get io functions */
#include
/* get string functions */
#include
/* a global string that holds the program name */
char realName[] = "atheistsprog";
int main(int argn, char* argv[])
{
/*
* the stricmp() function compares two strings
* (case insensitive) and returns 0 if they are
* equivalent.
*/
if (stricmp(realName, argv[0])!=0)
{
puts("You changed the program name!\nRename it back");
return 5; /* 5 is an AmigaDOS warning */
}
puts("OK");
return 0; /* okey dokey */
}
Thanks for the output. Obviously I'm not going to learn C on a message board, but one last important thing.
1) Have every type of C (C, C++, ANSI C and ANSI C ++) been made for Amiga?
Pretty much. If you just want to learn (ANSI) C for starters, get hold of the amiga developer cd v2.1. It comes bundled with StormC v3. Its even good to get the basic fundamentals of C++ too, but one thing at a time.
I know I gripe endlessly about StormC's C++ support being crap, but for an easy working environment its lovely. Just what you don't want to be doing is diving straight into CLI based compilers and makescripts etc. StormC's interface hides all that away nicely.
Once youre exprerienced with the language(s) and want the full works, go GCC.
2) No RKM's (books) are available for 4.0. Now no custom chips exist. So, the libs: directory will be completely rebuilt for the G4. Do you need 2 different compilers, one for G3, and 1 for G4?
Don't worry on that front. The G3 and G4 are code compatible. G3 code will run on G4, your only difference is that Altivec stuff will only run on G4 (and above?). Anhow, you can expect that your PPC compiler will support multiple target architectures.
The language itself doesn't change, thats the beauty.
3) I suppose I would need to buy an SDK to get that library information, before I could program in (any) C?
No. If you just want to write simple, portable programs to learn the language, you dont need the full OS related stuff.
Any ANSI C compiler and some tutorials will suffice.
4) Does one need RKMs to program in ADos 1.3, 2.04 etc.? Can you make 1 program, that will take advantage of a CPU, whether it's just a 68000, or a 68030 etc.? Or are separate versions always needed?
The RKMs are very handy when you need to write Amiga specific stuff. They detail how the OS works internally and gives you all the required info to take advantage of stuff like gfx/sound/threads etc.
The developer cd comes with those too ;-)
As for code generation, if you need to optimise a program as well as possible then you will need to target a given CPU. Sad fact of life. Unless you have used some assembly code in your project, you won't have to change any code though ;-)
With experience, you can write several versions of your critical functions (usually in assembly) and detect which CPU is used at runtime, then use that information to call the 'optimised' code.
We REALLY need to stay with 1 CPU.
For instance, now a C is needed to access the altivec component of CPU's.
Amiga!
Well, that's what compilers and libraries are for. The language itself doesn't need to change to take advantage of these developments. That's one of the real beauties of the language and one reason why it's stayed around for so long!
For example, suppose a code did something like
a = b*c+d;
where a, b, c and d are floats. Compiled for 680x0, we'd expect a 'fmul', 'fadd'and a few 'fmove' instructions.
On a PPC 60x, a good compiler would recognise the construct and use the single multiply-add instruction that the PPC supports.
With Altivec, a good compiler will be able to optimise code that operates on arrays of data etc. to make use of the altivec unit.
Tune in next week for the next thrilling installment!
:-)
-
@FuZion
As DaveP has said, it would be a good idea to start learning ARexx. And I say ARexx and no other scripting language because in Amiga almost every serious program as an ARexx port, so it's quite interesting to automatize tasks.
Once you have some control over ARexx I would try to learn C. No C++ but C. It integrates better with AmigaOS and to learn C++ it's better to know C.
If you find that you need more speed and control try some asm. I don't advise you to go directly to asm because it will be even more frustrating that C, you will probably crash your computer a lot more.
I wouldn't use Pascal (although I used it for some practices) because C is faster, has better support and integrates better with AmigaOS
Keep away of any Basic, it integrates bad with AmigaOS and usually makes the programmer used to bad habits (like GOTOs).
For me Java is not an option because in Amiga there's no Java (ok, it's so slow that it's nearly unusable and the versions that use graphics are alphas). Just look at the number of Amiga apps/games written in Java. None. Ok, if you aren't interested in coding for fun on your Amiga and want to make some money Java may be interesting.
@Atheist:
the right ANSI C (that is the official C standard) hello world would be:
#include
int main(void)
{
printf("Hello ANSI C world!\n");
return(0);
}
you write that main returns an int, because ideally you should always indicate to the OS how your program has finished (if an error has ocurred etc...).
You put the stdio because you are going to use the printf() function. You may select not to use that function at all. If you have 2 million of functions would you want your compiler to check everything for you? That would be damn slow (basic comes to my mind).
You use ";" because you can do long complex sentences that take up various lines.
And no... loops don't require includes, you can use "while"s, "for"s "if"s etc... without adding a single include. In fact you may do everything without using includes at all, just using pointers, but that would be pointless.
printf uses () because it's a function. It logical, everything you use are functions.
Why you use " in basic instead of for example º ???
its just a convention and that is what you do in C.
Why basic doesn't recognize that I want to show a line if I only write "Hello" instead of writting print"hello" that's illogical from your point of view.
That are language standards.
C is logical, well structured and used to learn structured programming, in contrast Basic is not so structured by definition, is slow and doesn't integrate so well with AmigaOS.
The only other language that integrates so well with AmigaOS is Assembler.
Every Basic sucks. If you don't want to learn C, at least learn Pascal, learning Pascal you may learn how to program correctly, with AMOS I'm sure you won't. Amos is quite incompatible with the OS, doesn't allow you to use third party libraries in a comfortable way (just try to use Warp3D from AMOS for example)... and yes, I used Basic when I didn't have a clue about programming, with c64, cpc and msx, but I wouldn't recommend it.
ARexx, C or ASM, that are the options for me in AMiga. And C++ to create some things, but I wouldn't suggest using Basic at all.
Simple fact: big apps/games aren't done in AMOS, they are done using C/C++ or even ASM, but these apps/games never are done using any Basic reincarnation.
Definitely... learn C before complaining so much about it. You can use C without pointers but one of the most powerful possibilities of C is using pointers.
And other advantage of C you only have to learn very few things to learn C. The rest are extensions that work following the standards. I recommend the Kerningan&Ritchie C book.
I think that argc stands from argument count...
but that is well explained in the K&R book. If you want to use graphic functions just load an autodoc viewer and do Amiga-M, you will have a list of functions with its input and output.
Just read a book about C, then you will be ready to code in C. Don't expect to use it even at 10% without any documentation... Use the sidewinder tutorial to set up a C environment and then start to read a book and do type some examples...
You won't do impressive stuff the first day, but once you have some experience you will be able to do things impossible to do in C. I would say the same if you started with ASM, without experience you won't do impressive stuff.
for me the following loop is not flexible:
for i=1 to 10 step 1
whatever
next i
why can't I for example multiply the variable each time? or why can't the for() increase 2 variables? and three? and four? Why do I have to write next if I have indicated in the for that I'm going to increase C?
wouldn't be easier to put
for i=1 to 10 step 1
{
whatever
}
why do I have to write "to"? it's obious that the goal is the 10 so why write that "to"
and why can't I use multiplication or divisions or simply do various things each time?
for i=1 10 i=i+1
let's order it a bit...
for i=1;10;i=i+1
and why it has to be that number? why can't I put other conditions, why I don't use the condition as a while condition to make it more flexible?
for i=1,j=2; i<11;i=i+1,j=j-1
why should I type i=i+1 to increment my variable? Wouldn't be faster to write that I want to increment the variable? isn't faster to write variablename and ++ or --?
for i=1,j=2;i<11;i++,j--
isn't it logical and flexible?
and to make it look cleaner and define better where the for ends why not put ()?:
for(i=1,j=2;i<11;i++,j--)
what do we have? oh yes a C "for" loop.
Firstly you put what you want to do the first time you enter the "for", then you type the condition of being inside the loop and at the end you put what it has to do each time. Quite logical in my opinion. With Basic if your code was big and you had two nested "for"s you would have to check that you have put next i and next j in the right positions (whyyy???) with c you don't have to worry about it and you simply put two "}"
Just learn C before complaining so much about it and saying that it's designed to keep people away of programming. Programmers read books, you know... if you want something scary try to learn ASM. Even better, try some 8086 asm instead of 68000... you will see something really scary then ;D
-
This is looking more daunting as the thread grows :-o
-
FuZion wrote:
This is looking more daunting as the thread grows :-o
NO! C++ & C are good! they are quite easy
nobody should be 'studying' basic because they are afraid C might be a bit too hard for them
C is a powerefull, professonal, high-performance, structured language - it is serious
but its also easy to use - it is IT IS!
you just need practice & patience & time
forget about basic - throw it away! that crap only tought me bad habbits - which, for a while caused me to program in C badly - i gained little out of basic programming, well, nothing that i would of done better in c (?)
grab a good book on C, set up your c compiler, and start practicing