473,706 Members | 7,223 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 7259
On 3 Sep, 11:18, Ron Ford <r...@example.i nvalidwrote:
On Wed, 3 Sep 2008 00:23:52 -0700 (PDT), Nick Keighley posted:
On 3 Sep, 07:47, Ron Ford <r...@example.i nvalidwrote:
On Tue, 02 Sep 2008 21:25:09 -0700, Pilcrow posted:
<snip>
Every time time you "reinvent the wheel," you have to have a caller and a
target. *
>I find that crossing syntax avoids weaknesses in given syntaxes.
what does that mean? Is it even english?

Since texans have monopolized vapidity, I'm afraid the answer is yes. *I
can't make the point without posting a syntax which is not c, but that just
reminds me of texans, the not-constitution oil retards.
since this makes no more sense than the bit I tried to get you clarify
I assume you don't actaully want to communicate.

<snip>

--
Nick Keighley
Sep 3 '08 #31
In article <Nduvk.481$Wd.2 23@trnddc01>,
James Kuyper <ja*********@ve rizon.netwrote:
>Pilcrow wrote:
...
>am used to doing with Perl. I ask provocative questions in the attempt
of gaining new knowledge, ...

Asking provocative questions tends, by definition, to provoke negative
reactions. I'd recommend asking interesting questions, rather than
provocative ones.
This is true on Usenet and is Usenet's primary flaw.

It's not true in general (Note: You should probably spend some time with
a dictionary - look up the word "provocativ e") - that is, in real life - but
it is true that anything the least bit off the well-trodden path in a
Usenet posting, just gets people's dander up. The thread then just
turns into a big mess of defensiveness.

Sep 3 '08 #32
In article <4h************ *************** *****@4ax.com>,
Pilcrow <pi*****@pp.inf owrote:
....
>So many people have accused me of having a hidden agenda that I feel I
should declare my agenda explicitly. I am a man who has had a bit of
programming experience, most recently with Perl, who is now trying to
acquire a working knowledge of C, sufficient to do the kinds of things I
am used to doing with Perl. I ask provocative questions in the attempt
of gaining new knowledge, especially as to the resources available to
the C programmer who is trying not to have to reinvent the wheel, but I
seem to have ruffled some feathers, for which I apologize. Please bear
with me, and be patient.

I already have gotten some answers, such as the existence of the
locale.h header file, which I should have noticed before.

I again apologize to all of you, but C, though faster than Perl, seems
to me very constricting. I am still working my way through K&R2, (and
posting some of my solutions on clc-wiki), so maybe there will be an
epiphany soon. I hope so.
Comments:
1) The obvious question is: Why? Others have alluded to this
question as well. The basic fact is that, in the context of
hosted systems, C is a legacy language; I can't see any reason
to do new development in it. People are pretty open about the
fact that, in today's world, C's domain is a) maintaining legacy
code and b) embedded systems.
2) Despite the name, this is not the newsgroup for you. None of the
things that you want to do are "on topic" here. I'm surprised
people haven't been hammering this point a lot harder than they
have. In fact, it can be said that, in general, anything that
you can do in C that is "on topic" here, shouldn't be done in C.
It should be done in a simple scripting language, such as AWK or Perl.

Sep 3 '08 #33
Pilcrow said:
Given that UNIX, including networking, is almost entirely coded in C,
how come so many things are almost impossible in ordinary C?
I don't know of anything computable that isn't computable in ordinary C.
Examples:
Network and internet access,
C allows you to call library functions that provide these features, but
doesn't go so far as to make their provision mandatory. (Otherwise, you
couldn't have a C implementation on a system that didn't have internet
access - and that would be silly.)
access to UNIX interprocess controls and communication,
Unix systems provide this access. Other systems don't. Don't blame the
language for the lack of provision of Unix interprocess communication
functionality on (some) non-Unix systems.
locale determination,
It's not very well-named, but setlocale() has a query option.
EBCDIC/ASCII discrimination, etc.
Well, if those were the only two choices, it would be trivial to determine
between them: if('A' == 65) it's ASCII. But since there are many choices,
why these two in particular?

(As it turns out, very often it doesn't actually matter what character set
you're using.)
Almost all of these are easy in Perl.
That's nice.
Why isn't there a mechanism like
perl modules to allow easy extentions for facilities like these?
There is. It's called "libraries" .

--
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 3 '08 #34
Richard Heathfield wrote:
Pilcrow said:
>Given that UNIX, including networking, is almost entirely coded in C,
how come so many things are almost impossible in ordinary C?

I don't know of anything computable that isn't computable in ordinary C.
>Examples:
Network and internet access,

C allows you to call library functions that provide these features, but
doesn't go so far as to make their provision mandatory. (Otherwise, you
couldn't have a C implementation on a system that didn't have internet
access - and that would be silly.)
Exactly.

There are many implementations of networking, from
Windows sockets, BSD sockets, Netware, USB networking,
Wan, LANs, etc.

To make mandatory the usage of some kind of network would
be a foolish. Besides, you can do things in C that are MUCH
more cumbersome in perl. For instance an ftp transfer in Perl
looks like this:
----------------------------------------------perl
#!/usr/bin/perl -w
require('ftplib .pl');
use strict;
my(@dirList);
ftp::debug('ON' );
ftp::open('ftp. cis.ufl.edu', 'anonymous', 'm******@planet .net') or die($!);
@dirList = ftp::list('pub/perl/faq');
ftp::cwd('/pub/perl/faq');
ftp::binary();
ftp::gets('FAQ. gz');
@dirList = ftp::list();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n") ;
}
@dirList = ftp::dir();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n") ;
}
ftp::debug();
ftp::cwd('/pub/perl/faq');
@dirList = ftp::list();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n") ;
}
----------------------------------------------perl

Using lcc-win the above program looks like this:

----------------------------------------------C (lcc-win)
int returncode = GetFtpUrl("ftp://ftp.cis.ufl.edu/pub/perl/faq","faq");
----------------------------------------------C (lcc-win)
>
Unix systems provide this access. Other systems don't. Don't blame the
language for the lack of provision of Unix interprocess communication
functionality on (some) non-Unix systems.
Exactly. The OP is completely confusing what a computer language is, and
what an operating system is.
>locale determination,

It's not very well-named, but setlocale() has a query option.
>EBCDIC/ASCII discrimination, etc.

Well, if those were the only two choices, it would be trivial to determine
between them: if('A' == 65) it's ASCII. But since there are many choices,
why these two in particular?

(As it turns out, very often it doesn't actually matter what character set
you're using.)
>Almost all of these are easy in Perl.

That's nice.
>Why isn't there a mechanism like
perl modules to allow easy extentions for facilities like these?

There is. It's called "libraries" .
Exactly. C has "modules", and the interface is simple and efficient.
There is an enormous amount of C libraries around.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 3 '08 #35
On Sep 3, 6:07 pm, jacob navia <ja...@nospam.c omwrote:

<snip>
To make mandatory the usage of some kind of network would
be a foolish. Besides, you can do things in C that are MUCH
more cumbersome in perl. For instance an ftp transfer in Perl
looks like this:
----------------------------------------------perl
#!/usr/bin/perl -w
require('ftplib .pl');
use strict;
my(@dirList);
ftp::debug('ON' );
ftp::open('ftp. cis.ufl.edu', 'anonymous', 'medi...@planet .net') or die($!);
@dirList = ftp::list('pub/perl/faq');
ftp::cwd('/pub/perl/faq');
ftp::binary();
ftp::gets('FAQ. gz');
@dirList = ftp::list();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n") ;}

@dirList = ftp::dir();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n") ;}

ftp::debug();
ftp::cwd('/pub/perl/faq');
@dirList = ftp::list();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n") ;}

----------------------------------------------perl

Using lcc-win the above program looks like this:

----------------------------------------------C (lcc-win)
int returncode = GetFtpUrl("ftp://ftp.cis.ufl.edu/pub/perl/faq","faq");
----------------------------------------------C (lcc-win)
And using my implementation of perl, the above program looks like
this:
f()

So what?
Sep 3 '08 #36
jacob navia said:
Kenny McCormack wrote:
<snip>
> People are pretty open about the
fact that, in today's world, C's domain is a) maintaining legacy
code and b) embedded systems.

This is the opinion of many people here, specially the regulars.
It certainly isn't my opinion.
I am really disappointed that you are basically in agreement
with them.
I don't think he is.
I am convinced that C is a language with a future,
Sure.
that can be
modified and improved to fit better the needs of software development
today without losing its inherent simplicity.
The whole C99 experience suggests that the process of changing C will not
be an easy one. That does not in itself mean that the task should not be
attempted, but it is at least a heads-up that Here Be Dragons.
All my posts, and my work building a freely distributable
C99 compiler go in that direction.

I would propose that people that think that C is dead should
keep their opinion and go to other newsgroups.
On the contrary, I would propose that they change their opinion, since
there is no point in holding onto broken opinions.

--
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 3 '08 #37
vi******@gmail. com wrote:
On Sep 3, 6:07 pm, jacob navia <ja...@nospam.c omwrote:

<snip>
>To make mandatory the usage of some kind of network would
be a foolish. Besides, you can do things in C that are MUCH
more cumbersome in perl. For instance an ftp transfer in Perl
looks like this:
----------------------------------------------perl
#!/usr/bin/perl -w
require('ftpli b.pl');
use strict;
my(@dirList) ;
ftp::debug('ON ');
ftp::open('ftp .cis.ufl.edu', 'anonymous', 'medi...@planet .net') or die($!);
@dirList = ftp::list('pub/perl/faq');
ftp::cwd('/pub/perl/faq');
ftp::binary( );
ftp::gets('FAQ .gz');
@dirList = ftp::list();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n" );}

@dirList = ftp::dir();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n" );}

ftp::debug() ;
ftp::cwd('/pub/perl/faq');
@dirList = ftp::list();
print("list of /pub/perl/faq\n");
foreach (@dirList) {
print("\t$_\n" );}

----------------------------------------------perl

Using lcc-win the above program looks like this:

----------------------------------------------C (lcc-win)
int returncode = GetFtpUrl("ftp://ftp.cis.ufl.edu/pub/perl/faq","faq");
----------------------------------------------C (lcc-win)

And using my implementation of perl, the above program looks like
this:
f()

So what?
Then, that proves that in any language, verbosity is a function of the
libraries that you are using!
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 3 '08 #38
jacob navia <ja***@nospam.c omwrites:
Richard Heathfield wrote:
>Pilcrow said:
>>Given that UNIX, including networking, is almost entirely coded in C,
how come so many things are almost impossible in ordinary C?

I don't know of anything computable that isn't computable in ordinary C.
>>Examples:
Network and internet access,

C allows you to call library functions that provide these features,
but doesn't go so far as to make their provision
mandatory. (Otherwise, you couldn't have a C implementation on a
system that didn't have internet access - and that would be silly.)

Exactly.

There are many implementations of networking, from
Windows sockets, BSD sockets, Netware, USB networking,
Wan, LANs, etc.

To make mandatory the usage of some kind of network would
be a foolish. Besides, you can do things in C that are MUCH
more cumbersome in perl. For instance an ftp transfer in Perl
looks like this:
----------------------------------------------perl
<snip bad Perl>
----------------------------------------------perl
No, using the correct module it is two lines.
Using lcc-win the above program looks like this:

----------------------------------------------C (lcc-win)
int returncode = GetFtpUrl("ftp://ftp.cis.ufl.edu/pub/perl/faq","faq");
----------------------------------------------C (lcc-win)
You need at least a #include and a main function as well, no? Your C
program will be no shorter than my Perl one.

These sorts of discussions (about program length) are daft and will
often degenerate into pointless comparisons like this.

But there *is* an important issue here. Perl's modules work well
together because of the dynamic type system, and the fact that Perl
has very flexible containers. Using C, you may be able to find a
great XML parsing library (for example) but it will probably represent
its lists and tables using different types (and access functions) to
all the other libraries you need. This is why Perl is so good at
"gluing" tasks.

This is the elephant in the room as far as C is concerned. Because
there is no agreed way to program a flexible array, a list or a map,
everyone writes their own, or uses a published one that is
incompatible with all the other published ones out there. It is often
a lot of work just to coax two libraries to work together.

--
Ben.
Sep 3 '08 #39
Ben Bacarisse wrote:
But there *is* an important issue here. Perl's modules work well
together because of the dynamic type system, and the fact that Perl
has very flexible containers. Using C, you may be able to find a
great XML parsing library (for example) but it will probably represent
its lists and tables using different types (and access functions) to
all the other libraries you need. This is why Perl is so good at
"gluing" tasks.

This is the elephant in the room as far as C is concerned. Because
there is no agreed way to program a flexible array, a list or a map,
everyone writes their own, or uses a published one that is
incompatible with all the other published ones out there. It is often
a lot of work just to coax two libraries to work together.
That is why I have been insisting that we adopt the operator overloading
feature that would allow using the '[' and ']' notation for general
containers. Then, we could agree that lists/flexible arrays/arrays
and all sequential containers could be accessed with that notation and
code would be compatible.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Sep 3 '08 #40

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

Similar topics

3
6551
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
5663
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
6446
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
17719
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
1664
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
4273
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
3786
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
4270
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
3981
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
8693
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
9281
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
9150
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
9044
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
8986
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
5935
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
4444
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
4707
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2087
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.