U.S. CitiesCity-Data Forum Index
Go Back   City-Data Forum > General Forums > Science and Technology > Computers
 [Register]
Please register to participate in our discussions with 1.5 million other members - it's free and quick! Some forums can only be seen by registered members. After you create your account, you'll be able to customize options and access all our 15,000 new posts/day with fewer ads.
Jump to a detailed profile or search
site with Google Custom Search

Search Forums  (Advanced)
Business Search - 14 Million verified businesses
Search for:  near: 
Reply Start New Thread
 
Unread 11-15-2011, 01:56 AM
 
53 posts, read 32,666 times
Reputation: 36
Quote:
Originally Posted by slackjaw View Post
Curious = in what way is C more logical than any other programming language?
Well most types of Basic for instance is essentially a scripting language with no options for memory management and very loose typing!

As someone said C is essentially "cross-compatible assembly" and by looking at the code it is quite apparent what resources the computer will allocate and what instruction series it will use.
Reply With Quote Quick reply to this message

 
Unread 11-15-2011, 07:41 AM
 
8,271 posts, read 5,055,161 times
Reputation: 4555
I understand the advantages of C.

More efficient sure, faster of course, but I'm not clear on how those attributes make it more logical. I believe one could make a case that glancing at code in another language that interacts with data structures and models a solution around objects could make the logic more easily apparent.
Reply With Quote Quick reply to this message
 
Unread 11-15-2011, 09:38 AM
 
Location: SoCal
3,713 posts, read 2,946,335 times
Reputation: 2174
Quote:
Originally Posted by MediocreButArrogant View Post
C is as close as you can get to the bare metal in a high-level programming language. That's why many C compilers support in-line assembly. An experienced C programmer can look at a line of C and act like a human compiler and figure out what assembly language instructions should be generated. Likewise, an experienced C programmer can look at assembly generated by a compiler and more or less figure out the C code that generated it.

There used to be jokes a long time ago that C was really "structured assembler".
That's not a joke. It's an accurate description. It's what K&R were after when they created C, IIRC.
Reply With Quote Quick reply to this message
 
Unread 11-18-2011, 01:49 PM
Status: "An Ameritard for a Putin takeover!" (set 13 days ago)
 
Location: spoKOMPTON
7,101 posts, read 4,059,591 times
Reputation: 3548
Wow, C is really confusing..............anyone have any suggestions to make it easier.

Here is a book I ordered , not a tutorial, but it should be helpful:

C All-in-One Desk Reference For Dummies

YIKES!
Reply With Quote Quick reply to this message
 
Unread 11-18-2011, 11:43 PM
 
Location: Mableton, GA USA (NW Atlanta suburb, 4 miles OTP)
9,915 posts, read 12,801,592 times
Reputation: 2686
Quote:
Originally Posted by MediocreButArrogant View Post
C is as close as you can get to the bare metal in a high-level programming language. That's why many C compilers support in-line assembly. An experienced C programmer can look at a line of C and act like a human compiler and figure out what assembly language instructions should be generated. Likewise, an experienced C programmer can look at assembly generated by a compiler and more or less figure out the C code that generated it.

There used to be jokes a long time ago that C was really "structured assembler".
I can drop into inline assembler code in FORTRAN 77 on the mainframe environment where I work, and with the old F66 compiler it was easy to get a long listing that showed the MASM statements that the compiler generated for each FORTRAN statement.

C can do it as well, but it's hardly a unique feature of C.

And no, with today's multi-pipeline processors that do instruction reordering on the fly, I doubt you can predict the code generated by the optimizer, or even the order in which those instructions will be processed.
Reply With Quote Quick reply to this message
 
Unread 11-18-2011, 11:47 PM
 
Location: Mableton, GA USA (NW Atlanta suburb, 4 miles OTP)
9,915 posts, read 12,801,592 times
Reputation: 2686
Quote:
Originally Posted by tobiasra View Post
So I thought as well before it was approached from the microcontroller assembly angle. Then everything fell in place and all seemed more logical than any other programming language.
How many languages have you used?

I'd probably used a dozen languages before I first ran into C in the early 90's, and the use of the "=" operator for assignment and "==" for equivalence has always bothered me. Who else hasn't done this accidentally?

if (aflag = 1) {
bflag = 0;
}

thinking they were checking aflag and conditionally setting bflag?

In good old FORTRAN:

IF (A .EQ. 1) THEN
BFLAG = 0
ENDIF

No question which is which.
Reply With Quote Quick reply to this message
 
Unread 11-18-2011, 11:50 PM
 
Location: Mableton, GA USA (NW Atlanta suburb, 4 miles OTP)
9,915 posts, read 12,801,592 times
Reputation: 2686
Quote:
Originally Posted by oddstray View Post
That's not a joke. It's an accurate description. It's what K&R were after when they created C, IIRC.
I think it's too bad that K&R didn't spend more time studying languages like Algol.

Many of the languages I've used from that language family seem a lot clearer to me. The C-like languages which dominate the POSIX world are good in their own right, but descriptions like the one you cite show a frightening lack of knowledge with regard to other programming languages of the time.

The Burroughs big iron boxes (B-series and eventually A-series) of the 60's and 70's running MCP used (and still use) an Algol variant as their assembly language, or so I'm told. It *is* the assembly language. My experience on MCP platforms is limited to COBOL/MARC and WFL, so I can't confirm or deny that firsthand.
Reply With Quote Quick reply to this message
 
Unread 11-18-2011, 11:59 PM
 
Location: Mableton, GA USA (NW Atlanta suburb, 4 miles OTP)
9,915 posts, read 12,801,592 times
Reputation: 2686
Quote:
Originally Posted by slackjaw View Post
I suspect memory management is the biggest wtf encountered by people learning C who are used to another programming language. Also probably the most common source of bugs, be it having a memory leak or walking into areas you shouldn't be.
Using malloc is scary...

Sheesh. Try PEEK and POKE sometime.
Reply With Quote Quick reply to this message
 
Unread 11-19-2011, 10:15 AM
 
Location: SoCal
3,713 posts, read 2,946,335 times
Reputation: 2174
Quote:
Originally Posted by rcsteiner View Post
How many languages have you used?

I'd probably used a dozen languages before I first ran into C in the early 90's, and the use of the "=" operator for assignment and "==" for equivalence has always bothered me. Who else hasn't done this accidentally?

if (aflag = 1) {
bflag = 0;
}

....
I've *never* done that! Not since last week! Luckily, any decent C compiler will warn you of that.
Reply With Quote Quick reply to this message
 
Unread 12-04-2011, 04:27 PM
Status: "An Ameritard for a Putin takeover!" (set 13 days ago)
 
Location: spoKOMPTON
7,101 posts, read 4,059,591 times
Reputation: 3548
Quote:
Originally Posted by tobiasra View Post
Well most types of Basic for instance is essentially a scripting language with no options for memory management and very loose typing!

As someone said C is essentially "cross-compatible assembly" and by looking at the code it is quite apparent what resources the computer will allocate and what instruction series it will use.
Or you can go all out and learn Assembly Language.............but wow, that stuff hurts my brain.

I wonder if there are people smart enough to just directly write ONES and ZEROS as needed by the machine.............lol, idrectly writing Machine Code with no compiler.
Reply With Quote Quick reply to this message
Please register to post and access all features of our very popular forum. It is free and quick. Over $68,000 in prizes has already been given out to active posters on our forum. Additional giveaways are planned.

Detailed information about all U.S. cities, counties, and zip codes on our site: City-data.com.


Reply
Please update this thread with any new information or opinions. This open thread is still read by thousands of people, so we encourage all additional points of view.

Quick Reply
Message:


Over $74,000 in prizes was already given out to active posters on our forum and additional giveaways are planned!

Go Back   City-Data Forum > General Forums > Science and Technology > Computers

All times are GMT -6.

2005-2014, Advameg, Inc.

City-Data.com - Archive 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 - Top