473,883 Members | 1,596 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 23893
"Eric Backus" <er*********@al um.mit.edu> wrote:
B. Don't forget Moore's law. It'll be at least, say, 5 years before you
could expect to have decimal floating-point in the C standard. By then,
computer hardware will be an order of magnitude faster, so even if decimal
math is the bottleneck in a real application today, it may not be by then.


Alas, Moore's law applies to people's expectations of computers, as
well. If by that time decimal FP is as fast as binary FP now, but slower
than binary FP then, that will still be perceived as too slow.

Richard
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #551
la************@ eds.com wrote:
In comp.std.c Morris Dovey <mr*****@iedu.c om> wrote:
[1] Assuming the standard were changed to include FP-10, will the
compiler producers consider the new standard non-relevant, given
that it covers hardware not now available anywhere in the world?


The standard could be changed to accomodate FP-10 without requiring it.
I sincerely doubt that the standard would mandate FP-10 without a broad
concensus among both users and implementors that that was the right
thing to do.


Moreover, this does not necessarily have anything to do with the
commonness of decimal FP hardware. The C Standard supported FP in
general at a time when many PCs were sold with no FP processor, and
co-processors, emulators and emulation-code-producing compilers were
common.
The only important thing is that decimal FP is seen as important to
_have_, not necessarily to have at high speed - those computers where
decimal speed is of the essence will already have hardware for it (if
only to accomodate things like Cobol), and the rest of us will catch up
later, as we have with normal FP.

Richard
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #552
To add to Francis Glassborow's excellent reply:
[4] Would the application needs be met by a simpler, more direct
approach? If rounding is a problem, for example, could not logic
be added to current (FP-2,FP-16) FPUs to produce the desired
behaviors?


No, because it is a mathematical impossibility to produce the
desired behavior (other than by using the BFP numbers as
integers, and handling the exponent separately).

See examples at google: decimal arithmetic FAQ

One could, possibly, build a dual unit which can switch the
base for calculation -- but it would be unlikely to be an
optimal design (for example, for BFP it's best if the
coefficient is a binary integer; for decimal it's better to have
a decimal coefficient (e.g., in BCD).

However, it is certainly possible to share the FP register
file, and that is a significant saving.

Mike Cowlishaw
Google: decimal arithmetic
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #553
Thad Smith <Th*******@acm. org> writes:
C has a mechanism to accommodate many innovative hardware features -- a
library function. This can be used without changing the language.


That works fine for most features, but it kinda sucks for numeric types.
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.

--
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
Nov 13 '05 #554
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.

With decimal floating-point, results remain exact for additions
and multiplications so long as there is sufficient total precision.
And with the IEEE 765R specification, the Inexact flag gets
set, too, if appropriate -- which can be used to detect for
unexpected inexactness.

All in all, floating-point decimal is simpler, easier, and safer than
fixed-point. (And you can use it for all your other
calculations, too, so there is no need for any binary <-->
decimal conversions.)

Mike Cowlishaw
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #555
"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? 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. They neither know nor care that the
underlying (double) precision can range from 56 bits on an old Vax
to a wobbling 53-56 bits on an old S/370 to 53 bits on modern IEEE
machines. Indeed, the better `scientists' write code that doesn't
depend on those last few bits being at all reproducible.

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.

But otherwise, all the new IEEE 754R really does to existing FP
calculations is add wobbly precision to the last couple of bits,
much like the S/370 hexadecimal FP that generations of programmers
survived, often without noticing the underlying problems for math
library writers.
I.e. there really should
be a set of new types and library support for the guaranteed-decimal
FP. Overlaying the existing ones with base-10 ones isn't a viable
alternative, IMHO.


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.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #556
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 ;-)

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 #557
Dan Pop wrote:

In <cl************ ****@plethora.n et> ge***@mail.ocis .net (Gene Wirchenko) writes:
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).


I agree with Dan on this point. The primary argument for BCD is really
about specified rounding and precision, not radix. BCD avoids the base
conversion, but this is fairly efficient at the ranges required for
monetary use.

To make it easier on the programmer I think that fixed point with
specified radix point, a la PL/I, would problem be a better answer, if
you really want decimal. For my embedded work, I would like scaled
fixed point binary, as well.

I'm beginning to think that an appropriate implementation for C is a
preprocessor that converts decimal declarations and arithmetic into
suitable library calls. Hmmm... sounds like a C++ class/template.

Thad
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #558
Hans-Bernhard Broeker wrote:

In comp.lang.c.mod erated Eric Backus <er*********@al um.mit.edu> wrote:
Is IBM really suggesting that new financial programs be written in C?
Let me answer this with another question: Would you prefer that they
forever keep being written in COBOL, instead?


C++? Java? Ada?
I'm all for it, _as_long_as_ it doesn't interfere with existing code.
While I encourage anyone that wants to extend their own compiler with
decimal arithmetic, I am seeing, in the embedded compiler community, the
increasing resistance to follow the Standard with increasingly complex
compilers to support features not usually required by their customers.
Apparently this resistance applies to other platforms as well. Adding
more special purpose features makes the situation worse, IMO.
If you view C as "portable assembler", then C should support as many
aspects of assembler programming as remotely possible.


There are many aspects of assembly programming that aren't supported in
a direct manner in C: carry bit and task swapping are two examples. C
provides macros and supports function libraries. These provide
reasonable support (through customized libraries) for most hardware
features through add-on libraries.

Does the added benefit of compiler-generated inline code for decimal
arithmetic outweigh the costs?

Thad
--
comp.lang.c.mod erated - moderation address: cl**@plethora.n et
Nov 13 '05 #559
"Hans-Bernhard Broeker" <br*****@physik .rwth-aachen.de> wrote in message
news:cl******** ********@pletho ra.net...
In comp.lang.c.mod erated Eric Backus <er*********@al um.mit.edu> wrote:
Is IBM really suggesting that new financial programs be written in C?
Let me answer this with another question: Would you prefer that they
forever keep being written in COBOL, instead?


OK, good point.

why does a low-level language like C need it?


Because it's the common-ground low-level language many other languages
(more precisely: their runtime libraries) are built on top of.


But you don't need built-in primitives to support other languages - a set of
standard decimal-floating-point library calls would suffice. These could
presumably be implemented in assembler on hardware platforms where there is
significant benefit for doing that. Moreover, in C++, a standard
decimal-floating-point class could wrap those calls to create a class that
looks mostly like a built-in primitive.

If you view C as "portable assembler", then C should support as many
aspects of assembler programming as remotely possible.


I don't really buy the portable assembler idea. If it were true, why has
there never been support for interrupts, and interrupt handlers, in C?
Almost any assembly language supports these.
--
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 #560

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...
0
10742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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
5990
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.
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.