473,778 Members | 1,934 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 7359
jacob navia wrote, On 09/09/08 09:50:
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.
You don't need to. One of the questions I was asked in my interview for
my current job was why one should not use strtok (or something of the
sort). My honest answer (which I gave) was that I did not know because I
had never used it. What I did not say was that the reason I had never
used it was that I had never done any token parsing in C so I had no
reason to have looked at it. There was a lot more of the C language
(specifically the library) that I did not bare in mind because it was
completely irrelevant to what I was doing, and ignoring it did no harm.

<snip>
"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.
There are more languages than just C and C++. I have also programmed in
Coral 66, Fortran 77, Basic, various assemblers some simper than C some
more complex, Forth (just a bit of playing), Logo (just a bit of
playing), ML (just a bit of learning), Lisp (just a little playing),
Pascal, Delphi, Perl, Java, a scripting language developed by someone I
know, a peculiar interfacing language designed and implemented by me
(which I am still learning the subtleties of), xslt, php (just a little
debugging and dabbling) and probably a few more I can't think of
currently. Often I'm dealing with multiple languages at the same time
and the interactions between them. I have also had to deal with code
written by fresh graduates with no experience, graduates with some
experience, and all the way up to people who have been programming
professionally since the early days of being able to get a job
programming. I've dealt with code written by good programmers and bad.
In my experience the programmer and process have a much greater impact
on the number of errors and how hard they are to find than the language.
Oh, and the hardest to debug has been some of the C code.
--
Flash Gordon
Sep 9 '08 #201
Nick Keighley wrote:
jacob navia <ja...@nospam.c omwrote:
.... snip ...
>
>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;
Many, especially if operator overloading is present. As an
anti-example, consider the Pascal use of DIV for integers and '/'
for reals.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Sep 10 '08 #202
REH wrote:
Ian Collins <ian-n...@hotmail.co mwrote:
>REH wrote:
>>jacob navia <ja...@nospam.c omwrote:
.... snip off-topic junk ...
>
Um, no I am not. I don't need to ask. I've been writing C++
code before it even had a standard.
The C++ newsgroup is, surprise, named comp.lang.c++. This is
comp.lang.c, and C++ is off topic.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home .att.net>
Try the download section.
Sep 10 '08 #203
jacob navia wrote:
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.
Which is how C++ does them, now there's an interesting contradiction!

--
Ian Collins.
Sep 10 '08 #204
CBFalconer wrote:
REH wrote:
>Ian Collins <ian-n...@hotmail.co mwrote:
>>REH wrote:
jacob navia <ja...@nospam.c omwrote:
.... snip off-topic junk ...
>Um, no I am not. I don't need to ask. I've been writing C++
code before it even had a standard.

The C++ newsgroup is, surprise, named comp.lang.c++. This is
comp.lang.c, and C++ is off topic.
We had that discussion yesterday.

--
Ian Collins.
Sep 10 '08 #205
Flash Gordon wrote:
Richard wrote, On 09/09/08 11:25:
>jacob navia <ja***@nospam.c omwrites:

<snip>
>>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.

<snip>
>>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?

<snip>

Yes, you are. I agree that operator overloading makes the language (and
particularly reading the code) more complex. This is one reason why I
don't expect operator overloading to ever be added to the C standard. It
is too controversial.
You are saying that
q = divide(add(b,c) ,multiply(b,c)) ;
is simpler to read than
q = (b+c)/(b*c);

This is why many languages use operator overloading!
It is much simpler to read and use.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 10 '08 #206

"jacob navia" <ja***@nospam.c omwrote in message
news:ga******** **@aioe.org...
Flash Gordon wrote:
>Richard wrote, On 09/09/08 11:25:
>>jacob navia <ja***@nospam.c omwrites:

<snip>
>>>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.

<snip>
>>>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?

<snip>

Yes, you are. I agree that operator overloading makes the language (and
particularly reading the code) more complex. This is one reason why I
don't expect operator overloading to ever be added to the C standard. It
is too controversial.

You are saying that
q = divide(add(b,c) ,multiply(b,c)) ;
is simpler to read than
q = (b+c)/(b*c);
Where b,c,q are clearly numeric types, then q=(b+c)/(b*c) is more intuitive.

The point is that operator overloads could be applied to /any/ user-types,
where b+c is not intuitive at all.

Neither would add(b,c) be, but now you can go and look at function add().
And in this case, if you are not using function overloading, you woudn't
call it add(), but something more apt. Then the function form could be
clearer to read even without looking at the source.

Anyway where an add() function returns objects using heap storage, this
requires extra effort and skill by whoever is writing the overload functions
to take care of memory. So being able to write a=b+c syntactically is only
half the work.
>
This is why many languages use operator overloading!
It is much simpler to read and use.
No, the end-result is much simpler to read and use, when appropriate. It's
the /mechanisms/ for making it possible that make the language complex.

--
Bartc

Sep 10 '08 #207
jacob navia wrote, On 10/09/08 07:53:
Flash Gordon wrote:
>Richard wrote, On 09/09/08 11:25:
>>jacob navia <ja***@nospam.c omwrites:

<snip>
>>>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.

<snip>
>>>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?

<snip>

Yes, you are. I agree that operator overloading makes the language
(and particularly reading the code) more complex. This is one reason
why I don't expect operator overloading to ever be added to the C
standard. It is too controversial.

You are saying that
q = divide(add(b,c) ,multiply(b,c)) ;
Here you always know that you are calling three user defined functions.
is simpler to read than
q = (b+c)/(b*c);
Without operator overloading here you know you are *not* calling and
user defined functions and something about the types. If, on the other
hand, you have operator overloading you don't know whether or not you
are calling user defined functions (or which ones) without checking the
types of all of the variables and whether the operators have been
overloaded.
This is why many languages use operator overloading!
It is much simpler to read and use.
It can make some things easier to write, and with sufficient discipline
it can be very useful. However, in general you don't know whether
sufficient discipline has been used. With operator overloading tell me
what the following line does...

count = a - b;


Bet you got it wrong, a and b are set types, - is overloaded to provide
the intersection, and = is overloaded so that if the left operand is an
integer types and the right a set type it assigns the cardinality of the
set to the left operand. So count will be the number of elements in both
a and b.

Now, is the following easier to read?

count = card(intersect( a,b));
--
Flash Gordon
Sep 10 '08 #208
Flash Gordon <sp**@flash-gordon.me.ukwri tes:
jacob navia wrote, On 10/09/08 07:53:
[...]
>You are saying that
q = divide(add(b,c) ,multiply(b,c)) ;

Here you always know that you are calling three user defined functions.
>is simpler to read than
q = (b+c)/(b*c);

Without operator overloading here you know you are *not* calling and
user defined functions and something about the types. If, on the other
hand, you have operator overloading you don't know whether or not you
are calling user defined functions (or which ones) without checking
the types of all of the variables and whether the operators have been
overloaded.
Which means that operator overloading should (ideally) be used only
when not knowing whether you're calling user-defined functions doesn't
make it more difficult to understand the code.

If you happen to know that q, b, and c are of some type(s) other than
those for which those operators are built-in, then you know that at
least "+", "/", and "*" are overloaded operators (i.e., user-defined
functions). And if you don't know that, then you're probably not
going to understand the code anyway.

In real code, you'd use better names that q, b, and c (they're ok for
a short example like this, but not for real code). Even without
operator overloading, I have very little idea what
q = (b+c)/(b*c);
is supposed to do.
>This is why many languages use operator overloading!
It is much simpler to read and use.

It can make some things easier to write, and with sufficient
discipline it can be very useful. However, in general you don't know
whether sufficient discipline has been used.
Agreed. I've used operator overloading myself, and I don't recall
running into serious problems with it; perhaps I've been lucky.
With operator overloading
tell me what the following line does...

count = a - b;


Bet you got it wrong, a and b are set types, - is overloaded to
provide the intersection, and = is overloaded so that if the left
operand is an integer types and the right a set type it assigns the
cardinality of the set to the left operand. So count will be the
number of elements in both a and b.
Overloading "-" to denote set intersection is a bad idea; it's like
writing an ordinary function to compute a set intersection and calling
it "difference ". I think "*" is sometimes used -- and that's ok if
your intended audience understands that "*" means set intersection.
Now, is the following easier to read?

count = card(intersect( a,b));
Maybe.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 10 '08 #209
Flash Gordon wrote:
jacob navia wrote, On 10/09/08 07:53:
>You are saying that
q = divide(add(b,c) ,multiply(b,c)) ;

Here you always know that you are calling three user defined functions.
>is simpler to read than
q = (b+c)/(b*c);

Without operator overloading here you know you are *not* calling and
user defined functions and something about the types. If, on the other
hand, you have operator overloading you don't know whether or not you
are calling user defined functions (or which ones) without checking the
types of all of the variables and whether the operators have been
overloaded.
This is just not true. If you are working in a 16 bit machine
and you are doing a long divide in 32 bits you call a
function. If you are in a 32 bit machine and you are doing
a 64 bit divide you call a function too. I know because I wrote
those functions and they are messy :-)
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 10 '08 #210

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
5672
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
3790
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
9629
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
10296
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
10127
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
8954
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
6723
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
5370
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...
0
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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
3627
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.