# Why is writing C so hard!



## Fusengammu (May 1, 2002)

Okay, I'm not a REAL programmer (I know java, js, you know, fluff languages), but I did read K&R's "C" book way back when.  my question is, why are actual UNIX C programs out there so hard to read and compile?  i guess it is because of the fact that they were written to compile on like a billion platforms, but it seems to me 50% of the syntax and grammar I see in the source code for these programs don't resemble any sort of C program I would ever write...

I don't plan on doing programming professionally, but I would like to be able to work or at least play with open source code.  Does anybody know where I can find some documentation on how to decipher real world C programs for UNIX?


----------



## AdmiralAK (May 1, 2002)

lol I resent you calling java a fluff language 
shame on you...you have incured the wrath of teh Admiral   

well quite simply C is a retard kind of language 
I HATE C


----------



## shrill (May 1, 2002)

Arrr! Admiral, now you've incurred the wrath of Junior Member Shrill!!   

C is the best language around: It runs on everything, it let's you do high level without a weirdo  scripting language OR low level programming without an assembler! More than that, from the ashes of C spawned C++, Java[script], Perl, etc. Most (all) modern languages are either direct descendents of C or use C's syntax rules.

That being said, I don't use C much anymore, it's too hard  I'd rather use perl. 

Back to the original question: you're right, Unix C programs can and do run on virtually every platform, are usually written by several people (speaking several languages) via CVS, and have astronomically complex makefiles and such. They aren't meant to be read by Mere Humans. I think you find your documentation for most of them by taking computer science courses at MIT. 


_I'll concede one point though: without C, there would be no C++; without C++, there would be no MFC; without MFC, Windows would still be Dosshell, and the Evil Empire would still be a Star Wars reference.  ~_


----------



## AdmiralAK (May 1, 2002)

ANSI C just sucks,
if you clain that C gave rise to other languages, then fine, assembler gave rise to B which gave birth to C, heck, lets go back to punchcards 

I hate memory manipulation in C, memory management, no automatic garbage collection, no automatic memory allocation, ANSI C is junk


----------



## Fusengammu (May 1, 2002)

--> If you are a real JAVA programmer, learning C or C++ is not much of a stretch. Pick up one of those "learn C in 10 minutes" books. <--

I WAS a Java programmer professionally for 2 yrs, and I worked inside a big project, so I think I'm pretty real as a Java programmer.  And the first language I learned to program in was C.  I mean Java is a fluff language because its so easy to use even a doofus like myself can use it.   

What I meant in the first post was, reading through UNIX source is often an indecipherable experience.  Since I don't have any source code in front of me, stuff of the top of my head:

*  I remember trying to compile something on my box, and I got a message like "unistd.h not found."  Okay, so I find it on my OS X box, and then include it in my include file search path.  Then it complains about how some function has duplicate definition, but the two defs have different return types.  ??  Question, how to learn about what to do then?

*  How does one decipher all those #ifdef stuff?  

*  I have no clue how variable visibility across separate source files work in C.  In Java, anything "public" is visible everywhere.  In C, theres all this static, extern, etc. etc.  VERY VERY confusing.



I hope to never program professionally again, but I still want to be able to program for fun, and maybe one day learn enough to contribute to open source.  But the more I read through UNIX source code, the more I have no clue wtf is going on???


-->  Back to the original question: you're right, Unix C programs can and do run on virtually every platform, are usually written by several people (speaking several languages) via CVS, and have astronomically complex makefiles and such. They aren't meant to be read by Mere Humans. I think you find your documentation for most of them by taking computer science courses at MIT.  <--

I guess that's what makes the world of UNIX so diverse, mysterious, contradictory and attractive to me.


----------



## shrill (May 1, 2002)

ANSI C sucks 




> "unistd.h not found." Okay, so I find it on my OS X box, and then include it in my include file search path. Then it complains about how some function has duplicate definition, but the two defs have different return types. ?? Question, how to learn about what to do then?



Usually you stomp your feet and sware a lot. Sometimes the header files from one framework get in the way of the header files from the other framework, and you get conflicting definitions. Sometimes you can fix this copying the definition that you think is right into your source file, and by not #including the second header file. Somebody probably has better advice on this one  



> * How does one decipher all those #ifdef stuff?



Most of the time, #ifdefs are used to separate out platform specific code. You mainly have to find out which #ifdef applies to your platform and ignore the rest. They are also often used as workarounds for difficiencies in compilers that are found on various platforms (you probably won't have to look too far to find "#ifdef __FILENAME__" in a .h file, which is a workaround for compilers that don't have something similar to a "#pragma once" directive).



> I have no clue how variable visibility across separate source files works in C. In Java, anything "public" is visible everywhere. In C, theres all this static, extern, etc. etc. VERY VERY confusing.



> File1.c
static thing thing1;  /* can only be referenced from within File1.c, because it's declared static */
extern thing thing2; /* this can be used in File1.c, but it's extern, which means it's declared elseware */
thing thing3;  /* this thing is declared here */

> File2.c
extern thing thing3; /* refers to File1.c's thing3; the reason this works is because thing3 is global, and there can be only one thing named thing3. */


----------



## Valrus (May 2, 2002)

Yeah shrill, perl's _real_ easy to read. 

I learned C++ in high school but I'm kinda rusty now. I took two computer science courses this year but neither had any real programming in it. So I'm stuck doing recreational projects in Python (not that I'm complaining; Python is _fantastic_) until I can rustle up the free time to work on my C.

-the valrus


----------



## nkuvu (May 2, 2002)

Any language can be obfuscated.  Even Python.  If you write code well, any language can be clear, also.


----------



## 96.9 (May 3, 2002)

I am learning C and assembly . I spend like 6 months on 6 months off .

I like taking a break from things , learning C in university is a few year course and I dont have all the time in the world but I am finishing off my basic studies of C and assembly completing a few solid years of computer studies .

To be able to write competant code you have to be creative in math to get anywhere . I am going to do some math studies this summer with algorithms and such . I want to work on my own code , which I think draws many people into computer science .


----------



## scruffy (May 3, 2002)

I wonder if there's not some sort of pissing contest among Unix programmers to see who can come up with the most terse, obfuscated way of doing things.

Sometimes you puzzle through someone's code, full of embedded ++'s and --'s, and you realize that it's nothing hard, and could be easily expressed by adding one local variable and three lines of code...


----------



## AdmiralAK (May 3, 2002)

lol code compactness seems to be the thing 
When someone programs in any language, a three-lined version might have a abigger "Big-oh" (time complexity) than one line of code (i.e. using a loop to calculate some number rather than figuring out some formula in order to keep time constant)

optimization of code sux at times


Admiral


----------



## gdanko (May 3, 2002)

> _Originally posted by testuser _
> *If you are a real JAVA programmer, learning C or C++ is not much of a stretch.  Pick up one of those "learn C in 10 minutes" books. *



I recommend "Learn C In 25 Seconds, For Dummies"


----------



## shrill (May 3, 2002)

It might be a pissing contest among unix programmers, but I'm not really a unix programmer, so I can't say. 

perl is my favorite for two reasons, both of which have to do with the way it looks: 

1. A page of perl code doing some good stuff looks like what I think a page of code should look like. Lots of symbols and punctuation arranged in some strange order. It reminds me of my bewilderment on seeing my first page of C code. I had no idea what all those semi-colons and curly braces where. It scared me. It looked confusing and *really* hard.

2. perl looks impressive to the casual over-the-shoulder passerby - programmer or mere human. Someone might come up behind you, about to ask "Hey, are you busy?" but the arcane perl symbols ~!@#$&%^$()//;\\ all over the page makes them think, "Wow, you are doing something *really* hard and *really* important, and what I had to say wasn't really that important, and boy I feel dumb looking at that stuff." Then they just leave. 


 - shrill -



@a=(Lbzjoftt,Inqbujfodf,
Hvcsjt); $b="Lbssz Wbmm"
;$b =~ y/b-z/a-z/ ; $c =
" Tif ". @a ." hsfbu wj"
."suvft pg b qsphsbnnfs"
. ":\n";$c =~y/b-y/a-z/;
print"\n\n$c ";for($i=0;
$i<@a; $i++) { $a[$i] =~
y/b-y/a-z/;if($a[$i]eq$a
[-1]){print"and $a[$i]."
;}else{ print"$a[$i], ";
}}print"\n\t\t--$b\n\n";


----------



## gdanko (May 3, 2002)

I agree. It is always good to have a screen full of perl code up on your computer at the office. It makes people avoid you.


----------



## blb (May 4, 2002)

> _Originally posted by scruffy _
> *I wonder if there's not some sort of pissing contest among Unix programmers to see who can come up with the most terse, obfuscated way of doing things.
> ... *


Yes there is (but not just Unix).


----------



## googolplex (May 4, 2002)

I just started doing Objective-C cocoa stuff and it is definately not really hard! I'm really loving it. Its just so damn cool and in many ways easy. I just finished doing some work on my first from-scratch cocoa app - a very very simple calculator. You can check it out if you want at http://homepage.mac.com/jeffhume/Calculator.app.sit


----------



## scruffy (May 5, 2002)

shrill - did you write that obscene perl code in your signoff, or is it one of these things that gets passed around?

What's with the .and .and .and .and .and .and .and .and .and .and .and


----------



## shrill (May 5, 2002)

Actually, it's perl code that comes from a T-shirt that some web site was selling. If you run the code, you get: 

 The 3 great virtues of a programmer:
 Laziness, Impatience, and Hubris.
                --Larry Wall


Take it as evidence of what nikuvu said: "Any language can be obfuscated"


(PS: i think the website was www.thinkgeek.com, but I don't see it there anymore)


----------



## 96.9 (May 5, 2002)

There are lots of unemployed coders out there . 

I think open source unix type OS software is going back to normal ( it was kinda hyped up in the late 90s ) , beeing a hobby/student software and not such a big deal .

I enjoy the mental stimulant , and its made me sober beeing a computer student . No more beer chugging contests for me .

I like darwin , its a little different than Free BSD  but its a open source unix OS and as long as its not microsoft I am happy .

If you havnt yet check out SuSE PPC Linux .


----------



## symphonix (May 5, 2002)

*C - * You shoot yourself in the foot.
*Java -* You create a model of a gun that automatically shoots you in the foot.
*BASIC -* You pick up a marble and throw it at your foot.
*Perl - * You find an efficient way to shoot yourself repeatedly in the foot with only one bullet.
*HTML -* You seem to be able to shoot yourself in the foot okay, but you'll need to try it out on different feet just to make sure its compatible with different footwear.


----------



## macguy17 (May 5, 2002)

> _Originally posted by AdmiralAK _
> *well quite simply C is a retard kind of language
> I HATE C  *


*MY THOUGHTS EXACTLY!!!*


----------



## macguy17 (May 5, 2002)

> _Originally posted by symphonix _
> *C -  You shoot yourself in the foot.
> Java - You create a model of a gun that automatically shoots you in the foot.
> BASIC - You pick up a marble and throw it at your foot.
> ...



ROFL!


----------



## nkuvu (May 5, 2002)

OK, just to play Devil's Advocate here, tell me why you hate C so much.  I haven't heard anyone here give a reasonable explanation why C is so evil.

The include files example is an explanation of poor programming practice, not poor language design.

The #ifdef stuff is simple once you understand it.  There are plenty of mystifying constructs in almost every language, what makes this different?

When you write your programs, do you document _everything_?  Including simple constructs, like print statements?  When you understand C/C++, commenting everything is ludicrous.  Why the heck would I want to comment something like "i++;"??  It's simple -- increment the variable i by one.

Unix C programs are not designed for learning.  They're designed to work.  And I have yet to see an operating system written in anything other than C.  Why is this?  Because ANSI C sucks?  Or maybe it's just that it's powerful?

I am not going to say that C doesn't have drawbacks -- there are plenty of reasons that C is not a good language.  I just haven't seen them here.  I've just seen a lot of people say "C SUX!!!!"  and I have no idea why they are saying it.  Does it suck because it's difficult to learn?  Because it's not well documented?  Because the programmer who wrote the source code you're looking at couldn't code his way out of a paper bag?  What?


----------



## LordCoven (May 6, 2002)

My third programming language was C (after Basic and Assembler) ... I really loved it back then. And every now and again I try and programm something small in C just to remember where a lot of it started.

I DO believe that there is most definitely still a place for C. As the previous poster pointed out, its used for system level programming. However I do application programming, and C just ain't the right language for me there. If I was doing performance critical (or real time) applications, then that would be something else. But I don't. And neither do most other programmers (that last statement is just wild speculation, and please feel free to correct me if I'm assuming too much ))

Personally, I don't like having to declare all the variables at the top (well, you had to the last time I programmed C). I don't like the way the #includes work compared to, say, Java imports. But other than that, there aren't really THAT many differences (bar the whole OO thing ...) ... and I've seen ugly C code just as I have seen ugly Java code and ugly Perl code, etc.

As far as documentation is concerned - it took me a wee while to get used to man pages back when was at Uni - because before then I was only used to Windoze help. Their different. There's actually a lot more (helpful) information in the man pages ... but I just wasn't used to them. Same applies to API docs. If you're only used to JavaDoc API docs (which IMHO are still the best), then you'll find it difficult at first getting into the whole C API docs. But if you persist and just give it a chance for a month or two, then you'll get used to that style of docs. (Same goes for Perl/Python/C++/Delphi, etc).

Anyway, just my 2 cents (and now that we have the Euro here, that saying actually makes sense, geographically, for me to use )))

C


----------



## nkuvu (May 6, 2002)

I agree, LordCoven.  Every language has its strong points.  Well, except maybe Visual Basic.    Sorry, personal prefs showing there.

You do still have to declare variables in C, by the way.  And from my experience this is a _good_ thing.  But I'm not about to argue about preferences...

Just to make my position 100% clear, I am not saying that C is the language that is better than everything else.  I just want to understand why everyone else thinks C is so bad.


----------



## LordCoven (May 6, 2002)

... I didn't mean declaring variables *per se* ... I meant having to declare them at the top of the function  ... in C++/Java/Python, etc, you can declare them anywhere you want - and I prefer to declare them just before they're used  But that's just my personal pref 

C


----------



## shrill (May 6, 2002)

nkuvu - 

There are a lot of people who are required to take classes in VB or other ridiculous languages in order to get an AS or BS degree. Some of these people may have tried to learn other languages like C, but being used to VB style rapid development tools, C scared them away.

These "programming for the english major" classes tend to just follow along with a "Learn Visual Basic In 30µs!" book. They teach the syntax of the language without teaching much about how to program a computer. 

When you don't have the basic programming foundations - knowing the different kinds of loops, how variables are stored in memory, what a pointer is for - any *real* language (C, Java, etc.) looks intimidating. 

Thus, you get stuff like "C is a retard kind of language", "C SUX!!!!!!!!!!!!" (may not be enough !'s  ), etc. 

 - shrill -


----------



## theed (May 6, 2002)

If you haven't seen an OS written in anything other than C, you haven't been around long.  Pascal and Assembler come to mind.  The reason C is popular here is the same reason that assembler is popular, it allows you to do bit twiddling and other obscure, awful, hardware-centric data manipulation that should only be necessary in device drivers.  So, C is like a really good assembler, but I fear continuing to call it a programming language.

C is hard because it's huge.  First, it wasn't written with the intention of public use, it was someone's pet project, and the keys and symbols used were chosen because they were easy to type, not because they had meaning, or were readable.  Next, you have the files, which isn't really C per se, but a precompiler construct that effectively puts the code referenced in place of the #include, making it really one big file for the compiler.  Then the issue of typing, late binding, templating, and other constructs of C that have been avoided, worked around, or otherwise bastardized so that C could be the all seeing all dancing crap of the world.  So now you have duplicate constructs that do the same thing, (struct vs class anyone?) and many possibilities over what you can do, because C can do anything ... it's assembler ... and many ways to do it.

And then on top of that, on unix, you have makefiles, which is actually its own scriptable application again, with its own syntax and rules, and of course if you're new to unix, you have to figure out the file structure as well ... so you have to create the entire universe just to bake an apple pie.  That is, in short, why I hate C.

and if you look for help in the man pages, they have their own syntax based in abstract language description syntax, so even they are confusing until you know the syntax for the man pages.

I like java, and I just wish that java hadn't settled on accepting the C syntax for a couple of things, like = and == ... it's just bad.  I would like to say though, that java chose to allow this as the syntax, but java is NOT based on or derived from C.  I'm offended.  C is the bastard child of a hundred madmen.  Learning java will allow you to program in C, but it will not allow you to read it, as C has even more obscurity and breadth than English. (American or British)

Perl at least is a scripting language that you can pretty much live in without having to learn the rest of the universe, but if you are even a touch dyslexic, you're so screwed.  I can appreciate perl while hating it; C, I mostly just hate.


----------



## shrill (May 6, 2002)

> C is the bastard child of a hundred madmen



Hahahahahah!!!! 




> ... it allows you to do bit twiddling and other obscure, awful, ...



Hey now. I like bit twiddling. There's nothing like shifting bits off the end, and wondering where they go.


----------



## AdmiralAK (May 6, 2002)

in writing drivers for my classes, and doing making hardware do things we still used x86 assember in class, and C was like a driver for the assembler part.


----------



## nkuvu (May 6, 2002)

> If you haven't seen an OS written in anything other than C, you haven't been around long. Pascal and Assembler come to mind.


So tell me, O Grand Master, which operating systems were written in Pascal and Assembler.  Then tell me the operating systems that are in use today that were written in Pascal and Assembler.  Sorry for the tone -- it sounds like you're insulting me...

Structs can't contain functions, so they're not the same as classes.  And last time I checked, C doesn't even implement classes, so this is a moot point.



> Then the issue of typing, late binding, templating, and other constructs of C that have been avoided, worked around, or otherwise bastardized so that C could be the all seeing all dancing crap of the world.


Agreed.



> and of course if you're new to unix, you have to figure out the file structure as well


Which of course is all C's fault.  I thought we were discussing C, not operating systems...



> C has even more obscurity and breadth than English. (American or British)
> 
> Perl at least is a scripting language that you can pretty much live in without having to learn the rest of the universe


It seems to me that you're contradicting yourself.  Like you're saying that C is obscure, but Perl is not.  Forgive me if I have misinterpreted -- but again I say that any code can be obfuscated.

Insert the standard "I'm not trying to offend" disclaimer here.


----------



## 96.9 (May 7, 2002)

There is an advanced programming book at the University Bookstore .

It's on how to design your own compiler.....in C !

LOL

It all depends on what you are trying to create with your time . I know that much from my studies , I have looked at Java and Widgets for my own GUI software moduels , but C just has what I need to build the utils I want .

I remeber when I first got into computers 2 1/2 years ago after an abcense of 14 years . I was a hacker when the internet was first released , telnet baby . I was quickly turned off when neighbourhood kids were busted for pirating software . I never went from floppy to hard drive and I never got a 300 baud modem of my own . C++ was just comming out when I finally put my computer away and picked up a guitar , I was using pascal back then for fun .

With C , if you have the time the world is in your hands and Assembly can be used to tighten up your code if needed . I remeber someone telling me back in 90 to to get off DOS and upgrade to a 386 and get a student version of a Unix flavour ( I was still yakking about hacking even though I was just a wanna bee ) . He went on and on about learning C and how I could do anything in the world with it .

I want to get into embedded stuff now so thats my angle I geuss .


----------



## theed (May 7, 2002)

I don't know of any modern OSes written in Pascal, since our poor dear OS 9 has departed, which still had pascal stubs till its last day.  As for assembler, someone wrote one a little while ago for x86 architecture that was noted on slashdot, had really impressive file sizes like Be did originally, OS, Nic driver and web browser all on a floppy, etc.

And when I say C I tend to refer to the family of C, C with classes, and C++.  And as such, structs and classes are the same in C++, especially if you explicitly state what's public and private.  Structs can contain functions, but it's convention not to, as that's not their intended purpose.  Both contain data members, but structs default public, classes default private.

As for my other comments bringing make, precompilers, and unix into question, the original was about why it's so hard to learn from C code.  This is definitely part of it.  When you're not sure what is what, it looks like C has 4 different forms of syntax.  I hated learning programming under C, as I spent more time learning C than learning to program.  I had already programmed under Pascal, and never got used to C's terse  syntax.

The comparison to Perl was made because at least Perl lives within itself, you don't also have to learn Make for instance.  But it's butt ugly all the same.

Nkuvu, you have some valid points, and I respect your opinions, but I will continue to hate C in general, and you seemed to be going a little farther than I thought was valid, so I played devil's advocate.  You called my bluff, err, exaggeration, and here we are.  Not really trying to offend, but not really trying not to either.


----------



## nkuvu (May 7, 2002)

> _Originally posted by theed _
> *I don't know of any modern OSes written in Pascal, since our poor dear OS 9 has departed, which still had pascal stubs till its last day.  As for assembler, someone wrote one a little while ago for x86 architecture that was noted on slashdot, had really impressive file sizes like Be did originally, OS, Nic driver and web browser all on a floppy, etc.*


This is kind of what I was talking about.  The fact that there are Pascal _stubs_ or even full functions (stub to me means non-working function, btw) does not an operating system make.  I don't think Pascal is powerful enough to make an operating system.  I only have passing acquaintance with Pascal, but I've never heard of the low level abilities of C within Pascal.  Assembly definitely has the power, but I don't think it has the maintainability to compete with a higher level language like C in the operating system market.


> *And when I say C I tend to refer to the family of C, C with classes, and C++.  And as such, structs and classes are the same in C++, especially if you explicitly state what's public and private.  Structs can contain functions, but it's convention not to, as that's not their intended purpose.  Both contain data members, but structs default public, classes default private.*


Almost every post in this thread has mentioned ANSI C as the language in question.  C++ is a mutated beast that I really think should belong to another class of language (hybrid bastard child to be more precise, but I digress  ).  I have never seen a struct with functions, nor have I ever heard that it is possible.  I'll take you at your word, however, and stand (or sit) corrected.


> *As for my other comments bringing make, precompilers, and unix into question, the original was about why it's so hard to learn from C code.  This is definitely part of it.  When you're not sure what is what, it looks like C has 4 different forms of syntax.*


Again I'll concede the point.  I never learned C from examining Unix source code, so when I did examine Unix source code I already knew what was what.  I made the classic pair of mistakes:  Not reading the original post thoroughly enough and not putting myself into the new user's shoes.  I will not, however, agree that you can count the man pages in with that new learning.  Every single programming language has a help system of some sort, be it Windows help files (shudder!), man pages, perldoc, or the web.  Since the help files all have the common problem of not being the same as the source code (syntactically speaking), I think it should be ruled out of the equation.  Common denominators, if you will.  Hey, it's a small point, but I need to make a stand somewhere... 


> *I hated learning programming under C, as I spent more time learning C than learning to program.  I had already programmed under Pascal, and never got used to C's terse  syntax.
> 
> The comparison to Perl was made because at least Perl lives within itself, you don't also have to learn Make for instance.  But it's butt ugly all the same.*


I find this interesting -- you never got used to C's terse syntax, but can use Perl even though it's "butt ugly"?  I can make beautiful C source code, and cryptic Perl code, it all depends on me.  Don't blame the language for my style (or lack thereof).

As I mentioned, I only have a passing acquaintance with Pascal -- what about it is so wonderful?  If you're talking BEGIN and END vs { and } I'll make a note to myself that you're a lunatic.    And if you already knew Pascal, why did you need to learn to program when you learned C?  Programming is programming -- the syntax varies, but the concepts stay the same.

I also don't agree that you _have_ to learn makefiles to learn C.  If you're examining pre-existing code, yes.  But I don't make makefiles for most of my programs -- they're almost always self contained, just like Perl.


> *Nkuvu, you have some valid points, and I respect your opinions, but I will continue to hate C in general, and you seemed to be going a little farther than I thought was valid, so I played devil's advocate.  You called my bluff, err, exaggeration, and here we are.  Not really trying to offend, but not really trying not to either.   *


I never tried to convince you otherwise.  I just wanted _someone_ to specify why they hate C so much, and be prepared to explain themselves.  You hate C, I don't like C (truly!), we can all hate VB together.    I swear, it took a lot of prodding to get _any_ response from someone who wanted to discuss this.  So don't be confused -- I was trying to get a reaction, so may have poked a little harder than necessary.


----------



## scruffy (May 7, 2002)

nkuvu - _I also don't agree that you have to learn makefiles to learn C._

No, you just have to learn makefiles.  Period.


----------



## theed (May 7, 2002)

yeah, the reason I even mentioned perl was that it is just as hard to read on its own as C, but it is a scripting language, not a language compiled via a mechanism, with some precompiler magic, in a wacky file structure ... that's all.  Both ugly, Perl doesn't need compiling.

The reason I said learn programming, was that I took programming courses which assumed no prior experience, their intention was to teach programming.  For the sake of brevity, I said learned.  Brevity backfired as you quoted my entire message to reply.  It's backfiring extra now as I re-explain.

As for Pascal, MacOS was originally written in Pascal, that's why the pascal stubs existed, you needed to make your code, no matter what it was written in, conform to the pascal calls that the OS (API's) still expected.

No pointers, that's one thing I liked about Pascal, and something I like about java all over again.  Not just pointers, but the syntax introduced by them.  Having some dyslexic tendencies, *, &, $, #, @ all look about the same to me when they start running together.  I get physically ill trying to read C++ with pointers thrown around. 

Also, I like the words "and" and "or" a lot better than && and || ... and why the fsck anyone chose = for assign ... it's ambiguous.  I'm not the only one who has irretrievably lost hours of life to a =/== error.  And C doesn't complain, it simply spits out false, because there isn't really a boolean type anyway.  Pascal had booleans.  I like booleans.  ... I got off track and went over the edge there, I apologize

Anyway, Pascal used := for assign, and words instead of symbols.  It was legible.  People liked it for the same reason they like AppleScript now.  Well written code simply told you what it was doing.

On the vein of not telling you what it's doing... C convention is to use i as a counter variable ... why?  Because it was a limitation in fortran, where variables' types were defined by their first letter, thus i was an integer.  All single letters might as well be x to me, I really like my variables to be things like count or loop.  Math formulas are really hard for me to remember by the way.  Anyway, conventions to minimize typing make things hard to read.

for(int i = 1;i < 5;i++) just isn't obvious.  Let alone the if then shortcuts.  And for whatever reason C programmers usually get it into their heads that shorter source files produce smaller and faster executables.  So in an attempt to make their code faster, they make it hard to read beyond the inherent complexity of optimization itself.  And that %d%x%s is why I hate C.

I should have been asleep hours ago.  does it show?


----------



## howardm4 (May 7, 2002)

I'm quite sure that Domain/OS, the 
Unixy-like OS used on some of the first
true 'workstations' by Apollo Computer
was done in Pascal.


----------



## AdmiralAK (May 7, 2002)

lol someone got busted for piracy?!
  I grew up in greece and piracy ran rampid  everyone did it (I did not have a computer back then and I was so envious of all my friends with Atari STs, Amigas and Amstrads  )


I have to say that makefiles make life easy, but they are a biatch to decipher at times.  I got a crash course on them but I still confuse myself with them.


----------



## nkuvu (May 7, 2002)

> _Originally posted by theed _
> *Also, I like the words "and" and "or" a lot better than && and || ... and why the fsck anyone chose = for assign ... it's ambiguous.  I'm not the only one who has irretrievably lost hours of life to a =/== error.  And C doesn't complain, it simply spits out false, because there isn't really a boolean type anyway.  Pascal had booleans.  I like booleans.  ... I got off track and went over the edge there, I apologize*


The = for assign isn't ambiguous at all, just different.  Yeah, the =/== error is an easy one to do , though.  Perl has the same construct.


> *Anyway, Pascal used := for assign, and words instead of symbols.  It was legible.  People liked it for the same reason they like AppleScript now.  Well written code simply told you what it was doing.*


Well written C code tells you what it is doing...


> *All single letters might as well be x to me, I really like my variables to be things like count or loop.*


Agreed, one letter variables are mostly a bad idea, but I'm used to i and j as counters, so it really doesn't matter to me.


> *for(int i = 1;i < 5;i++) just isn't obvious.*


Sure it is.  If you suddenly see an i in a for loop, I almost never go back and check the loop declaration -- I expect that int i to be there.


> *Let alone the if then shortcuts.*


If I write a sentence, I usually won't use the word then.  I personally think the then syntax is clunky.


> *And for whatever reason C programmers usually get it into their heads that shorter source files produce smaller and faster executables.  So in an attempt to make their code faster, they make it hard to read beyond the inherent complexity of optimization itself.  And that %d%x%s is why I hate C.*


Uh, shorter source files generally _do_ produce faster code.  The short part that I am referring to is the number of instructions.  To take an example from this thread a while back -- "the whole thing would have been simple with three extra lines and another variable".  But that's _at least_ three more instructions, probably more, extra memory space, plus operations to store and manipulate that memory.  So it's faster to write terse code.

This does ignore such things as order analysis of the program as a whole, and micro-improvements like this make little difference if you're in an order N^3 algorithm...


> *I should have been asleep hours ago.  does it show? *


No, you've stated your case well.  For the most part, I agree with you.

Anyway, I have to get ready for work...


----------



## ladavacm (May 7, 2002)

Complicated makefiles are sure sign of lacking frameworks.  Let us examine a makefile needed to create an executable on OS X:

```
PROG= myprog
.include <bsd.prog.mk>
```
will convert myprog.c into myprog, and myprog.1 into manpage myprog.1.gz

If you need more source files:

```
PROG= myprog
SRCS= main.c file1.c file2.c
.include <bsd.prog.mk>
```
will do the work.

Both variants will take care of all the obvious dependencies.

Edit: code did not like &lt; and &gt;


----------



## LordCoven (May 7, 2002)

Hey, y'all.

A friend of mine was really into Pascal and wrote a 3D rendering engine using that. He was able to embed Assembler into his Pascal code. Now, I'm not sure all Pascal compilers (interpreters??) allow this, but the one he was using obviously did. Just thought I'd mention this in response to something someone posted where they were asking whether you could do this ... ramble, ramble ...

Also - MacOS was programmed in Pascal? That explains a thing or two 

Another point I'd like to reiterate is that no language makes for bad programming or good programming. You can find good, clean, readable C source, just as you can find really ugly, unreadable Java code (I have to help out newbies at work, and the things they can do with Java even Satan would have difficulty dreaming up )
That's one of the problems I find with many "learn to program in X" courses - they teach the syntax, but forget to teach you about programming.

Also, I agree that one should definitely differentiate between C and C++/ObjectiveC, etc. C is one thing, and the rest is ... well ... something else, really.

Oh, and Java is based partly on C++ (also on Smalltalk) ... and C++ is based on C ... so Java kind of has bits of C in it. Mainly syntaxy stuff. And of course they went to great lengths to avoid all the "nasty" (i.e. somewhat awkward) stuff from C/C++ ... like pointers (I once had the nickname Pointer Bender, coz I could do things with pointers not even the computer was quite sure of, hehehe ).

Anyway - if your looking for a "nice syntax" language, take a look at Python. Personally, I like it -- took a bit of getting used to, but one of the main goals (I believe) was to create a language with a clean syntax.

Sorry for rambling on a bit.

Cheers,

C


----------



## nkuvu (May 7, 2002)

> That's one of the problems I find with many "learn to program in X" courses - they teach the syntax, but forget to teach you about programming.


Those books aren't meant to teach the skills of programming, they're meant to teach the syntax of the language.

If you need an explanation of a for loop, the "Teach yourself _{language}_ in X days" isn't a good choice.  But if you don't know how to write a for loop in Java (or Perl, or C, or whatever) but already know what a for loop is, they work fine.

Python == ick 

But I ranted about Python already (in this thread) so I'll leave it alone.

Edit:  Correct spelling and add link to the thread o' Python rant


----------



## LordCoven (May 7, 2002)

I said courses. I checked. Says so right there in my post! 
Wasn't talking about books. Wasn't criticising books. I was talking about courses. Ah well. Lesen muss gelernt sein 

C


----------



## LordCoven (May 7, 2002)

... and I won't post a huge rave about Python, coz I know its good and in the end its down to taste. Just thought someone should mention it here in context with clean syntax. My advice - check it out - if you don't like (which you obviously don't nkuvu, then go with something else  Personally, I like it, and as far as scripting languages go, its the one I choose every time (apart from real simple small stuff where I stick with Bash/sed/awk).



C


----------



## LordCoven (May 7, 2002)

... I agree with the point nkuvu was making:

Once you actually *have* learned how to program, then a good reference book can be very handy. Of course, in these days of always on, broadband internet I find it easier going to one of my fave sites ... or in the case of some v. well documented languages (Java, Python) the online docs are mostly more than enough 

C


----------



## 96.9 (May 7, 2002)

I want to put together a unix embedded OS that can be used for digtal sound . I want to design my own effects gear beeing a guitar maker and an enthusiast . I have been talking about this for years , I want to have something together by the fall .


----------



## nkuvu (May 7, 2002)

> _Originally posted by LordCoven _
> *I said courses. I checked. Says so right there in my post!
> Wasn't talking about books. Wasn't criticising books. I was talking about courses. Ah well. Lesen muss gelernt sein
> 
> C *


Man, that's _twice_ I misread a post.  Sorry, won't happen again.  



> *which you obviously don't nkuvu, then go with something else*


Which is what I am doing.    Just wanted to express my opinion of the matter, nothing more.



> *the online docs are mostly more than enough*


The only time I buy hardcopy text is for *1.* Something I know I'll use a lot, like Perl, *2.* Something that has poor to no online documentation, like DXL (a scripting language for a program called Doors), or *3.* A good reference for something I know but keep forgetting the syntax (because I'm switching languages too often) like C/C++.  I keep trying to make foreach loops in C...  

p.s.  LordCoven, what does "Lesen muss gelernt sein" mean?  The fish says "Vintages must be learned"


----------



## lethe (May 7, 2002)

Lesen = read.  reading must be learned (by tortoise).

i wonder what that nonsense about embedded UNIX for guitars was all about...


----------



## LordCoven (May 7, 2002)

nkuvu - to your point 1) why you buy hardcopy. I find it interesting that you buy hardcopy for something that you use a lot, coz its exactly the opposite for me. The two languages I use most are Java and Python (both professionally and 'at home') and although I did buy hardcopy when I was learning, I haven't looked at those books since that time (quite a while ago now for both). But then I'm not switching languages as much (pretty much sticking with Java/Python) so perhaps that's why.
The reason I like hardcopy is so that I can learn a language on the move. OK, its not quite as necessary since I got my iBook , but I still like books for that, coz you can sit out in the park and read them on a sunny day, which is a trifle tricky with an LCD/TFT monitor. BTW: I learned Python by downloading the tutorial as HTML onto my iPaq and reading it while on the loo ... hehehe. Truly mobile  (hope I didn't put anyone off their food just then )

PS: Lesen muss gelernt sein (as was pointed out by the last poster) means 'The ability to read must be learned' - its something I say to myself a lot when I make a stupid mistake with syntax or typo in a method name or the like when programming. 

Right, I'll stop rambling now.

Cheers,

C


----------



## scruffy (May 7, 2002)

> _Originally posted by 96.9 _
> *I want to put together a unix embedded OS that can be used for digtal sound . I want to design my own effects gear beeing a guitar maker and an enthusiast . I have been talking about this for years , I want to have something together by the fall . *



Sweet!  I assume you'd be starting from a pre-existing OS; no point building your own when free stuff exists...

Keep us posted


----------



## 96.9 (May 7, 2002)

Ya , the companies like Roland have thier own OS they use . I will be building off an existing open source embedded OS .

I have lots of stuff to research , but I will get back to ya'll in a few days . I have been sort of waiting for the open source embedded scene to get rolling , there is some nice stuff on the market in the software and hardware department . The embedded field has been a great employer in todays slow market if you have the connections . 

I just think it would be fun for people to just download something to setup in your own rig .


----------

