Hi,
I am new to C and curious to know some basic questions about C.
Why C is good?
In what way its better than any other languages?
If it is no longer a choice of programming language...why people still study
it?
And also its not an OO language either...is there any advantages in being
not an OO language?
I know one reason is that, IT started with C and so they are still using
them rather than changing it into new language.
Nov 14 '05
39 2864 da*****@NOMORES PAMcs.utoronto. ca.com (Darrell Grainger) writes: On Fri, 30 Apr 2004, E. Robert Tisdale wrote:
The correct term is *assembler*.
[...] How could you not be aware of this? You have lost a great deal of credibility and so far you have only made one statement. [...]
ERT had credibility? That's news to me. You're best off just
ignoring his articles; he rarely has useful information to
impart.
--
int main(void){char p[]="ABCDEFGHIJKLM NOPQRSTUVWXYZab cdefghijklmnopq rstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwC IxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+= strchr(p,*q++)-p;if(i>=(int)si zeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;} da*****@NOMORES PAMcs.utoronto. ca.com (Darrell Grainger) wrote: On Fri, 30 Apr 2004, E. Robert Tisdale wrote:
You have lost a great deal of credibility
Amazing. I have noticed that certain statements in C language will *not* always produce the same machine language on a given machine.
Okay, so C language is not EXACTLY machine language. There is not a hard one-to-one correspondence. Thus it has been said that C is 'close to' the machine language.
Then again, that _is_ a vast overstatement. How, then, can C language code be "close" to machine language code on each of these different architectures?
For any given architecture it is 'close to' that architecture.
Oh, bull. C is the same on each architecture; the machine languages
differ, sometimes greatly. C can be interpreted; what does an
interpreter have to do with machine code?
If I was to write a loop that counted from zero to 100 in PDP-11 assembly language, same thing for a MC68000 assembly language and again for ARM9 assembly language there will be similarities between them. Even if I never programmed ARM9 assembly language, I could look at the code and figure out it is a loop that counts from 0 to 100. If I compiled:
for(i = 0; i <= 100; i++)
Yes, but this says absolutely _nothing_ about C. Lots and lots of
programming languages have very similar constructs. Basic has FOR ...
NEXT; Pascal has for ... do; Icon has foreach.
If anything, the for statement seems to prove that C is _less_ close to
machine language than Basic and Pascal, and about as close as Icon,
because while all Basic and Pascal have is the normal, assembly-alike,
count up or down, C allows for loops like
for (ptr=list_head, total=0; ptr; total+=amount(p tr), ptr=ptr->next)
modify_list_ele ment(ptr);
which does not have a similarly close equivalent in assembler language
(and Icon allows similar things with hand-written generators).
Richard
E. Robert Tisdale wrote: Chris Dutton wrote:
C is sometimes known as "portable assembler". The key concept represented by this statement is that C is closer to the machine that most other languages.
I don't know what that means. Which "machine" is C "close to"? Is C "farther" from machines that are not "close to" the machine that C is "close to". What sort of topology allows this sort of reasoning?
Oh, come on, Robert. You embarrass the rest of us UCLA Ph.D's and soon-to-be
Ph.Ds. Walter is probably spinning in his grave.
It's a fundamental tenet in languages that there is a hypothetical, perfect
virtual machine that models the implementation and runtime semantics of a
language. C is no exception.
And yes, C is a portable assembler for lack of a better phrase. It seems to
grow like a weed on many different platforms because the processor model of
most platforms maps well to the hypothetical VM that maps to the language.
"Suresh" <gs*****@rogers .com> wrote: I am new to C and curious to know some basic questions about C. Why C is good? In what way its better than any other languages?
Of course, some would argue that its not.
But in any event, C is usually implemented very close to the latest
ANSI and ISO standards prior to C99, and its implemented for just
about every platform in existence. For example, there are basically
no (or very few) C++ compilers that are totally standards compliant,
while very few C compilers are not. C has a long history, is fairly
stable, and has good functionality. There are more generally
applicable books and tools written for C than any other language.
If it is no longer a choice of programming language...why people still study it?
Knowing C is kind of a prerequisite for learning C++.
And also its not an OO language either...is there any advantages in being not an OO language?
OO introduces more complications to programming languages that have
nothing to do with general computation. Like Perl, OO makes programs
easier to write, but harder to maintain. More people know and
understand basic C, than the OO features of C++ -- this means that
moving to OO will necessarily reduce the set of programmers that will
be equipped to deal with it.
OO also has no feature which can improve the performance of programs
that cannot be duplicated with non-OO mechanisms. At the same time OO
hides lots of implementation details which *CAN* drastically impact
performance in a negative way. One typically needs a lot of expertise
to know when these cases occurr and to know how to avoid them.
--
Paul Hsieh http://www.pobox.com/~qed/ http://bstring.sf.net/
On Tue, 04 May 2004 15:13:09 -0700, Paul Hsieh wrote: "Suresh" <gs*****@rogers .com> wrote: I am new to C and curious to know some basic questions about C. Why C is good? In what way its better than any other languages? Of course, some would argue that its not.
But in any event, C is usually implemented very close to the latest ANSI and ISO standards prior to C99, and its implemented for just about every platform in existence. For example, there are basically no (or very few) C++ compilers that are totally standards compliant, while very few C compilers are not. C has a long history, is fairly stable, and has good functionality. There are more generally applicable books and tools written for C than any other language.
All of this true to a surprisingly large extent, but it can be difficult
to make some compilers conform to /only/ C89. For example, gcc requires a
small clutch of command-line options (-ansi -pedantic -Wall) to /not/
compile its set of extensions /and/ to generate all of the warnings it
needs to. If it is no longer a choice of programming language...why people still study it? Knowing C is kind of a prerequisite for learning C++.
False. C++ can be learned as a standalone language, and even as a /first/
language. (Although beginning with Python might be better, that's a matter
of pedagogical taste.)
In fact, learning about C and C++ as two very different languages (as
different as, say, Algol-68 and Pascal) is the best, in terms of code
hygiene (should malloc() be cast?) and conceptual modeling (the C++ STL,
for example, allows much different approaches to problems than the C
standard library). And also its not an OO language either...is there any advantages in being not an OO language? OO introduces more complications to programming languages that have nothing to do with general computation. Like Perl, OO makes programs easier to write, but harder to maintain. More people know and understand basic C, than the OO features of C++ -- this means that moving to OO will necessarily reduce the set of programmers that will be equipped to deal with it.
Now, this is simply ignorant. OO can improve the organization and
maintainability of the code by orders of magnitude when used by skilled
professionals, as opposed to inept fools. OO allows a programmer to
enforce a single unified interface to his solutions, as opposed to a
hodge-podge of exported subroutines and messy global variables. OO also has no feature which can improve the performance of programs that cannot be duplicated with non-OO mechanisms. At the same time OO hides lots of implementation details which *CAN* drastically impact performance in a negative way. One typically needs a lot of expertise to know when these cases occurr and to know how to avoid them.
OO does nothing of the sort. Compilers and, to a lesser extent, languages
do. The take-home lesson here is that languages aren't inefficient,
programs are: Either the OO code you write is absolutely hideous cruft
(likely) or your tools are badly-written.
--
yvoregnevna gjragl-guerr gjb-gubhfnaq guerr ng lnubb qbg pbz
To email me, rot13 and convert spelled-out numbers to numeric form.
"Makes hackers smile" makes hackers smile.
August Derleth <se*@sig.now> wrote: On Tue, 04 May 2004 15:13:09 -0700, Paul Hsieh wrote: If it is no longer a choice of programming language...why people still study it? Knowing C is kind of a prerequisite for learning C++.
False. C++ can be learned as a standalone language, and even as a /first/ language. (Although beginning with Python might be better, that's a matter of pedagogical taste.)
But if you try to learn C++ by itself, you end up learning basic C as
a result. You may learn something different about NULL, the way
structures can be declared, and how sizeof works, but these are
details that even C programmers are often not very clear on.
My point is that if you can't learn C for whatever reason, you aren't
really going to be able to learn C++.
In fact, learning about C and C++ as two very different languages (as different as, say, Algol-68 and Pascal) is the best, in terms of code hygiene (should malloc() be cast?)
Should malloc be cast in C is a paranoia that I believe exists
strictly in CLC. I believe people outside CLC will cast it or not as
it suits them or, in C++'s case, as its required. Knowing this or
not, is not what I would seriously consider "knowledge" about C. Of
course malloc isn't used much in C++ at all. And also its not an OO language either...is there any advantages in being not an OO language?
OO introduces more complications to programming languages that have nothing to do with general computation. Like Perl, OO makes programs easier to write, but harder to maintain. More people know and understand basic C, than the OO features of C++ -- this means that moving to OO will necessarily reduce the set of programmers that will be equipped to deal with it.
Now, this is simply ignorant. OO can improve the organization and maintainability of the code by orders of magnitude when used by skilled professionals, as opposed to inept fools.
You don't see the inherent contradiction in the statement you just
wrote? The bar for dealing with C++ is simply higher. You only point
out the extremes, but one cannot maintain what one does not
understand. The C++ standard is apparently > 1000 pages -- meaning
that even if you understand C++ for your own purposes, understanding
it to maintain someone else's code is a completely different matter.
[...] OO allows a programmer to enforce a single unified interface to his solutions, as opposed to a hodge-podge of exported subroutines and messy global variables.
C doesn't require or encourage a hodgepodge of exported subroutines or
messy global variables. Minimizing or completely eliminating the use
of global variables is a good habit that has nothing to do with
anything about C or C++. The "static" keyword and function pointers
were also introduced in C, not C++. OO also has no feature which can improve the performance of programs that cannot be duplicated with non-OO mechanisms. At the same time OO hides lots of implementation details which *CAN* drastically impact performance in a negative way. One typically needs a lot of expertise to know when these cases occurr and to know how to avoid them.
OO does nothing of the sort. Compilers and, to a lesser extent, languages do.
This is just an assertion, and you don't understand that its wrong.
For example, to compute any algebraic expression, a compiler will
model the computation with temporary variables. However, whether or
not the compiler can eliminate some of the temporaries may be beyond
even the theoretical capabilities of any compiler -- and its usually
not clear unless the programmer goes through the same work as the
compiler by hand.
C++ introduces the concept of contructors/destructors which
necessitates built-in memory management for objects. This is fine
except that if you create an array of objects, raw performance of this
memory management and the fragmentation of the heap itself could be
improved if a group of objects (related by their use, not their type)
were allocated in a single allocation call. A C programmer has no
problem seeing and doing this -- I know of no C++ compiler capable of
this.
STL's vectors, for another example, have a surprising implementation
that requires that the default constructor be present for your object.
The reason is that in order to append an entry, its going to create
the default one, then copy the one you are passing via "=". That's
all very interesting, except that depending on your object design, the
"class A1(A0)" initialization idea (if implemented as basically a
copy) can skip this extra construction step (which can be arbitrarily
expensive -- your object could launch a thread on construction, for
example.) STL can't see this because of its implementation, and what
the language C++ specifies (the compiler can't know that class A1(A0)
is going to implement copying, even if the programmer does.)
[...] The take-home lesson here is that languages aren't inefficient, programs are:
Ok now who's talking about ignorance. Look at Fortran, the "volatile"
keyword addition to C in C99, and any benchmarks of Java, C and Lisp.
There are serious differences in languages with respect to
performance, that go beyond the different capabilities of compilers.
People who follow these things on Windows like to hail the Intel C
compiler as being somewhat miraculous for being able to maintain a 20%
edge over MSVC or gcc, however I would be surprised if there is any
program in either Java of Fortran that stays pretty much within 20% of
C. You could at best make this argument between C and Pascal perhaps
-- but one could argue that these languages are very close in what
they implement beyond their syntactical differences.
--
Paul Hsieh http://www.pobox.com/~qed/ http://bstring.sf.net/
> Now, this is simply ignorant. OO can improve the organization and maintainability of the code by orders of magnitude when used by skilled professionals, as opposed to inept fools. OO allows a programmer to enforce a single unified interface to his solutions, as opposed to a hodge-podge of exported subroutines and messy global variables.
True (when properly used), but you can write C in an OO manner.
I've been using C in this way for years. And have still good
reasons to do so instead of using C++.
OO does nothing of the sort. Compilers and, to a lesser extent, languages do. The take-home lesson here is that languages aren't inefficient, programs are: Either the OO code you write is absolutely hideous cruft (likely) or your tools are badly-written.
True in an abstract environment, but not true in the real world.
If you take the example of C vs. C++: there is no way you can make the
same piece of software use less resources and memory space with C++
compared to a C solution. Some people have been claiming the opposite
for ages, but I have yet to see a single proof of it.
Paul Hsieh wrote: August Derleth <se*@sig.now> wrote:
.... snip ... [...] OO allows a programmer to enforce a single unified interface to his solutions, as opposed to a hodge-podge of exported subroutines and messy global variables.
C doesn't require or encourage a hodgepodge of exported subroutines or messy global variables. Minimizing or completely eliminating the use of global variables is a good habit that has nothing to do with anything about C or C++. The "static" keyword and function pointers were also introduced in C, not C++.
For an example of OO design in pure C, see my hashlib (URL
below). It is designed so that the user can only get his hands on
objects he designs himself (barring futzing with the hashlib
source code). All this is done through the normal C abilities,
with the exception that the user is told not to alter the portion
of the data object on which the hash depends. The use of static,
void *, and incomplete structures is essential. The user, in
turn, can define his objects as he likes, but must define a
specified set of operations on them. This is really no more than
an exercise in information hiding.
See <http://cbfalconer.home .att.net/download/hashlib.zip>
--
fix (vb.): 1. to paper over, obscure, hide from public view; 2.
to work around, in a way that produces unintended consequences
that are worse than the original problem. Usage: "Windows ME
fixes many of the shortcomings of Windows 98 SE". - Hutchison
"Suresh" <gs*****@rogers .com> wrote in message news:<lE******* *************** @twister01.bloo r.is.net.cable. rogers.com>... Hi, I am new to C and curious to know some basic questions about C. Why C is good?
Well, Yes and No. Its very good for the kind of programming task where
you need to be closer to the hardware, directly access the memory, and
need speed/effeciency. But when you are out to solve generic problems
where hardware is not a matter of concern, C would probably be a
not-so-good choice.
A 10 line program in C can be converted to a single line program in
Python. But that takes away speed. So its your choice.
In what way its better than any other languages?
Well, most(!) other languages are written in C (eg. Python, Perl, PHP,
Ruby etc.) And IMHO its foolish to compare languages like this to C as
much as its foolish to compare a high level language with assembler or
uP opcodes, so to speak. I know a lot of "programmer s" who complain
about the way strings are handled in C and the poor support for them;
and then they brag about how easy it is to do so in perl/php.
If it is no longer a choice of programming language...why people still study it?
Frankly speaking, its because no other language has been able to
replace it and it still is the choice of programming language. Check
out the source code for any of the BSDs/Linux'es, they all use C. I
know people who develop operating systems in C++ but I don't think its
worth the effort. Even GNU prefers that all its official software be
written in C. I know there will be 1000s of anti-C advocates to refute
me, but they've been around since C was born.
And also its not an OO language either...is there any advantages in being not an OO language?
OO is not everything. Oh yeah, if you really understood OO, to some
level it can be acheived in C also, although it could get ugly, thats
all. http://ldeniau.home.cern.ch/ldeniau/html/oopc/oopc.html
I know one reason is that, IT started with C and so they are still using them rather than changing it into new language.
Oh no, C is not as ubiquitous as everybody thinks. Check this out and
drive your myths away - http://www.cobolwebler.com/cobolfacts.htm
Peace.
Vivek
"Suresh" <gs*****@rogers .com> wrote in message news:<lE******* *************** @twister01.bloo r.is.net.cable. rogers.com>... Hi, I am new to C and curious to know some basic questions about C. Why C is good?
Well, Yes and No. Its very good for the kind of programming task where
you need to be closer to the hardware, directly access the memory, and
need speed/effeciency. But when you are out to solve generic problems
where hardware is not a matter of concern, C would probably be a
not-so-good choice.
A 10 line program in C can be converted to a single line program in
Python. But that takes away speed. So its your choice.
In what way its better than any other languages?
Well, most(!) other languages are written in C (eg. Python, Perl, PHP,
Ruby etc.) And IMHO its foolish to compare languages like this to C as
much as its foolish to compare a high level language with assembler or
uP opcodes, so to speak. I know a lot of "programmer s" who complain
about the way strings are handled in C and the poor support for them;
and then they brag about how easy it is to do so in perl/php.
If it is no longer a choice of programming language...why people still study it?
Frankly speaking, its because no other language has been able to
replace it and it still is the choice of programming language. Check
out the source code for any of the BSDs/Linux'es, they all use C. I
know people who develop operating systems in C++ but I don't think its
worth the effort. Even GNU prefers that all its official software be
written in C. I know there will be 1000s of anti-C advocates to refute
me, but they've been around since C was born.
And also its not an OO language either...is there any advantages in being not an OO language?
OO is not everything. Oh yeah, if you really understood OO, to some
level it can be acheived in C also, although it could get ugly, thats
all. http://ldeniau.home.cern.ch/ldeniau/html/oopc/oopc.html
I know one reason is that, IT started with C and so they are still using them rather than changing it into new language.
Oh no, C is not as ubiquitous as everybody thinks. Check this out and
drive your myths away - http://www.cobolwebler.com/cobolfacts.htm
Peace.
Vivek This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: matty |
last post by:
Go away for a few days and you miss it all... A few opinions...
Programming is a craft more than an art (software engineering, not
black magic) and as such, is about writing code that works, first
and foremost. If it works well, even better. The same goes for
ease of maintenance, memory footprint, speed, etc, etc. Most of the
time, people are writing code for a use in the *real world*, and
not just as an academic exercise.
Look at...
|
by: David MacQuigg |
last post by:
I'm concerned that with all the focus on obj$func binding, &closures,
and other not-so-pretty details of Prothon, that we are missing what
is really good - the simplification of classes. There are a number of
aspects to this simplification, but for me the unification of methods
and functions is the biggest benefit.
All methods look like functions (which students already understand).
Prototypes (classes) look like modules. This will...
|
by: Mike MacSween |
last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime
ago.
Then remembered that arguments are passed by reference, by default.
Does the fact that this slowed me down indicate:
a) That I don't know enough
b) Passing arguments by ref is bad
|
by: Clark |
last post by:
Hi all.
I'm looking for good C source code to study and be able to advance my C
programming skills. Do you recomend any open source project in particular
that in your opinion has good writen C code?
Thanks.
|
by: Kevin Hall |
last post by:
C++ is one of my favorite languages to work in. This is because it has
so many differrent strengths. But there is also a number of blemishes
in the language -- some could potentially be fixed, others are not
likely. I wanted to open a discussion on what people think are the
good and bad things about C++. Here are my lists:
Good things about C++
---------------------
- multi-paradigm language.
- const-specifications
| |
by: Jon Skeet [C# MVP] |
last post by:
I'm looking to write a C# book fairly soon, and the publisher I've
approached wants me to do a bit of market research to find out what
people like and don't like in this kind of book.
I've read loads of reviews of best-selling books on Amazon, so I've got
some ideas from there, but I'd be very interested in hearing what you
all think makes a good C# book.
I'm interested primarily in stylistic things - how light-hearted, what
kind of...
|
by: WaterWalk |
last post by:
I've just read an article "Building Robust System" by Gerald Jay
Sussman. The article is here:
http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf
In it there is a footprint which says:
"Indeed, one often hears arguments against building exibility into an
engineered sys-
tem. For example, in the philosophy of the computer language Python it
is claimed:
\There should be one|and preferably only one|obvious...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |