On Tue Nov 22, 2005 at 17:43:49 +1100, O Plameras wrote:
>Benno wrote:
>
>>On Tue Nov 22, 2005 at 16:52:06 +1100, O Plameras wrote:
>> 
>>>
>>
>>C is a very difficult programming language to program in and get right.
>>(As seen in this thread). Programming errors in C are likely to lead
>>to buggy unstable, insecure software. Therefore if you program in C you 
>>should try and get as much help from tools to ensure that what you have
>>programmed is correct. Some of those tools are:
>>
>> 
>>
>
>I don't find C difficult at all. 

... but you still didn't know how strings work.

>C has one of the least number of 
>vocabularies to learn and master.

Yep that is true.

>If you understand pointers and pointer arithmetic you have the right 
>stuff. So, learn pointers
>and pointer arithmetic.

pointers and pointer arithmetic are very difficult concepts
for people to learn. They are important things to learn, but
most people find them difficult.

>C is extremely good because many OSes and Compilers are written in C 
>including Linux itself
>and many tools in Linux.

I would say C is good despite that ;). I never said C is bad, I said
it was difficult to program in well.

>Open Source is notoriously lacking in documentations. Unless you know C 
>you are lost and
>you hardly  can't proceed if you are doing a project.

That is simply untrue. There are many projects written purely in python,
perl,ocaml,haskell,java.

>So, my advise to newbies in Linux, forget about people that discourages 
>you from writing in
>C language. Use C and you will quickly realise the real beauty and 
>opportunities of Open Source.
>It gives you more freedom and independence.

Hey, I agree. Learn it, and then learn when to use it and when to use
a higher level language.

>The object of programming is to get what you want in a simple and easy 
>to understand programming.

Sure, that is why I prefer higher-level languages that provide more abstraction.

>That's why my preferred the solution is

<snip function that returns a pointer to a stack>
>
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>This is tremendously simpler than what you have proposed, as ff:

<snip my previous solution>

I wasn't attempting to have something simpler, I was try to
give him what I'm thinking he was trying to do, but I'm not a
mind reader. I assumed that there was some reason for the
given structuring. Hell if I wanted to give him the simplist
solution to print out a string it would have been:

#include <stdio.h>

int main(void)
{
        puts("Some string\n");
}


>I am discouraged by simply looking at these codes much more
>bother to read it.

Well, that is sad.

>The trouble other programmers have with C is that they make their
>codes complicated than it should. 

That is possible. With any language really knowing it means, knowing
the simplest and most clear way to achieve what you want.

>>1/ Using the compilers warning system.
>>2/ Using something like valgrind to test for memory errors.
>>3/ Use a static analysis tool like splint.
>>
>>(Apart from that C is a very unproductive language to program in, so 
>>unless you really need it then use something higher level -- please!)
>> 
>>
>
>I disagree with this. There are lots of things I can do with C that 
>cannot be done with
>other high level languages easily.

Sure, and that is why I said "unless you really need to". For example
lets say you have some data in a file. With the format:

Label: number

And you want the average of those numbers. Writing that in python
takes about 10 lines of code and about 1 minute, and you usually
get it right first time. Writing that in C with the standard library
is not so simple. And if that is too contrived think about large
complex open source problems like revision control and how most
of the latest ones are written in high level languages. Because
really, speed of the processor isn't an issue here, but good algorithms
are.

And I challenge anyone to write a doubly linked list right the first
time.

Anyway, you can write good stuff in C, but really, unless computation
speed is the issue you would do much better to write it in a higher level
language where you can spend time refining algorithms not worrying
about memory management.

(And really C sucks for device drivers and low level stuff too now I think about
it, its not as though C has a way to access x86 style ports, and its not
as though its structs are tightly defined enough so you can just use them
to describe device memory layouts, although people do and rely on how the
compiler works.)

Cheers,

Benno
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to