473,883 Members | 1,725 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
> "C programmer" is always a meaningless term for me. I am a
programmer.
The languages somebody use tells a lot about him. Usually C-programmers are
people
who want to know what exactly is going on behind. they love small things
they love
details. C-progammers are like assembler programmers, but assembler
programmers are the worst (is this the correct term to express more
extremely marked
characteristics of somebody?).
I use three or four different languages on a regular basis.
Me to (c++/c#/java/php)
Sometimes I use others as well for specialized
tasks. I use whichever programming 'paradigm'(s), tools etc.
that I find most suitable for a given task.
Never written a webshop in C or a graphics driver with Java? :-[=]
Seriously i actually programmed once a fully functioning XXO game in a Excel
table using VBS.
I don't know *any*
practicing professionals who only use a single language and/or
programming 'style' or toolset.


It depends. Surely lots of people are only using *one* language regularly,
depending on their work.
for_each() says: Iterate throw all items in this container and you don't
have to say how it should do that.
Isn't that what functional programming is?


Feel free to believe that if you like.


OK, maybe i was wrong about that.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 13 '05 #161

th*@cs.ucr.edu wrote:
[...]
C is pretty much, but not quite, a sublanguage of C++. C programmers
who don't use the non-C++ features of C are programming in C++ whether
they claim to or not. They are restricting themselves to an older,
more established, more easily learned, and more easily implemented
subset of C++. But they are writing in C++ --- non-idiomatic C++, but
C++ nevertheless. AFAIK, a C++ compile is free to generate the same
code for those programs as would a C compiler, so there is no
intrinsic difference in performance.


In C without exceptions (stuff like MS or DEC/HP SEH extensions), all
functions are kinda "throw()". In the current C++ (without mandatory
2-phase EH and with brain-damaged exception specifications instead),
throw() is kinda expensive. So, there is some "intrinsic difference
in performance", I'm afraid.

http://lists.boost.org/MailArchives/boost/msg53807.php
http://lists.boost.org/MailArchives/boost/msg53808.php
http://lists.boost.org/MailArchives/boost/msg53826.php

regards,
alexander.

P.S. WRT to the last link: "Stack overflow is no problem on *entry*
to a throw() region..." is about explicit throw()-regions apart from
scope cleanup -- I mean {throw()-nothing} dtors... they shall have
implicit throw() ES by default, of course. We just can't retry thier
destruction because objects are gone. Optional stack checking (for
objects that live in throw-something routines) can be done prior to
construction (and, of course, the entire "landing pad" shall to be
protected by MS SEH like "__try/__except(goto_u nexpected()) {}" or
"something like that").

<quote>

LANDING PADS

The runtime transfers control to a landing pad whenever an exception
is thrown from a given call site. The landing pad contains code in
the following order:

- compensation code, restoring program state to what it would be if
optimizations had not been done in the main control flow;

- destructor invocation to destroy any local object that needs to be
destroyed;

- exception switches to select which catch handler, if any, to jump
to (an appropriate switch value is computed by the runtime from
the C++ exceptions table and placed in a temporary register); and

- a landing pad exit, which either returns to a catch block and
moves from there to the main control flow or resumes unwinding if
no appropriate exception handler is found in this subroutine.

<snip>

- If the variable is allocated to a different register in different
sections of code, the landing pad can simply copy that register to
the target register that represents the variable in the exception
handler.

- A value known to be constant that is replaced with the constant
value can be loaded into the appropriate register by the landing
pad, for use by the user code in the exception handler.

- Pending memory operations that have been delayed in the main
control flow can simply be executed in the landing pad should an
exception be thrown. Compensation code therefore lets the compiler
use any of the optimizations that were prevented by simpler table-
driven techniques.

</quote>

regards,
alexander.
Nov 13 '05 #162
"Mike Wahler" <mk******@mkwah ler.net> schrieb im Newsbeitrag
news:TB******** *********@newsr ead4.news.pas.e arthlink.net...
struct data
{
int details;
};

The value 'details' is properly encapsulated inside
the struct type 'data'. This encapsulation could
indeed be corrupted via making coding errors, but
this does *not* mean the encapsulation is 'improper'.
This is no encapsulation. encapsulation means that nobody (except the

class
itself)
can access the variable directly,
or the direct acess is limited to certain
classes for example derived classes or friend classes.


Go ahead and believe that if you like. I'm done trying
to correct your misconceptions.


OK, OK i already learned that in C proper encapsulation is possible.
But i could not know what you mean if you just say:

"struct data{ int details; };
The value 'details' is properly encapsulated inside the struct type 'data' "

That is no encapsulation. Combined with the concept of opaque types, it is.
I already learned that.
You also still seem to be insisting that OO concepts must
be expressed with C++ constructs, which is certainly
untrue. However my example is still valid in that language
anyway. It's not the way I'd actually do it with C++, but
that doesn't mean it's not encapsulation.
You are right. I used to see the concept of OOP only in OOP-languages, which
made
me blind for other approaches implementing OOP.
So you admit that when talking about C, you are talking
about something you don't understand. So why do you
make the claims about it that you have?
I hope to learn.
The existence of the possibility of coding errors does
not preclude a program from being expressed with OOP.
A language's enforcements of OOP concepts is a very
useful tool, but need not be present for a program
to be expressed using OOP.

Agreed.
1. Research the terms 'data hiding' and 'interface'.
I know how to hide data with C. but I wonder how a C programmer would
implement
an Interface.
for_each (myContainer, MultiplicateWit h(2)) /* you just say what is to do you don't care about how it should be done */


1. That does *not* express an invocation of the C++
library function 'for_each()'


for_each(myCont ainer.begin(), myContainer.end (), MultiplicateWit h<2>());

better? (consider MultiplicateWit h as a functor with <int> as template
parameter)
2. A correct invocation of 'for_each' expresses exactly
the same concept as your 'for' example above, only
using different words.
for_each is using iterators, that means the container knows how it can be
traversed.
you only say: iterate through this thing!
3. 'for_each' behavior is not an example of functional programming.


Is it. I googled a bit and found some good results:
Multi Paradigm programming in C++:
http://www.fz-juelich.de/zam/FACT/gl.../glossary.html
http://www.oreillynet.com/pub/a/netw...n.html?page=la
st
--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 13 '05 #163
Alexander Terekhov wrote:
So, there is some "intrinsic difference in performance", I'm afraid.


No.

There is no difference in performance
unless an exception is actually thrown.
But C++ programs that handle exceptions
can be much "fatter" than C (or C++) programs
that don't handle exception.
This doesn't usually make much difference
on modern microprocessors with large code memories.

Nov 13 '05 #164

"E. Robert Tisdale" wrote:

Alexander Terekhov wrote:
So, there is some "intrinsic difference in performance", I'm afraid.


No.

There is no difference in performance
unless an exception is actually thrown.


To begin with, read this:

http://www.computer.org/concurrency/pd2000/p4072abs.htm
("C++ Exception Handling", Christophe de Dinechin,
IEEE Concurrency October-December 2000 (Vol. 8, No. 4))

regards,
alexander.
Nov 13 '05 #165
On Mon, 13 Oct 2003 00:25:37 +0200, in comp.lang.c , "cody"
<do************ *********@gmx.d e> wrote:
I wasn't aware that OOP is so well understood by C-programmers.
This always was a contradiction for me.


Perhaps you should do a websearch for some of the names of the
regulars, or hang out in comp.programmin g for a few weeks. Then
perhaps you'd understand why you are looking like a bit of an idiot
right now. :-) Just because they're posting in CLC doesn't mean that C
is the only language they programme in.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #166
On Mon, 13 Oct 2003 22:00:44 +0200, in comp.lang.c , "cody"
<do************ *********@gmx.d e> wrote:
"C programmer" is always a meaningless term for me. I am a
programmer.
The languages somebody use tells a lot about him. Usually C-programmers are
people who want to know what exactly is going on behind. they love small things
they love details. C-progammers are like assembler programmers, but assembler
programmers are the worst (is this the correct term to express more
extremely marked characteristics of somebody?).


IME people who can programme good C tend to be people who are good
programmers because C, unlike some languages, requires to you to
*think*.
I use three or four different languages on a regular basis.


Me to (c++/c#/java/php)


well, three of those are the same language, with a different name :-0
Seriously i actually programmed once a fully functioning XXO game in a Excel
table using VBS.


This is probably a good example of the wrong choice of language. :-)

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #167
Alexander Terekhov wrote:
E. Robert Tisdale wrote:
Alexander Terekhov wrote:
So, there is some "intrinsic difference in performance", I'm afraid.


No.

There is no difference in performance
unless an exception is actually thrown.


To begin with, read this:

http://www.computer.org/concurrency/pd2000/p4072abs.htm
("C++ Exception Handling", Christophe de Dinechin,
IEEE Concurrency October-December 2000 (Vol. 8, No. 4))


According to Bjarne Stoustrup, "The C++ Programming Language:
Third Edition", Chapter 14 Exception Handling,
Section 8 Exceptions and Efficiency, page 381:

"In principle, exception handling can be implemented so that
there is no run-time overhead when no exception is thrown."

This principle has been realized in practice.

Nov 13 '05 #168
thp
In comp.std.c Alexander Terekhov <te******@web.d e> wrote:
+
+ th*@cs.ucr.edu wrote:
+ [...]
+> C is pretty much, but not quite, a sublanguage of C++. C programmers
+> who don't use the non-C++ features of C are programming in C++ whether
+> they claim to or not. They are restricting themselves to an older,
+> more established, more easily learned, and more easily implemented
+> subset of C++. But they are writing in C++ --- non-idiomatic C++, but
+> C++ nevertheless. AFAIK, a C++ compile is free to generate the same
+> code for those programs as would a C compiler, so there is no
+> intrinsic difference in performance.
+
+ In C without exceptions (stuff like MS or DEC/HP SEH extensions), all
+ functions are kinda "throw()". In the current C++ (without mandatory
+ 2-phase EH and with brain-damaged exception specifications instead),
+ throw() is kinda expensive. So, there is some "intrinsic difference
+ in performance", I'm afraid.

Huh? We're talking about code that is conforming under both C
(perhaps I should specify C89/90) and C++. Are you saying that there
are some such programs for which a C++ compiler must generate code
that is somehow different from what a C compiler would/could generate?

Tom Payne
Nov 13 '05 #169
E. Robert Tisdale wrote:
But C++ programs that handle exceptions
can be much "fatter" than C (or C++) programs
that don't handle exception.


"Fatter" is some sort of technical term here?
Anything to do with "bloat"?

--
Allin Cottrell
Department of Economics
Wake Forest University, NC

Nov 13 '05 #170

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...
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
10410
tracyyun
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...
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
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
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.