Welcome, Guest. Please login or register.

Author Topic: Learning C with the Amiga  (Read 32325 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Louis Dias

Re: Learning C with the Amiga
« on: January 25, 2007, 03:13:19 PM »
I downloaded GCC and the C++ version as well back in '95.  I didn't have the luxury of nice IDE's like there exists now, but I managed.

GCC is free and really good for compatibility as someone has already mentioned.

Just find in nice IDE to do your code editing and a good book like "C for Dummies".

C isn't hard or confusing until you get into compiler directives and #include, #if... stuff as your projects grow in size and complexity...

I'm curious, what other languages do you know?

EDIT:
You don't need a developer CD to do basic C programs that will run in a CLI/shell window.  Just get gcc and a text editor and that's all you need.  Tutorials are all over the internet on the basics of C programming.
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #1 on: January 25, 2007, 06:00:39 PM »
I think you guys are asking her to walk before she has learned to crawl.

GCC is not "slow" for learning C.  She will not be waiting for 20 minutes to compile:

#include stdio.h
void main() {
printf("Hello world.");
}

Nor will it take long to compile examples using basic structures like linked-lists.

She doesn't need to know how to program OS apps before she even learns the language.

GCC and a simple text editor is all she needs and both are free.
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #2 on: February 03, 2007, 01:22:11 AM »
Quote

CannonFodder wrote:
Quote

mel_zoom wrote:
Hi!

Wow so many ways to start a program in C! I think Ill stick with the basic "int main(int argc, char** argv)" one for now.


Basic?  Shh, you´ll wake the VB dragon. ;-)

int main(void) {} is the basic way anyhow. :-)


The dragon has awaken.
However, it is a wise old dragon and know when trolls are trying to feed it poison and decides to go back to sleep.

Anyway, this method works just as well:

#include
#include
#include
void main()
{
char *Result;
int CannonFodder, funny;

funny = 1;
CannonFodder = 0;
Result = "";

if (CannonFodder != funny) Result = "not";
printf("Cannon Fodder is %s funny.\n",Result);
printf("Cannon Fodder is a %d\n",CannonFodder);
}


See what you get...
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #3 on: February 03, 2007, 07:03:55 PM »
LOL @ all
:pint:

The topic is learning C not C++, anyway I wrote it from scratch and not on a compiler.

As I've mentioned before, I know enough C/C++ but don't use it at all at work and haven't tried in 10-12 years.

Ofcourse these "complaints" are my whole problem with the language as well as all the different standards.

It seems beginners fight more with the language than the actual art of programming.  Who does that help?  I understand it's place for core stuff like kernels and drivers, but for robust user applications, with today's processing power, I don't feel it's ideal.

Mel, may I recommend Hollywood 2.x to you.  It's one way to do Amiga programming and have it work on OS3, OS4 and AROS.  It's really an over-looked product.  It's as close to a ".Net" programming paradigm as you'll find in Amiga-land.
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #4 on: February 03, 2007, 08:09:02 PM »
Quote

mel_zoom wrote:
lou_dias:

I never quit once I set my mind on something. I dont think the language looks that bad just yet!

This one worked fine....

#include

int main(void)
{
  const char *result;
  ...
  result = "was funny";
  ...
  result = "backfired";
  ...
}



ah yes, another thing about C syntax that makes no sense

"oh but the address stays the same" ... oh but it still leads to confusion because a variable declared as a constant should remain a constant, otherwise, why call it a constant?

const char result[] = "C is not fun";
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #5 on: February 03, 2007, 08:32:42 PM »
Mel,

Why should there be 4 possibilites?

To me, constants are constants because their values don't change.  Like pi.

Now to say you will constantly point at 1 address and what's really important is the information at that address and then tell me that information can change, what's the point of a constant pointer?  Just use a variable.  When the compiler does it's job in converting to machine language, I don't think it sees the difference between a constant pointer and the pointer it generates for a normally declared variable.  Infact, I would say there is more of a performance hit since declaring a typed variable in advance means it allocates the space right away rather than when the code is running.
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #6 on: February 07, 2007, 09:15:43 PM »
Mel,

Even if a structure contains an array, the value within the structure representing the array is a pointer.

ps,
you answered your own questions in asking them for the most part

but remember, I don't know anything so don't believe anything I tell you
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #7 on: February 07, 2007, 10:40:32 PM »
Hans_ wrote:
Quote

It's a quirk of the language.


It's these quirks that make it not a good language for beginners.  Maybe if she ever learns a second language (C++ doesn't count), then she'll see the light at the end of the tunnel.  C is a language with few rules.  How do you write structured code when the language has no uniform structure within it's design.  C is a language designed for low-memory machines because that's all they had when it was designed.  All these "quirks" are just hacks someone added to the compiler at the time because of memory constraints and over time "became part of the language".  C is a hack to not have to write assembly.

Quote
BTW, I think that lou_dias is wrong about arrays in structures. A fixed-length array in a structure is the data itself, not a pointer to the array. Ah, I see that Karlos has already commented on that as I was writing this.

Hans

So if the "rule" is arrays are passed by reference...why wouldn't an array within a structure not be a reference as well?  Oh, I forgot, we are talking about C...but anyway, Karlos and YOU assumed I was responding to her "code" when I was actually responding to her prior set of several questions.  I guess I should have quoted her.  C`est la vie.  (and no, that doesn't say "C is the life")
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #8 on: February 07, 2007, 11:13:18 PM »
@AJCopland
Quote
By structure I mean that you'll make a conscious decision to implement things in a particular way and in a methodical manor as opposed to other languages where you implement things in a certain way... because it's the only way that the language will let you.


But other languages have 1 clear way of doing every certain thing.  As long as these other languages give you all the functionality you need, why not use them with the saftey on rather than C/C++ with is playing with loaded guns and the safety(s) off.

Here we have a new student to programming and you give her the loaded gun right away.  That can/will lead to frustration.  Bad descision.  What is her "need" to learn C?  Certainly, other languages could speed up her "learning to program" process.  Learning these other languages could then speed up her subsequent "Learning To Program In C" process.
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #9 on: February 08, 2007, 12:06:00 PM »
Quote

Karlos wrote:
Quote

CannonFodder wrote:

C++ is the Shia to Islam´s C? ;-)


/me runs very very fast!!


No. C++ was the final revelation that perfected the language. C itself is more like your Torah/Gospel :-P

/surreal


That's funny, I learned JAVA for a class and I would say that JAVA is the final revelation that perfected C++.

@koaftdr
JAVA offers data serialization built-in.

PS,
We are way off topic for Mel.
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #10 on: February 09, 2007, 12:21:39 PM »
Code: [Select]
Structure Point
   Dim X as Double
   Dim Y as Double
   Dim Z as Double
   Dim Name as String
End Structure

Sub Main()
   Dim Position as Point
   Dim Speed as Double = 1.0

   Position = SetInitialPosition("Orbit 1")

   For Angle as Integer = 0 to 359  'Default stepping is 1
      Position = Plot(Position, Speed, Angle)
      DrawIt(Position)
   Next Angle
End Sub

Function SetInitialPosition(ByVal Name as String) as Point
   Dim Vector as New Point

   Vector.X = 1
   Vector.Y = 0
   Vector.Z = 0
   Vector.Name = Name

   Return Vector  'here you can alternately do this:  SetIntitialPostion = Vector
End Function

Function Plot([b]ByVal[/b] aPoint as Point, ByVal Velocity as Double, ByVal Theta as Integer) as Point
...
End Function


The PLOT function above, the structure is passed by value as well.  However, I could have written it to pass by reference like this:

Function Plot(ByRef aPoint as Point, ByVal Velocity as Double, ByVal Theta as Integer) as Point
...
End Function

This example isn't good because it alludes to designing a "game" where global variables are favored over proper programming design for the sake of speed.

Oops, wrong language!  :flame:
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #11 on: February 09, 2007, 01:19:56 PM »
Quote

koaftder wrote:
Why post vb.net stuff in a thread about C? If you want to go over some vb.net stuff, why not do it in a vb.net thread? I'm game. I could use some vb.net review as I have yet to actually move over to that environment ( and there are lots of us out there ).


If you need to know anything about vb, feel free to PM me.

Well, mostly, people here talk about how C is powerful and clear(cough) and blah blah blah, self-documenting(cough cough), blah blah, well I posted some VB code for comparison.  Let's leave it at that.  
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #12 on: February 09, 2007, 01:23:54 PM »
falemagn wrote:
Quote

Self-descriptive code makes code beautiful.


I agree.  I know you weren't addressing me, but VB code is VERY self-descriptive.  C, not so much.  Please reference my code.  No flames intended.
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #13 on: February 09, 2007, 07:56:38 PM »
In that case, the USA is not a 1st world country.
Healthcare costs are quite a political debate around here. :(
 

Offline Louis Dias

Re: Learning C with the Amiga
« Reply #14 on: February 09, 2007, 09:21:42 PM »
OT:
I am Portugues born, American raised.
I see this country with clear eyes.  It has many problems that foreigners don't see and I'm not a blind loyalist like many seem to be.

The problem with this government is that politicians also have business interests.  There should be a law separating the 2.  That is the root of many woes.  Everybody is in it for money and not for what is right.