473,753 Members | 8,053 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 #1
223 7293
Pilcrow wrote:
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, ...
They are not impossible in "ordinary C", they are impossible in strictly
conforming C. The C that operating systems are written in will make
heavy use of highly non-portable constructs that give access to all of
these things. In some cases, those non-portable constructs will consist
of calls to routines written in assembly language, or in-line assembly
language, but a very large fraction of the system can be written
entirely in non-portable C.
... locale determination, EBCDIC/ASCII discrimination, etc.
I'm not at all clear to me why you think that those can't be performed
in ordinary C. What features are you asking for that aren't provided by
<locale.h>? Perhaps if you described in more detail the desired
functionality I could address the question better.
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?
There are such mechanisms - they are called "header files" and
"libraries" , and together they serve a very similar purpose.
... Isn't
anyone working on this problem? or is it all being left for proprietary
systems?
There's no reasons why the libraries have to be proprietary, though many
certainly are.
Sep 2 '08 #2
Pilcrow wrote:
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?
Should a programming language set standards for all
the application arenas in which it can be used?

--
Eric Sosman
es*****@ieee-dot-org.invalid
Sep 2 '08 #3

Eric Sosman <es*****@ieee-dot-org.invalidwrot e in message
news:2u******** *************** *******@comcast .com...
Pilcrow wrote:
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?

Should a programming language set standards for all
the application arenas in which it can be used?
Sun Microsystems: "YOU BETCHA!!!"

Java, the Esperanto of computer programming languages...

---
William Ernest Reid
Sep 2 '08 #4

Pilcrow <pi*****@pp.inf owrote in message
news:11******** *************** *********@4ax.c om...
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?
I thought "PERL" WAS coded in "C"...

Somebody, many people have worked on this "problem"; for example,
I got a "regex" PERL-like library for free with MY "C" compiler, along
with a bunch of other stuff, including stuff you mention...the only
people who haven't worked on it are those DAMN BEAURUCRATS
IN WASHINGTON!!! (or whever the "C" standards committee met,
and of course, their "portabilit y" yipping lap-dogs here)...

---
William Ernest Reid
Sep 2 '08 #5
On Sep 2, 10:18*am, "Bill Reid" <hormelf...@hap pyhealthy.netwr ote:
Pilcrow <pilc...@pp.inf owrote in message

news:11******** *************** *********@4ax.c om...
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?

I thought "PERL" WAS coded in "C"...

Somebody, many people have worked on this "problem"; for example,
I got a "regex" PERL-like library for free with MY "C" compiler, along
with a bunch of other stuff, including stuff you mention...the only
people who haven't worked on it are those DAMN BEAURUCRATS
IN WASHINGTON!!! *(or whever the "C" standards committee met,
and of course, their "portabilit y" yipping lap-dogs here)...

---
William Ernest Reid
What are we considering "ordinary C?" Are we talking about the
libraries that are distributed with the GNU C library, any C compiler
that is POSIX standard supported, or are we talking about Visual C++?
The beauty of C is that it will run on damn near any piece of hardware
you throw at it. Almost every single platform's operating system is
written in a combination of C and (some form of) assembler. All of
these things that you mentioned are very possible, because frankly,
the language that you mentioned was implemented in C. The foundations
that you are building on were written in C, Pascal and assembler.

But here is the other interesting tidbit. Many languages that make it
easier for programmers to simply create a socket connection with two
lines of code (Python, C# and Java) have C libraries behind them doing
all the dirty work. If you really want to do all of these things in C
then your best bet is to follow a POSIX standard for sockets
(networking) and work strictly with C99 standards. You are almost
guaranteed that your code will run almost anywhere except certain
embedded platforms (and even those now are using POSIX compilers).

I am a firm believer that both C/C++ are portable as long as you have
someone in the background managing the projects. As long as the proper
libraries are used and standards are followed the code should be
relatively easy to port across platforms. But don't take my word for
it: there are many projects available at sourceforge.net that are open
source that can give you examples of a portable C application.
Although take a note: many "C" applications nowadays are essentially a
C++ application.
Sep 2 '08 #6
Bill Reid wrote:
....
IN WASHINGTON!!! (or whever the "C" standards committee met,
As you might expect for an international standards organization, the
meetings of ISO/IEC JTC1/SC22/WG14 are held in a wide variety of
places around the world. Judging from
<http://www.open-std.org/jtc1/sc22/wg14/www/meetings>, it would appear
that they have not met in Washington at any time since at least 1994,
and probably earlier. Since the US member is INCITS J11
<http://www.ncits.org/tc_home/j11.htm>, and that committee's meetings
are co-located with those of WG14, it doesn't look like Washington has
anything to do with this.
Sep 2 '08 #7
On 2 Sep 2008 at 11:48, Pilcrow wrote:
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.
You've spent too much time being brainwashed by the clc regulars.

ALL of these things are possible in C, OF COURSE. And if Official
Standards (peace be upon them) are really important to you, there's this
one you might have heard of: POSIX.

Sep 2 '08 #8
Pilcrow <pi*****@pp.inf owrites:
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?
It depends on what you mean by "ordinary C".

The C language is defined by an ISO standard. (Actually by two
versions of the same ISO standard, since the most recent one has not
yet been widely implemented.) That standard specifically permits
extensions with certain limitations -- and many implementations
provide extensions without those limitations in a non-conforming mode.

If you want to write code that depends only on features defined in the
language standard, then your code will be portable to any conforming C
implementation -- but it won't be able to do networking, interprocess
communication, and so forth.

If you need to use such features, you can. You'll just have to use
some extension (such as POSIX) that's provided by your implementation.
Your program won't be portable to an implementation that doesn't
provide the particular extension(s) you're depending on, and in many
cases your program's behavior won't be defined by the language
standard.

This kind of tradeoff is unavoidable.

C is *designed* to allow writing non-portable code.

The thing is, though, that for most of the extensions you might want
to use, this newsgroup isn't the best place to discuss them. If you
want to ask how to use POSIX, there's comp.unix.progr ammer; for Win32,
there's comp.os.ms-windows.program mer.win32.

Don't confuse the scope of this newsgroup (as agreed upon by most of
the participants) with the scope of C programming.

--
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 2 '08 #9
On Tue, 02 Sep 2008 12:04:38 GMT, James Kuyper <ja*********@ve rizon.net>
wrote:
>Pilcrow wrote:
>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
communicatio n, ...

They are not impossible in "ordinary C", they are impossible in strictly
conforming C. The C that operating systems are written in will make
heavy use of highly non-portable constructs that give access to all of
these things. In some cases, those non-portable constructs will consist
of calls to routines written in assembly language, or in-line assembly
language, but a very large fraction of the system can be written
entirely in non-portable C.
>... locale determination, EBCDIC/ASCII discrimination, etc.

I'm not at all clear to me why you think that those can't be performed
in ordinary C. What features are you asking for that aren't provided by
<locale.h>? Perhaps if you described in more detail the desired
functionalit y I could address the question better.
>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?

There are such mechanisms - they are called "header files" and
"libraries" , and together they serve a very similar purpose.
>... Isn't
anyone working on this problem? or is it all being left for proprietary
systems?

There's no reasons why the libraries have to be proprietary, though many
certainly are.
I am certainly glad to hear that these things are possible. But perhaps
an example of what I mean is appropriate. Last year I had a list of
several hundred addresses in the USA for which I wanted the 5+4 postal
zip codes. Using a standard module, 'WWW::Mechanize ', from CPAN
<http://en.wikipedia.or g/wiki/CPAN>, I was able, in about an hour, to
write a program (or a 'script'), in perl, that would access
<http://zip4.usps.com/zip4/welcome.jsp>, programmaticall y enter each
address, parse the response, extract the zip codes I needed, and update
my list.

The program I wrote is generalized enough to be able to do the same with
any other similar list. This saved me the chore of manually entering
each address into the form on that web page and copying and pasting the
zip code to my list. That chore would have taken several days, since I
am a clumsy typist, and the list, as I have said, has several hundred
entries.

How could I do the same sort of thing using C? Is there a repository of
libraries for C, similar to CPAN for Perl? If not, is anyone working on
it?

I am sure that it is possible, since Perl itself is written in standard
C, or at least GCC.
Sep 2 '08 #10

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

Similar topics

3
6555
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
5670
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
6447
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
1669
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
3787
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
4273
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
9072
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
8896
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
9653
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
9451
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
9421
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,...
1
6869
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
4771
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
3395
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
2284
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.