Early beginner learning arrays and for and while loops ...

S

scott

C is the wrong language to be learning these basic concepts with.  Use
one of Java, C#, Perl, Python, Ruby or Lua.  Any of those will provide
a safer and easier-to-debug environment than C.  Once you are up to
speed with a high-level language, than you can start to use C (if you
have to).  Overall the learning curve will be shorter and shallower.
  -Andrew.

This seems to be the prevailing wisdom these days and is the way that
most of the CS programs in US schools are going. I disagree though.
IMHO the way you really learn something is by screwing it up and
figuring out what you did wrong, C is the perfect language for this as
it will happily let you shoot yourself in the foot. It can be
frustrating for the beginner but in the long run I think you are
better off.
 
N

Nobody

This seems to be the prevailing wisdom these days and is the way that
most of the CS programs in US schools are going. I disagree though.
IMHO the way you really learn something is by screwing it up and
figuring out what you did wrong, C is the perfect language for this as
it will happily let you shoot yourself in the foot. It can be
frustrating for the beginner but in the long run I think you are
better off.

If your eventual aim is to program in C, learning a highly dynamic
language such as Python probably isn't a good way to start.

You would probably be better off starting with one of Pascal, Java or
Basic. These are all quite similar to C, but make it harder to shoot
yourself in the foot. E.g. many common mistakes will result in errors in
those languages, whereas in C they would simply result in confusing
behaviour. The most obvious example is out-of-bounds array access. In C,
this results in reading or writing some arbitrary memory location, whereas
most languages will detect it and report an error.

Pascal is the most similar to C; it has most of the same features, except
for the dangerous ones. Java is an object-oriented (OO) language, while C
isn't. You don't necessarily have to use the OO features a lot, but you'll
have to learn them to some extent. The main problem with BASIC is that
there are hundreds of different dialects, and most of them are missing
useful features.
 
A

Andrew Tomazos

perl!? To learn programming?

Python, Ruby or Lua.  Any of those will provide


I'd never thought the debugging environments of perl or python
were particularly brilliant.


you could learn some really bad habbits with perl

I can tell by the fact that you spelled Perl with incorrect
capitalization three times that you have not read even introductory
information about the language. Please refrain from offering opinions
about matters that you know little or nothing about - *especially*
when comparing one language versus another. All of the six languages
I listed offer full reflection, and are inherently easier to debug
than C, regardless of the particular debugging environment you use.
If you have trouble debugging small programs written in dynamic
languages than it is your method that is at fault. Further, I am not
sure what the bad habits that you think Perl encourages are, please
list them.
-Andrew.
 
S

scott

If your eventual aim is to program in C, learning a highly dynamic
language such as Python probably isn't a good way to start.

You would probably be better off starting with one of Pascal, Java or
Basic. These are all quite similar to C, but make it harder to shoot
yourself in the foot. E.g. many common mistakes will result in errors in
those languages, whereas in C they would simply result in confusing
behaviour. The most obvious example is out-of-bounds array access. In C,
this results in reading or writing some arbitrary memory location, whereas
most languages will detect it and report an error.

I agree that this is something that can be caught and reported as an
error in many languages but I think the fact that it results in
"confusing" behavior in C is a good thing. This forces the student to
then do some debugging, a skill that will serve them well later when
something more complex is wrong. The student is more likely to
remember their error if they actually have to find it but more
importantly they actually need to learn some debugging techniques and
or tools.
 
B

bpascal123

Hi,

I'm starting with learning functions.

Any good internet site that has a mix of theory, examples and
practise?

I think i found one in google but i can't get my hand on it. Maybe i
don't have the right keywords...but i should have bookmarked it then.

Pascal
 
M

Moi

Hi,

I'm starting with learning functions.

Any good internet site that has a mix of theory, examples and practise?

I think i found one in google but i can't get my hand on it. Maybe i
don't have the right keywords...but i should have bookmarked it then.

Pascal

Ok, There you go: (not perfect, but it works)


void merge( int result[], int arr1[], int cnt1, int arr2[], int cnt2)
{
int idx0,idx1,idx2;

for (idx0=idx1=idx2=0; idx1 < cnt1 && idx2 < cnt2; ) {
if (arr1[idx1] <= arr2[idx2] ) result[idx0++] = arr1[idx1++] ;
else result[idx0++] = arr1[idx2++] ;
}
while (idx1 < cnt1) result[idx0++] = arr1[idx1++] ;
while (idx2 < cnt2) result[idx0++] = arr1[idx2++] ;

return;
}

HTH,
AvK
 
B

bpascal123

Hi AvK,
Ok, There you go: (not perfect, but it works)

void merge( int result[], int arr1[], int cnt1, int arr2[], int cnt2)


I'm totally in a daze. I'm starting to learn functions and this code
seems just perfect.
I need to understand the basics first but i'll learn this one by heart
so i can implement it on other arrays when i get further in learning
functions.

Thanks a lot AvK,



Pascal
 
M

Moi

Hi AvK,
Ok, There you go: (not perfect, but it works)

void merge( int result[], int arr1[], int cnt1, int arr2[], int cnt2)


I'm totally in a daze. I'm starting to learn functions and this code
seems just perfect.
I need to understand the basics first but i'll learn this one by heart
so i can implement it on other arrays when i get further in learning
functions.

Thanks a lot AvK,

You're welcome.

Now first: rewrite your original program to use thsi (or a similar)
function instead of the "everything in main" approach.
You will probably see that the code gets clearer.
Repost your code here, SVP.


HTH,
AvK
 
R

Richard Bos

Andrew Tomazos said:
I can tell by the fact that you spelled Perl with incorrect
capitalization three times that you have not read even introductory
information about the language.

I can tell by the fact that you don't know that Nick's capitalisation is
_always_ inconsistent and broken that you have not read even three days'
worth of comp.lang.c.
Further, I am not sure what the bad habits that you think Perl encourages
are, please list them.

For starters, it encourages 99.9% of all Perl code I've ever seen.
There's an IOCCC, in which the best, most creative C coders try their
very hardest to create the most confusing, ambiguous code they can come
up with; there is no IOPCC, because if there were, there would be an
all-way tie for first place.

Richard
 
K

Keith Thompson

For starters, it encourages 99.9% of all Perl code I've ever seen.
There's an IOCCC, in which the best, most creative C coders try their
very hardest to create the most confusing, ambiguous code they can come
up with; there is no IOPCC, because if there were, there would be an
all-way tie for first place.

Ah, proof by blatant assertion.

Perhaps you could take this somewhere else?
 
A

Antoninus Twink

Here's my attempt at an ASCII art representation (fixed pitch font
required):

_______________ ________________ ____________
| 1, 2 | | 3 | | 4
tum-ti- | tum-ti- | tum-ti-| tum :| tum-tum-| tum :| tum-ti-|tara

WTF?

As usual, the regulars exempt themselves from their own "topicality"
rules.
 
A

Andrew Tomazos

For starters, it encourages 99.9% of all Perl code I've ever seen.

This says nothing. I could say C encourages 99.9% of all C code I've
ever seen. Meaningless crap.
There's an IOCCC, in which the best, most creative C coders try their
very hardest to create the most confusing, ambiguous code they can come
up with; there is no IOPCC, because if there were, there would be an
all-way tie for first place.

You don't have a clue what you are talking about. If you knew
anything about Perl you would know that it had an obfuscation contest:

http://en.wikipedia.org/wiki/Obfuscated_Perl_Contest

Please refrain from sharing your uninformed opinions. The Internet is
full up.
-Andrew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top