473,883 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

why still use C?

no this is no trollposting and please don't get it wrong but iam very
curious why people still use C instead of other languages especially C++.

i heard people say C++ is slower than C but i can't believe that. in pieces
of the application where speed really matters you can still use "normal"
functions or even static methods which is basically the same.

in C there arent the simplest things present like constants, each struct and
enum have to be prefixed with "struct" and "enum". iam sure there is much
more.

i don't get it why people program in C and faking OOP features(functi on
pointers in structs..) instead of using C++. are they simply masochists or
is there a logical reason?

i feel C has to benefit against C++.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05
687 23872
Hans-Bernhard Broeker wrote:
....
designers who effectively did that. I'm not aware of any architecture
in active use right now that has FLT_RADIX != 2. In fact, there seems


P.J. Plauger has already mentioned the S/370, which had FLT_RADIX==16,
as well as a few less common machines where FLT_RADIX==10, as being the
driving factors behind allowing FLT_RADIX!=2 in C99.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #591
Mike Cowlishaw wrote:
... there was a question about using a pragma to switch the
meaning of the floating-point types [between base 10 and base
2].

Yes, in principle it can be done, and on the surface it might
seems it would limit complexity. But after some code
prototyping, and thinking it through more carefully, using pragma
has a number of disadvantages.

Below quickly summarizes the main points:

1/ The fact that there are two sets of floating-point types in
itself does not mean the language would become more complex.

The complexity question should be answered from the
perspective of the user's program - that is, do the new data
types add complexity to the user's code? My answer is no,
except for the issues surrounding implicit conversions, which
I will address below. For a program that uses only binary
floating-point [FP] types, or uses only decimal FP types,
the programmer is still working with at most three FP
types. We are not making the program more difficult to
write, understand, or maintain.
[wholehearted agreement]
2/ Implicit conversions can be handled by simply disallowing them
(except maybe for cases that involve literals). If we do this,
for CUs that have both binary and decimal FP types, the
code is still clean and easy to understand. In a large
source file, with std pragma flipping the meaning of the
types back and forth, the code is actually a field of land
mines for the maintenance programmer, who might not
immediately aware of the context of the piece of code.

[For example, if a piece of code expected to be doing
'safe' exact decimal calculations were accidentally
switched to use binary, the change could be very hard to
detect, or only cause occasional failure.]
Not a good idea. This was the kind of rationale exercised by the
Stratus Computer people when they included PL/I-style
variable-length strings into their VOS C implementation. It has
produced nightmare after nightmare for even highly experienced
and sophisticated programming teams. (Stratus' VOS was, at least
orininally, written in PL/I)

I have no difficulty seeing the same kind of confusion and
frustration growing out of this kind of policy.

How does this proposal deal with expressions evaluating both FP-2
and FP-10 variables? What are the proposed rules of promotion for
mixed floating point types and sizes? Are you going to require
explict promotions and conversions? If the answer to this latter
is "yes", then I'd like to go on record as having warned before
the fact that you're not only creating an ugly monster; but that
you aren't acting in the best interests of the wider community.
3/ Giving two meanings to one data type hurts type safety. A
program may bind by mistake to the wrong library, causing
runtime errors that are difficult to trace. It is always
preferable to detect errors during compile time. Overloading
the meaning of a data type makes the language more
complicated, not more simple.
Unless you can somehow nullify Murphy's Law, mistakes will be
made, regardless. If the proposal obscures the meaning of C code
as you suggest below, then this would seem to suggest that you'd
prefer the errors to be made at coding time - and remain
undetected at compile time. [I don't think this is your actual
intent; but I see it as the natural consequence of implementing
this rationale.]
4/ A related advantage of using separate types is that it
facilitates the use of source checking/scanning utilities (or
scripts). They can easily detect which FP types are used
in a piece of code with just local processing. If a std
pragma can change the representation of a type, the use of
grep, for example, as an aid to understand and to search
program text would become very difficult.
Only if the grep user is too lazy to check the most recent
radix-controlling pragma. The source editors I use most (nedit,
gvim) BTW make this a "no brainer". If you're addressing
/particular/ "source checking/scanning utilities (or scripts)"
then you should probably consider changing/replacing those (dare
I say "brain dead"?) inadequate tools. This is not a /C/ issue.
Comparatively speaking, this is not a technical issue for the
implementation, as it might seem on the surface initially --
i.e., it might seem easier to just tag new meaning to
existing types -- but is an issue about usability for the
programmer. The meaning of a piece of code can become
obscure if we reuse the float/double/long double types.
Also, I feel that we have a chance here to bind the C
behavior directly with [the new] IEEE types, reducing the
number of variations among implementations . This would help
programmer writing portable code, with one source tree
building on multiple platforms. Using a new set of data
types is the cleanest way to achieve this.
If the meaning of the code can made obscure by changing the
underlying floating point processing, then I'd like to suggest
that we're on a bad path, however good our intentions.
To this I would add (at least) a few more problems with
the 'overloading' approach:

5/ There would be no way for a programmer in a 'decimal'
program to invoke routines in existing (binary) libraries.
Every existing routine and library would need to be
rewritten for decimal floating-point, whereas in many
(most?) cases the binary value from an existing library
would have been perfectly adequate.
Even if the word was "most" (instead of just "many"), what of the
other cases? I'm understanding this 'point' as an invitation to
degrade the language/library.

My clients won't accept "adequate" results "most" of the time.
Whatever we do needs to be a higher quality solution than that.
If this means a whole new library, then let's be honest enough to
face that fact now.
6/ Similarly, any new routine that was written using decimal FP
would be inaccessible to programmers writing programs which
primarily used binary FP.

7/ There would be no way to modify existing programs (using
binary FP calculation) to cleanly access data in the new
IEEE 754 decimal formats.

8/ There would be no way to have both binary and decimal
FP variables in the same data structure.

9/ Debuggers would have no way of detecting whether a FP number
is decimal or binary and so would be unable to display the
value in a human-readable form. The datatypes need to be
distinguished at the language level and below.

The new decimal types are true primitives, which will exist at
the hardware level. Unlike compound types (such as Complex),
which are built from existing primitives, they are first class
primitives in their own right. As such, they are in the same
category as ints and doubles, and should be treated similarly and
distinctly.


To an ordinary C programmer who has no investment (emotional or
otherwise) in FP-10, in the implementation and/or marketing of a
new generation compiler, nor the implementation and/or marketing
of a new generation library, all of this sounds very much like an
argument /against/ a change to the C language standard to
accommodate radix 10 floating point.

In point of fact, as an ordinary C programmer I have no
difficulty appreciating the benefits of FP-10. I don't care what
goes on in the circuitry so long as it produces accurate results
in even (especially?) worst case scenarios. As an ordinary C
programmer I feel that the circuitry is not something I should
need to worry about (at least not in /hosted/ systems) else I'd
still be an assembly language programmer. Finally (and still an
ordinary C programmer), I'll welcome FP-10 benefits when they
produce the accurate results I require in a transparent fashion -
when FP-10 data is properly handled in all arithmetic expressions
(including those containing floating point data in any other
radix representation) as clearly, cleanly, and consistantly as
all currently existing arithmetic types. IME, a failure to
provide this kind of type compatibility amounts to a low-quality
arithmetic operator overloading - and I have difficulty seeing
that as an improvement to the language.
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c
Read my lips: The apple doesn't fall far from the tree.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #592
Fergus Henderson wrote:

"Mike Cowlishaw" <mf*****@attglo bal.net> writes:
P.J. Plauger wrote:
Who's talking about removing features? Standard C has *never* promised
that floating-point arithmetic will be done in binary. And it's damned
hard to write a program that can determine whether it is.


This one should be quite reliable:

#include <stdio.h>
int main(void) {
double x = 0.1;
if (x*8 != x+x+x+x+x+x+x+x )
printf("Binary" );
else
printf("Decimal ");
return 0;
}


You are kidding, right?

--
Fergus Henderson <fj*@cs.mu.oz.a u> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et


maybe, replace line 3 and 4 by:

double x = 1.2;
if (x/3 != x - 0.8)

Wolfgang
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #593
"Mike Cowlishaw" <mf*****@attglo bal.net> wrote in message
news:cl******** ********@pletho ra.net...
Dan Pop wrote:
And what is the exact result of dividing 1 penny by 3, when using
decimal floating point arithmetic? Or is division a prohibited
operation for this class of applications?


This is exactly why floating-point is the right solution. Whenever
the result is Inexact, you get the best possible approximation to
the 'ideal' result -- that is, full precision. With a fixed scaling
factor you cannot make full use of the precision unless you
know how many digits there will be to the left of the radix
point.


You also get the best possible approximation to the 'ideal' result if you
use binary floating-point. I'm sure you know this, but it's worth
emphasizing anyway: decimal floating point does *not* get rid of the inexact
nature of floating-point operations for the majority of calculations.

It seems to me that the *only* thing decimal floating point gets you is
conformance to the conventions used by the financial community for how to
deal with that inexactness. You can do that today with a library, so the
only thing that hardware support gets you is faster computations for those
calculations where this is a requirement.

Note that this library could be implemented in assembly on those platforms
that have hardware support, so you don't really even need native C support
for decimal floating point in order to get the faster computations. Of
course, using such a library is inconvenient compared to having native C
support, but that inconvenience is payed only by those who need this
capability. Is that group of people large enough that inconveniencing them
justifies changing the language?

--
Eric Backus
R&D Design Engineer
Agilent Technologies, Inc.
425-356-6010 Tel
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #594
In article <cl************ ****@plethora.n et>, P.J. Plauger
<pj*@dinkumware .com> writes
"Douglas A. Gwyn" <DA****@null.ne t> wrote in message
news:cl******* *********@pleth ora.net...
I'll also remark that this newsgroup discussion isn't a
very effective way to proceed. In several days of
dicussion so far, no point has been made that wasn't
dealt with within a few minutes at the evening session
during the recent Kona C meeting.


But it has educated a wider audience to some of the issues,
and that's an important part of proceeding.


This is true. Not everyone can make the panel meetings. The majority
don't: particularly some of the experts. I recall that out of many who
understood and discussed the problem on our panel only two attend the
Kona meeting.
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/\
/\/\/ ch***@phaedsys. org www.phaedsys.org \/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #595
Eric Backus wrote:
"Mike Cowlishaw" <mf*****@attglo bal.net> wrote in message
news:cl******** ********@pletho ra.net...
Dan Pop wrote:
And what is the exact result of dividing 1 penny by 3, when using
decimal floating point arithmetic? Or is division a prohibited
operation for this class of applications?
This is exactly why floating-point is the right solution. Whenever
the result is Inexact, you get the best possible approximation to
the 'ideal' result -- that is, full precision. With a fixed scaling
factor you cannot make full use of the precision unless you
know how many digits there will be to the left of the radix
point.


You also get the best possible approximation to the 'ideal' result if
you use binary floating-point. I'm sure you know this, but it's worth
emphasizing anyway: decimal floating point does *not* get rid of the
inexact nature of floating-point operations for the majority of
calculations.


Indeed, but there is the huge class of 'interesting' calculations
where using base 10 FP will yield exact results where binary
cannot.
It seems to me that the *only* thing decimal floating point gets you
is conformance to the conventions used by the financial community for
how to deal with that inexactness. If, by 'financial community' you include everyone who does
calculations on their finances, I agree.
You can do that today with a
library, so the only thing that hardware support gets you is faster
computations for those calculations where this is a requirement.
It's certainly true that the only thing that hardware support
gives you, over a library of assembler code, is improved
performance. But we are talking orders of magnitude
(remember how slow binary FP emulation was?).
Note that this library could be implemented in assembly on those
platforms that have hardware support, so you don't really even need
native C support for decimal floating point in order to get the
faster computations. Of course, using such a library is inconvenient
compared to having native C support, but that inconvenience is payed
only by those who need this capability. Is that group of people
large enough that inconveniencing them justifies changing the
language?


Of course; C is the 'assembly language' on which the vast
majority of other languages are based and in which they are
implemented. It is the very foundation of software; without
access to the hardware primitive types in C, every other
language has to provide it from scratch, in a platform-
dependent way.

Mike Cowlishaw
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #596
Eric Backus wrote:
....
for decimal floating point in order to get the faster computations. Of
course, using such a library is inconvenient compared to having native C
support, but that inconvenience is payed only by those who need this
capability. Is that group of people large enough that inconveniencing them
justifies changing the language?


That group of people is large enough that someone has started building
hardware solutions to meet their needs. I suspect that's means the group
is large enough.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #597
In comp.lang.c.mod erated James Kuyper <ku****@saicmod is.com> wrote:
Hans-Bernhard Broeker wrote:
...
designers who effectively did that. I'm not aware of any architecture
in active use right now that has FLT_RADIX != 2. In fact, there seems
P.J. Plauger has already mentioned the S/370, which had FLT_RADIX==16,
as well as a few less common machines where FLT_RADIX==10, as being the
driving factors behind allowing FLT_RADIX!=2 in C99.


Wrong citation, I think. Those fact were the rationale for having
FLT_RADIX != 2 in _C90_. C99 didn't change that. Instead it did put
a much heavier weight on FLT_RADIX==2 architectures by devoting a lot
of appendix and standardized optional parts of the library to IEEE 754
support.

I.e., if anything, C99 moved *away* from FLT_RADIX != 2, not towards
it. And that's why I'm concerned about it. People looked at the
current mainstream hardware, and at the impression made by C99, and
are lead to think that all floating point is binary these days.

Anyone who read the famous paper "What every computer scientist should
know about floating point" should be aware that it's not *always*
foolish to rely on the exact behaviour of the lowermost few digits of
a floating-point number. You have to be very careful working with
them, sure, but classifying them as "garbage" unanimously doesn't do
justice to numerical analysis.

--
Hans-Bernhard Broeker (br*****@physik .rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #598
Dan Pop wrote:
In <cl************ ****@plethora.n et> "Mike Cowlishaw" <mf*****@attglo bal.net> writes:
(snip)
PL/I did many things wrong (some of its coercions were/are quite
extraordinary ). But given that it was designed in the 1960s it
actually was a significant step forward in many areas. It
certainly wasn't a failure, and it is still widely used today.

It failed to achieve the goal of its designers: to be the ultimate
programming language. It never achieved the popularity of the languages
it was supposed to render obsolete: FORTRAN and COBOL.


There are reasons for that unrelated to the language itself, such as how
long it took to write the compiler, and how slow it ran on machines that
existed at the time.

It does seem hard to replace an existing language with an improved one.

Not long ago a discussion in another newsgroup related to assembler
programming reminded me of ALP, which is a preprocessor for a certain
assembler that offers free format, structured programming, and some
other features, but it never got popular.

Ratfor, and a few different versions of MORTRAN as Fortran
preprocessors, again with improvements over the original, but never got
very popular.

The original PL/I compiler supplied conversion programs to convert
Fortran, COBOL, and maybe ALGOL to PL/I.

Maybe more relevant here, C++ was an improved version of C, possibly
with the intention of converting C programmers to C++ programmers, yet C
is still reasonably popular.

-- glen
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #599
Brian Inglis wrote:

(snip)
This is a very good idea -- mixing binary, decimal (and hex) FP
formats in a structure or a set of related modules is a very bad idea
-- unless the radix can be detected at the hardware level.
(snip)
Current IBM 390/z compilers and platforms don't appear to support any
mixing of binary and hex FP instructions and functions in the same
code -- Linux supports IEEE functions and requires IEEE instructions
-- native OSes support hex functions and require hex instructions.


Well, the compilers and libraries supported by Linux use IEEE, so any
programs compiled with them will.

The compilers and libraries traditionally supplied with IBM OS's
supported hex because that is all there used to be.

The OS itself doesn't really support any base. The same floating point
registers are used, which the OS will save and restore as appropriate,
without regard to the base currently store in them.

-- glen
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #600

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11266
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL) on the server because of that. Our site will have an SSL certificate next week, so I would like to use AIM instead of SIM, however, I don't know how to send data via POST over https and recieve data from the Authorize.net server over an https...
2
5865
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues to execute the code until the browser send his reply to the header instruction. So an exit(); after each redirection won't hurt at all
3
23053
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which field is completed.
0
8508
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1
1
8621
by: Richard Galli | last post by:
I want viewers to compare state laws on a single subject. Imagine a three-column table with a drop-down box on the top. A viewer selects a state from the list, and that state's text fills the column below. The viewer can select states from the drop down lists above the other two columns as well. If the viewer selects only one, only one column fills. If the viewer selects two states, two columns fill. Etc. I could, if appropriate, have...
4
18317
by: Albert Ahtenberg | last post by:
Hello, I have two questions. 1. When the user presses the back button and returns to a form he filled the form is reseted. How do I leave there the values he inserted? 2. When the user comes back to a page where he had a submitted POST data the browser keeps telling that the data has expired and asks if repost. How to avoid that? I tried registering all POST and GET vars as SESSION vars but
1
6890
by: inderjit S Gabrie | last post by:
Hi all Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url http://www.mis.gla.ac.uk/biquery/training/ but each of the courses held have maximum of 8 people that could be
2
31461
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value to :parameter I dont like the idea of making the SQL statement on the fly without binding parameters as I dont want a highly polluted SQL cache.
3
23617
by: Sandwick | last post by:
I am trying to change the size of a drawing so they are all 3x3. the script below is what i was trying to use to cut it in half ... I get errors. I can display the normal picture but not the results of the picture half the size. The PHP I have installed support 1.62 or higher. And all I would like to do is take and image and make it fit a 3x3. Any suggestions to where I should read or look would be appreciated.
0
9791
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,...
0
11137
Oralloy
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...
1
10844
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9571
agi2029
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...
1
7970
isladogs
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...
0
7122
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5990
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4215
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3231
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.