473,883 Members | 1,674 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
In message <cl************ ****@plethora.n et>
Fergus Henderson <fj*@cs.mu.oz.a u> wrote:
The problem is that C doesn't have any support for user-defined operators,
operator overloading, or indeed any user-defined infix notation, so
user-defined numeric types feel decidedly like second-class citizens in
comparison with.

E.g. compare

decimal_t x, y, z, a, b, c;
z += x * y * z + a * b * (c - 1);

with

decimal_t x, y, z, a, b, c;
decimal_mult_as sign(&z, decimal_add(
decimal_mult(de cimal_mult(x, y), z),
decimal_mult(de cimal_mult(a, b),
decimal_sub(c, int_to_decimal( 1)))));

The former is a lot more readable.


Which strikes me as a very good argument for using C++. I mean, that's
the language with user defined operators, paramaterised classes and all
that jazz. If one really wants float<2> and float<10> etc, surely C++
is the way to go.

Create an analogue of Annex F for implementations with FLT_RADIX==10 by all
means, but the added complexity of yet another class of base types? The
complex stuff is hairy enough. I've certainly not been able to tackle
implementing any of that yet, and it's not clear that my users have any
particular interest in it. Any base 10 stuff will be similar.

--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1223 503458
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #571
"Dan Pop" <Da*****@cern.c h> wrote in message
news:cl******** ********@pletho ra.net...
In <cl************ ****@plethora.n et> "P.J. Plauger" <pj*@dinkumware .com> writes:
Certainly the proposal accepted by both the C and C++ committees
calls for a parallel set of FP capabilities, but I confess I'm
a long way from being convinced that such added complexity is
either necessary or desirable. I *am* convinced that fleshing
out IEEE 754R decimal FP arithmetic as an alternative representation
for the existing three FP builtin types is quite viable.
Can this be done without changing the current floating point model of the
C standard? IIRC, the IEEE 754R specification goes beyond merely
specifying base 10. Are the other details compatible with the C floating
point model?

From what I've seen so far, and I have studied 754R more than casually,

the answer is yes. 754R adds a few functions that are quite useful
for (possibly denormalized) base 10 arithmetic, but none of those
functions are completely silly when applied to (usually normalized)
binary arithmetic either.

Luckily, we put in C89 the possibility that FLT_RADIX could be other
than 2. Mostly that was to accommodate S/370, which is base 16. But
we also had an eye to a few machines that did decimal floating point
in software. So the basic C model is not severely stressed by 754R.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #572
"Hans-Bernhard Broeker" <br*****@physik .rwth-aachen.de> wrote in message
news:cl******** ********@pletho ra.net...
In comp.lang.c.mod erated P.J. Plauger <pj*@dinkumware .com> wrote:
"Hans-Bernhard Broeker" <br*****@physik .rwth-aachen.de> wrote in message
news:cl******** ********@pletho ra.net...
I'm all for it, _as_long_as_ it doesn't interfere with existing code.
Scientists will insist that behaviour of existing code that does rely
on FP being done in base 2 doesn't change.
You really think so?


Yes. Been there, done that. It was big High-Energy Physics
experiment, with a total project time of more than a decade, and still
counting. Lots of computations go on between the actual raw data
taking and the output of published results. At least 3 generations of
computer hardware were involved over the time the experiment has been
running, and they want to be sure that changing the FPU doesn't affect
the results. Not even minimally. Result was that they decided to
re-configure the Intel FPUs to turn of their "excess" precision.
These guys would be *very* upset if a compiler came out that no longer
supported binary FP.


This is the kind of simplistic thinking I was referring to when I
wrote (and you clipped):

: Perhaps you're thinking of the constituency who think the `right'
: answer is the one that reproduces all the noise digits exactly
: from the original test run. Not much help for them.

I remember when Princeton University upgraded their IBM 7090 to an
IBM 7094, which would trap on a zero divide instead of effectively
dividing by one. After one week of production code bombing regularly,
the user community *demanded* that the divide check trap be left
permanently disabled. They just didn't want to know...

I have trouble stifling the evolution of a programming language
standard to accommodate people who `solve' problems this way.
Most `scientists' I know are content to have their FP calculations
produce results that look more or less reasonable to, say, a dozen
decimal places.


Then may you only know `scientists' (including the quotes), but no
actual scientists.


Uh, I spent most of a decade in cyclotron laboratories while earning
an AB and a PhD in nuclear physics. I worked my way through school
writing computer programs for both theoretical calculations and
data reduction. I've spent a good part of the past 40 years writing
and rewriting math functions that only a small fraction of our
clientele cares much about. Many of them consider themselves
`scientists'. I do too, to the extent they favor rational thinking
over dogma and/or officiousness.
I see no problem adding new features to the language. But the day you
start removing features is when you may be causing real trouble for
people out there.
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.
Actually, if the plan were to just use decimal FP *instead* of the now
common binary FP, there would be nothing for the committee to decide
about, as far as I can see. A platform with FLT_RADIX==10 should be
perfectly compliant right now, as far as I can see. It might enrage
some potential users and steer them away from such a platform, but
that's an economic risk for its vendors to worry about rather than a
concern for the C standardization comittee.
You're mostly correct. The one added piece of work would be to add
the handful of functions recommended by IEEE 754R. I believe those
can and should be overhauled to be useful for floating-point of
*any* base.
The only thing the current standard(s) doesn't support, and thus
requiring an actual committee decision, would be having more than one
FP base available on the same platform, to be used within the same
program. And once you support more two, you have to make essentially
3 substantial decisions:

1) Whether to prescribe which of them is used as good old float,
double & surrounding tools, or leave that to the implementors
2) If so, which one to prescribe.
3) Whether to make support for the known-base types optional or mandatory


Exactly. That's *so* much more work than simply fleshing out good
support for 754R *if present* that it's really worth avoiding, if
at all possible. I want to explore thoroughly the implications of *not*
having Standard C support multiple floating-point formats simultaneously,
before we commit to adding all that complexity to C.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #573
On Wed, 26 Nov 2003 18:57:09 +0000, Dan Pop wrote:
In <cl************ ****@plethora.n et> "Mike Cowlishaw" <mf*****@attglo bal.net> writes:
Dan Pop wrote:
That would be nice, too, but what if you need decimal FLOAT?
What for? Given the intrinsic nature of floating point, if the base is
relevant to your application, then you should review the application.

If the ability of representing $3.11 *exactly* is important, simply
do all your computing in pennies and the base used by your floating
point representation no longer matters (only the precision is relevant).


This does not work, because applications are constantly changing.
Items are often costed in sub-penny decimal units; taxes are now
sometimes specified to 4 or 5 decimal places. The scaling factor
you need to apply, to get exact results, is difficult to work out, and
has to be updated often as the data changes. And if the application
designer or maintainer doesn't allow enough fractional digits, all
of a sudden results become Inexact, with no indication.


This is trivially handled by defining the scaling factor as a macro.
The precision of an IEEE 754 double allows enough space for that, without
limiting the range of precise representations too much for the needs of
the usual financial application.

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?


For that particular calculation you'll have to use the new trinary
arithmetic annex being added to support such things.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #574
P.J. Plauger wrote:
... I want to explore thoroughly the implications of *not*
having Standard C support multiple floating-point formats simultaneously,
before we commit to adding all that complexity to C.


The main implication would be that applications requiring
the properties of decimal f.p. would not be portable to C
implementations that use binary f.p. as the sole flavor
of f.p. (and if there are any depending on the properties
of binary f.p. they would not be portable in the other
direction). It could be that software emulation of the
other flavor of f.p. would be adequate in many cases, and
requiring support would thus enhance portability. We
need to determine a reliable estimate for the number of
applications in this category.

In past committee discussions, reprsentatives of the
numerical analysis community have assured us that there
are important algorithms in use where the exact behavior
of the lowest-order bits significantly affects the
outcome of f.p. computation. Thus that community would
presumably care whether a binary or a decimal radix was
used, and we should get their feedback also.

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.
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #575
In comp.lang.c.mod erated P.J. Plauger <pj*@dinkumware .com> wrote:
"Hans-Bernhard Broeker" <br*****@physik .rwth-aachen.de> wrote in message
news:cl******** ********@pletho ra.net...
[...]
running, and they want to be sure that changing the FPU doesn't affect
the results. Not even minimally. Result was that they decided to
re-configure the Intel FPUs to turn of their "excess" precision.
These guys would be *very* upset if a compiler came out that no longer
supported binary FP. This is the kind of simplistic thinking I was referring to when I
wrote (and you clipped): : Perhaps you're thinking of the constituency who think the `right'
: answer is the one that reproduces all the noise digits exactly
: from the original test run. Not much help for them.
Going over your arguments again, I concede your point. Sorry if I
came across as being mule-headed. Germans from the region of the
country I come from _do_ have a tendency to be quite stubborn...
I remember when Princeton University upgraded their IBM 7090 to an
IBM 7094, which would trap on a zero divide instead of effectively
dividing by one. After one week of production code bombing regularly,
the user community *demanded* that the divide check trap be left
permanently disabled. They just didn't want to know...
Well, the new hardware should have offered to silently return infinity
instead ...
I see no problem adding new features to the language. But the day you
start removing features is when you may be causing real trouble for
people out there.

Who's talking about removing features? Standard C has *never* promised
that floating-point arithmetic will be done in binary.
You're right of course, C never promised that. It's the hardware
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
to be hardly anything else but IEEE 754 (with its extensions) out
there these days.

Given that, programmers did start to rely on this de-facto standard,
and would at least somewhat justifiably be opposed to any change if
that caused extra work for them. Since that change would only come to
them with the next generation of hardware, though, users can still
vote against it with their hardware investments, so no harm done.
And it's damned hard to write a program that can determine whether
it is.
Unless it is allowed to just look up FLT_RADIX in <float.h>, that is ;-)

[...]
Exactly. That's *so* much more work than simply fleshing out good
support for 754R *if present* that it's really worth avoiding, if at
all possible. I want to explore thoroughly the implications of *not*
having Standard C support multiple floating-point formats
simultaneously, before we commit to adding all that complexity to C.


I agree. So the issue boils down to this question:

How likely is a single program going to really need both decimal and
binary FP?

If and only if the answer to that is "essentiall y never", then there's
nothing to do --- let the compiler vendors and platform ABI designers
make the decision on a per-program basis, and thus outside the realm
of standard C.

--
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 #576
Dan Pop wrote:
That would be nice, too, but what if you need decimal FLOAT?
What for? Given the intrinsic nature of floating point, if the
base is
relevant to your application, then you should review the
application.

If the ability of representing $3.11 *exactly* is important, simply
do all your computing in pennies and the base used by your floating
point representation no longer matters (only the precision is
relevant).
This does not work, because applications are constantly changing.
Items are often costed in sub-penny decimal units; taxes are now
sometimes specified to 4 or 5 decimal places. The scaling factor
you need to apply, to get exact results, is difficult to work out,
and
has to be updated often as the data changes. And if the application
designer or maintainer doesn't allow enough fractional digits, all
of a sudden results become Inexact, with no indication.


This is trivially handled by defining the scaling factor as a macro.
The precision of an IEEE 754 double allows enough space for that,
without limiting the range of precise representations too much for
the needs of the usual financial application.


I suggest you try it; it is not trivial at all.
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.

Mike Cowlishaw
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #577
In <cl************ ****@plethora.n et> ge***@mail.ocis .net (Gene Wirchenko) writes:
Da*****@cern.c h (Dan Pop) wrote:
In <cl************ ****@plethora.n et> glen herrmannsfeldt <ga*@ugcs.calte ch.edu> writes:
It may or may not be relevant, but PL/I has supported FLOAT DECIMAL


It is relevant. PL/I was designed to be the ultimate programming
language and it failed big time. Therefore, it should be considered an
excellent example of how NOT to do things ;-)


And you wish to lay that all at the feet of decimal floating
point? PL/I also had semicolons to end statements and a number of
other things that C has.

How about we carefully consider any proposed changes instead,
regardless of whether the features have been used before?


How about *you* carefully consider the meaning of the emoticon ending my
previous post?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #578
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;
}

(Though it's harder to distinguish if more than just the two possibilities,
of course.)

Mike Cowlishaw
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #579
In <cl************ ****@plethora.n et> "Mike Cowlishaw" <mf*****@attglo bal.net> writes:
It may or may not be relevant, but PL/I has supported FLOAT DECIMAL


It is relevant. PL/I was designed to be the ultimate programming
language and it failed big time. Therefore, it should be considered
an excellent example of how NOT to do things ;-)


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.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #580

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
9935
marktang
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...
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,...
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
5797
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4609
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
2
4215
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.