473,789 Members | 3,013 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UNIX, C, Perl

Given that UNIX, including networking, is almost entirely coded in C,
how come so many things are almost impossible in ordinary C? Examples:
Network and internet access, access to UNIX interprocess controls and
communication, locale determination, EBCDIC/ASCII discrimination, etc.

Almost all of these are easy in Perl. Why isn't there a mechanism like
perl modules to allow easy extentions for facilities like these? Isn't
anyone working on this problem? or is it all being left for proprietary
systems?
Sep 2 '08
223 7384
jacob navia wrote:
>
I consider C++ a very complex language where bugs have a lot more
places to hide.
While it is complex, it offers bigger hammers to squash bugs!

Like many new toys, C++ adds the tools to eliminate common C bugs, while
introducing plenty of scope for bugs of its own.

--
Ian Collins.
Sep 9 '08 #181
REH wrote:
On Sep 6, 1:44 pm, jacob navia <ja...@nospam.c omwrote:
>TYPE operator [ ]=(TYPE table, int idx, ELEMENT_TYPE newvalue)
This would apply to

table[idx] = newvalue;

In C++ there is no way to distinguish between those
operations since you just return a pointer.

This is done to support read only data types, what is very hard in C++.

nonsense.

Read:
const TYPE& operator[](std::size_t i) const;

or, if you prefer by value:

TYPE operator[](std::size_t i) const;

Write:
TYPE& operator[](std::size_t i);

x = y[1]; would call the operator with the read prototype.

y[1] = x; would call the operator with the write prototype.
No you are wrong there. Ask why on c.l.c++.

--
Ian Collins.
Sep 9 '08 #182
jacob navia wrote, On 09/09/08 00:14:
Flash Gordon wrote:
>Anand Hariharan wrote, On 08/09/08 16:19:
>>On Sep 4, 6:15 pm, Flash Gordon <s...@flash-gordon.me.ukwro te:
jacob navia wrote, On 04/09/08 00:08:
Because it is a *simple* language. Simple languages are easier to
understan d and use, and have less surface for bugs.
I've seen a lot of bugs in code written in simpler languages.

Could you elaborate? What are the mainstream programming languages
(as in those languages with a reasonable number of programs written
using them) that you consider to be simpler than C?

Depending on your definition of simpler, I have...

Z80 assembler. This is a nice fairly simple assembly language and I've
seen lots of bugs in code written in it. It certainly was mainstream
back when I started using it, and there are a lot of NSC800 processors
(the military equivalent with a few extra built-in peripherals) still
flying around.

Pascal. This is simpler in terms of being in general a higher level
language without OO (which Jacob considers complex, and not without
reason), and I've seen lots of bugs in Pascal.

Choose a definition of simple and I am sure I can find a language I've
used which meets that definition.

I did NOT say that C has no bugs. Read what I wrote again:
Read what I said again. I said "lots".
>>jacob navia wrote, On 04/09/08 00:08:
>>>Simple languages are easier to
>>>understand and use, and have less surface for bugs.

Is that clear to you now?

"Less surface" means that, less surface, not NO bugs but fewer and
easier to find.
My experience is that bugs are just as common and just as good at hiding
in code written in every language I have used.
I consider C++ a very complex language where bugs have a lot more
places to hide.
I don't have enough experience of C++ to comment about that. However, I
do have experience of "simpler" languages than C and my experience is
that the skill level of the people and the quality of the development
process have a far larger impact than the language on the bug count and
the difficulty in finding the bugs.
--
Flash Gordon
Sep 9 '08 #183
On 9 Sep, 00:14, jacob navia <ja...@nospam.c omwrote:
Flash Gordon wrote:
Anand Hariharan wrote, On 08/09/08 16:19:
On Sep 4, 6:15 pm, Flash Gordon <s...@flash-gordon.me.ukwro te:
jacob navia wrote, On 04/09/08 00:08:
>>Because [C] is a *simple* language. Simple languages are easier to
understand and use, and have less surface for bugs.
I dunno. You tend to have to write more code to do things that
a more "complex" language would express in less code.

Consider a C with operator over-loading. This is more both more
expressive and more complex than standard C. :-)

>I've seen a lot of bugs in code written in simpler languages.
Could you elaborate? *What are the mainstream programming languages
(as in those languages with a reasonable number of programs written
using them) that you consider to be simpler than C?
Depending on your definition of simpler, I have...
Z80 assembler. This is a nice fairly simple assembly language and I've
seen lots of bugs in code written in it. It certainly was mainstream
back when I started using it, and there are a lot of NSC800 processors
(the military equivalent with a few extra built-in peripherals) still
flying around.
Pascal. This is simpler in terms of being in general a higher level
language without OO (which Jacob considers complex, and not without
reason), and I've seen lots of bugs in Pascal.
Choose a definition of simple and I am sure I can find a language I've
used which meets that definition.

I did NOT say that C has no bugs. Read what I wrote again:
he didn't say you said...

*>>jacob navia wrote, On 04/09/08 00:08:
*>>>Simple languages are easier to
*>>>understand and use, and have less surface for bugs.

Is that clear to you now?

"Less surface" means that, less surface, not NO bugs but fewer and
easier to find.
um no. Since programming languages don't have surfaces they can't
have "less surface". It's a metaphor and you don't explain a metaphor
by, basically, repeating the metaphor.

One of my pet hates is things like "he was *literally* blown away".
Well
unless he was mishandling explosives, no he wasn't.

I consider C++ a very complex language where bugs have a lot more
places to hide.
how many places can this expression generate an exception?
a = b + c;
--
Nick Keighley

"If you think C++ is not overly complicated, just what is a protected
abstract virtual base pure virtual private destructor, and when
was the last time you needed one?"
-- Tom Cargil, C++ Journal.
Sep 9 '08 #184
Nick Keighley wrote:
Consider a C with operator over-loading. This is more both more
expressive and more complex than standard C. :-)
No, because standard C includes complex numbers. This extension would
make the language *smaller* because complex numbers could
be left *out* of the language itself, making it simpler
yet more powerful.

>"Less surface" means that, less surface, not NO bugs but fewer and
easier to find.

um no. Since programming languages don't have surfaces they can't
have "less surface". It's a metaphor and you don't explain a metaphor
by, basically, repeating the metaphor.
The "surface" of a language is the number of features exposed
to the user at any given time.

When you write in a simple language you can have all the features
of the language in your mind and you can know exactly what are you
doing.

When you write in a complex language, there are so many features
available that it is impossible for you to have all of them
in your mind when writing new code. There are then features that can
provoke bugs that you can't foresee.

>
--
Nick Keighley

"If you think C++ is not overly complicated, just what is a protected
abstract virtual base pure virtual private destructor, and when
was the last time you needed one?"
-- Tom Cargil, C++ Journal.
It is interesting that in your signature you quote a confirmation of
what I am arguing.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 9 '08 #185
Flash Gordon wrote:
I don't have enough experience of C++ to comment about that. However, I
do have experience of "simpler" languages than C and my experience is
that the skill level of the people and the quality of the development
process have a far larger impact than the language on the bug count and
the difficulty in finding the bugs.
The problem with complicated/complex languages is that you just
can't have all the features of the language in your mind when writing
new code.

For instance I said in this same thread that C++ can't differentiate
with the overloaded '[' ']' operator between writing and reading.

Almost immediately, one C++ expert told me that is nonsense and
proposed a solution. The solution looks quite plausible, and nobody
objected (I was just waited).

A day later another expert says that the solution proposed by the
first expert will just not work. He said (to the first expert) that
he should ask in comp.lang.c++ why it doesn't work.

When I asked the same question in the C++ experts group, it took
quite a while until one expert proposed a solution that was
accepted by the others, maybe because involved templates and
was (as always in c++) an atomic bomb to kill a fly.

The problem with a language like that is that the interactions
among the million features are just *beyond* what a human
mind can follow.

The specifications for name lookup when following a class
overloaded operator are pages and pages, involving a
topological sort, etc. It is impossible for a human to
follow all that. Only a machine can have the patience to
do this kind of stuff.

At that point, a language becomes segmented in the programmer's
mind. He/she will concentrate on the features he/she assumes
that have relevance to the problem at hand and ignore the
possible subtle interactions of all the others.

You have to keep in mind that when writing code there are
TWO completely different "computers" involved:

(1): A "biological " computer made of billions of processors that
is NOT designed for programming
(2) a CPU

(1) is designed after around 1 billion years of evolution for
coping with a natural environment, where computers just
do not exist. It has a short attention span and a very
limited short term memory.

"To err is human", and the possibility of introducing errors in a
program increases with the number of features you have to keep
in mind.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 9 '08 #186
On 9 Sep, 09:26, jacob navia <ja...@nospam.c omwrote:
Nick Keighley wrote:
Consider a C with operator over-loading. This is more both more
expressive and more complex than standard C. * :-)

No, because standard C includes complex numbers. This extension would
make the language *smaller* because complex numbers could
be left *out* of the language itself, making it simpler
yet more powerful.
a similar argument could be made for templates in C++
allowing the existence of the STL
<snip>

The "surface" of a language is the number of features exposed
to the user at any given time.

When you write in a simple language you can have all the features
of the language in your mind and you can know exactly what are you
doing.

When you write in a complex language, there are so many features
available that it is impossible for you to have all of them
in your mind when writing new code. There are then features that can
provoke bugs that you can't foresee.
--
Nick Keighley
"If you think C++ is not overly complicated, just what is a protected
*abstract virtual base pure virtual private destructor, and when
*was the last time you needed one?"
* * * * * * * * * *-- Tom Cargil, C++ Journal.

It is interesting that in your signature you quote a confirmation of
what I am arguing.
my sigs are not randomly generated
--
Nick Keighley

why isn't there an obfuscated C++ contest?
Sep 9 '08 #187
jacob navia <ja***@nospam.c omwrites:
Flash Gordon wrote:
>I don't have enough experience of C++ to comment about
that. However, I do have experience of "simpler" languages than C
and my experience is that the skill level of the people and the
quality of the development process have a far larger impact than the
language on the bug count and the difficulty in finding the bugs.

The problem with complicated/complex languages is that you just
can't have all the features of the language in your mind when writing
new code.

For instance I said in this same thread that C++ can't differentiate
with the overloaded '[' ']' operator between writing and reading.

Almost immediately, one C++ expert told me that is nonsense and
proposed a solution. The solution looks quite plausible, and nobody
objected (I was just waited).

A day later another expert says that the solution proposed by the
first expert will just not work. He said (to the first expert) that
he should ask in comp.lang.c++ why it doesn't work.

When I asked the same question in the C++ experts group, it took
quite a while until one expert proposed a solution that was
accepted by the others, maybe because involved templates and
was (as always in c++) an atomic bomb to kill a fly.

The problem with a language like that is that the interactions
among the million features are just *beyond* what a human
mind can follow.
Am I allowed here to say once more - and this is why operator
overloading is nonsense and leads to horrible, unmaintainable code?

I have worked with experts and language lawyers. And all they do is
argue about the cleverest way to do things. And Introducing Operator
Overloading into C will see a huge reduction in the quality and
maintainability of the code bases. Been there done that with C++.- Yes,
I know, "if done properly" - but listen to the experts argue about best
approach and then consider "average Ted" and what he would
do. Nope. Keep them away.
Sep 9 '08 #188
REH
On Sep 9, 1:13*am, Ian Collins <ian-n...@hotmail.co mwrote:
REH wrote:
On Sep 6, 1:44 pm, jacob navia <ja...@nospam.c omwrote:
TYPE operator [ ]=(TYPE table, int idx, ELEMENT_TYPE newvalue)
This would apply to
* * * * table[idx] = newvalue;
In C++ there is no way to distinguish between those
operations since you just return a pointer.
This is done to support read only data types, what is very hard in C++..
nonsense.
Read:
const TYPE& operator[](std::size_t i) const;
or, if you prefer by value:
TYPE operator[](std::size_t i) const;
Write:
TYPE& operator[](std::size_t i);
x = y[1]; would call the operator with the read prototype.
y[1] = x; would call the operator with the write prototype.

No you are wrong there. *Ask why on c.l.c++.

--
Ian Collins.
Um, no I am not. I don't need to ask. I've been writing C++ code
before it even had a standard.

REH
Sep 9 '08 #189
jacob navia wrote:
>
For instance I said in this same thread that C++ can't differentiate
with the overloaded '[' ']' operator between writing and reading.

Almost immediately, one C++ expert told me that is nonsense and
proposed a solution. The solution looks quite plausible, and nobody
objected (I was just waited).
How do you define 'immediately' (almost 2 days) and how do you define
expert?
A day later another expert says that the solution proposed by the
first expert will just not work. He said (to the first expert) that
he should ask in comp.lang.c++ why it doesn't work.
Where else should the so called expert go to find the error of his ways?
Do all C programmers agree all of the time? A day or two here will
answer that.
When I asked the same question in the C++ experts group, it took
quite a while until one expert proposed a solution that was
accepted by the others, maybe because involved templates and
was (as always in c++) an atomic bomb to kill a fly.
Proxies are the idiomatic way to determine read from write. No
templates are required.
The problem with a language like that is that the interactions
among the million features are just *beyond* what a human
mind can follow.
Then use the ones your mind can follow, which is what most programmers
do in most languages. What I do like is a language that can solve
problems (such as determining read from write to an array) without
resorting to language extensions.
At that point, a language becomes segmented in the programmer's
mind. He/she will concentrate on the features he/she assumes
that have relevance to the problem at hand and ignore the
possible subtle interactions of all the others.
So all C programmers use all the dusty corners of the language? Most
programmers work in teams and the collective knowledge of the team helps
the individual's knowledge to grow.

--
Ian Collins.
Sep 9 '08 #190

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

Similar topics

3
6557
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then should run on a Unix box I have. Both scripts run ok, except for the part when Windows try's to call out the Unix script. I have it set up where the Unix is mapped through a drive letter and can drop stuff into the Unix box. It is going through another...
2
5673
by: Mohsin | last post by:
Hi all, I have a perl program which makes a user exit to the O/S (unix, solaris) to issue a O/S command. I know that the shell it invokes is NOT a korn shell, because I captured the shell info into a file with a 'ps' command. My question is "How to explicitly specify a Korn shell to be used by perl?" Eg of my perl code: ## Begin code snippet..
0
6448
by: Danny Jensen | last post by:
I need to test if certain processes on a unix box were running. I wanted to use whatsup gold to do the testing. First I needed to go to the whatsup configure>monitors & services menu to add this tcp/ip port 1555 service with the folowing lines: Send=psef /dj/myco/rf.monitor\r\n Expect=~1 the psef above is a command that the unix server executes. The unix box communicates back a 1 if the test is successful and a 0 if it is
1
17721
by: Al Belden | last post by:
Hi all, I've been working on a problem that I thought might be of interest: I'm trying to replace some korn shell scripts that search source code files with perl scripts to gain certain features such as: More powerful regular expressions available in perl Ability to print out lines before and after matches (gnu grep supports this but is not availble on our Digital Unix and AIX platforms) Make searches case insensitive by default (yes, I...
6
1671
by: asimorio | last post by:
Hi folks, Recently, I am investigatin a memory leak issue. I have written a simple C++ program and a Perl script to test on UNIX environment machine. I do a for loop to new up 20 char of size 32768 bytes, then delete them. Please see below: //// part of the code start //// for (i=0; i<20; i++) { ptrA = new (std::nothrow) char;
2
4275
by: perlnewbie | last post by:
Hi everyone I am new to perl and I am writing a perl script to invoke a set of commands on UNIX clearcase vob however I am having trouble after setting the view and mounting the vob I want to change the directory into the vob and then using Cwd or pwd to confirm I am in the vob to continue the CC functions. Sample code in perl : $Result = system 'cleartool setview admin_view'; $Result = system ('cleartool mount /vobs/test');
4
3792
by: jane007 | last post by:
Hello everybody: I am having a problem. On Unix platform, there is a script that need user to input data from console, then when I call Unix perl script from Windows, these is an issue occurs, when I input data and enter "enter" so fast, the Windows console is freezed, I don't know why, does anybody know?Thank you very much. My code like follows:
4
4274
by: mdshafi01 | last post by:
Hi , I am trying to send mail from unix perl. I am using following code to send mail. It is not triggering mail and also it is not giving any error. please tell me any special settings are required or this program should be executed from special user with higher permission or something. please tell me.
1
3983
by: dxz | last post by:
I have a perl script to run on both UNIX and Windows. How should I write the Shabang line: On UNIX, it is #!/usr/bin/perl On Windows, it is #!C:\perl\bin\perl.exe Which one should I use? Should I combine them? If yes, how?
0
9665
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
9511
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
10408
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
9983
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...
0
9020
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...
0
6768
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
5417
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
4092
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
3697
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.