473,789 Members | 2,500 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 7382
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.
Re-reading it, I believe you were confused/mislead by my overly
concise example. I meant to imply x = y[1]; was being used in a
context were y was constant. Obviously, if y is not constant, it would
call the "write" version for both lvalues and rvalues.

REH
Sep 9 '08 #191
REH wrote:
On Sep 9, 1:13 am, Ian Collins <ian-n...@hotmail.co mwrote:
>REH wrote:
>>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++.

Um, no I am not. I don't need to ask. I've been writing C++ code
before it even had a standard.
No, the constness of the object determines which one gets called. Try
it then ask down the hall.

--
Ian Collins.
Sep 9 '08 #192
"jacob navia" <ja***@nospam.c omwrote in message
news:g9******** **@aioe.org...
Flash Gordon wrote:
>>
Are you claiming that C should be used as a general solution to ALL
programming problems?

Obviously Gwyn thinks that C is good for "System programming", where
it is unclear why system programming needs gets() and trigraphs...

You apparently are of the same opinion.

By leaving application programming for other languages, you
effectively destroy C.

Application programming should be done in "evolved" languages
and C should be kept at the level of gets() with a library
conceived in the 70s and still bug-compatible with that
one.
My opinion when I first looked at C a few years ago was that this would be a
great language if you got rid of all the obsolete baggage and brought it
up-to-date. Like a 'C2004' version (as it would have been).

And, perhaps target it at more modern machines. Looking at a table of basic
types like the following (for perhaps C# or D):

char 1 byte 8 bits
short int 2 bytes 16 bits
int 4 bytes 32 bits
long int 8 bytes 64 bits

is somehow very wonderful and refreshing. Finally, you know exactly where
you are! Compare with the woolly approach used in C, which makes it
difficult to code with any confidence.

New C would be simpler and yet could be more powerful. Unfortunately people
creating successors to C don't know where to stop.
I am claiming that C can be used for general application
programming. It needs just a single modification
(operator overloading) and a rewrite of the standard library
to be able to be very useful in application programming.
When I looked at this for one of my languages once (but never implemented; I
found it easier to build any special types and their operators into the
language), I tried this approach:

* Create the code needed for the operations using ordinary functions. The
function names need to be unique, as function overloading is not used.

So far, this does not require anything special in the language, and people
who don't like overloading can use these directly.

THEN, possibly link each of these functions to a standard operator using
some syntactic device, perhaps a pragma:

#pragma registerop "*" (mat,mat) = multiplymat()

This way you can sneak in operator overloading into the language with hardly
anyone noticing.

--
Bartc

Sep 9 '08 #193
REH
On Sep 9, 7:11*am, Ian Collins <ian-n...@hotmail.co mwrote:
REH wrote:
On Sep 9, 1:13 am, Ian Collins <ian-n...@hotmail.co mwrote:
REH wrote:
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++.
Um, no I am not. I don't need to ask. I've been writing C++ code
before it even had a standard.

No, the constness of the object determines which one gets called. *Try
it then ask down the hall.

--
Ian Collins.
Please, read my other response.

REH
Sep 9 '08 #194
On Sep 9, 6:53*am, "Bartc" <bc@freeuk.comw rote:
"jacob navia" <ja***@nospam.c omwrote in message

news:g9******** **@aioe.org...
Flash Gordon wrote:
Are you claiming that C should be used as a general solution to ALL
programming problems?
Obviously Gwyn thinks that C is good for "System programming", where
it is unclear why system programming needs gets() and trigraphs...
You apparently are of the same opinion.
By leaving application programming for other languages, you
effectively destroy C.
Application programming should be done in "evolved" languages
and C should be kept at the level of gets() with a library
conceived in the 70s and still bug-compatible with that
one.

My opinion when I first looked at C a few years ago was that this would be a
great language if you got rid of all the obsolete baggage and brought it
up-to-date. Like a 'C2004' version (as it would have been).

And, perhaps target it at more modern machines. Looking at a table of basic
types like the following (for perhaps C# or D):

char * * * *1 byte * *8 bits
short int * 2 bytes * 16 bits
int * * * * 4 bytes * 32 bits
long int * *8 bytes * 64 bits

is somehow very wonderful and refreshing. Finally, you know exactly where
you are! Compare with the woolly approach used in C, which makes it
difficult to code with any confidence.
char 1 byte 8 bits
int16_t 2 bytes 16 bits
int32_t 4 bytes 32 bits
int_least64_t 8 bytes 64 bits (or more)

;-)

Sebastian

Sep 9 '08 #195
s0****@gmail.co m wrote:
On Sep 9, 6:53 am, "Bartc" <bc@freeuk.comw rote:
....
>Looking at a table
of basic types like the following (for perhaps C# or D):

char 1 byte 8 bits
short int 2 bytes 16 bits
int 4 bytes 32 bits
long int 8 bytes 64 bits

is somehow very wonderful and refreshing.

char 1 byte 8 bits
int16_t 2 bytes 16 bits
int32_t 4 bytes 32 bits
int_least64_t 8 bytes 64 bits (or more)

;-)
Yeah, bolting on this stuff (plus a few dozen other variations) using a
special header in a disputed standard is just as elegant as defining it
clearly once and for all in the core language.

--
Bart

Sep 9 '08 #196
s0****@gmail.co m said:

<snip>
char 1 byte 8 bits
Counter-example: some DSPs have 16 or even 32 bits per byte.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 9 '08 #197
Richard Heathfield <rj*@see.sig.in validwrites:
s0****@gmail.co m said:

<snip>
>char 1 byte 8 bits

Counter-example: some DSPs have 16 or even 32 bits per byte.
And, unless this was disallowed by ANSI, K&R I makes reference to the
Honeywell 9000, which apparently had 9 bits per byte (and an int was
36 bits). Granted, this probably plays into the OP's assertion that
such things are now relics and ought not to be considered anymore.
Sep 9 '08 #198
Nate Eldredge said:
Richard Heathfield <rj*@see.sig.in validwrites:
>s0****@gmail.co m said:

<snip>
>>char 1 byte 8 bits

Counter-example: some DSPs have 16 or even 32 bits per byte.

And, unless this was disallowed by ANSI, K&R I makes reference to the
Honeywell 9000, which apparently had 9 bits per byte (and an int was
36 bits).
It wasn't disallowed by ANSI, no.
Granted, this probably plays into the OP's assertion that
such things are now relics and ought not to be considered anymore.
<shrugSome of the embedded guys consider 8-bit bytes to be relics, too. I
don't let that stop me from writing code that'll work on systems with
8-bit bytes, though.

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Sep 9 '08 #199
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.
--
Flash Gordon
Sep 9 '08 #200

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
9663
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
10195
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
10136
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
9979
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
6765
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
5415
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
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
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
2906
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.