473,903 Members | 3,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Choosing Perl/Python for my particular niche

Hello,

This is not a troll posting, and I've refrained from
asking because I've seen similar threads get all
nitter-nattery. But I really want to make a decision
on how best to invest my time. I'm not interested on
which language is better in *general*, just for my
purpose. My area of research is in CAD algorithms,
and I'm sensing the need to resort to something more
expedient than C++, bash scripting, or sed scripting.
What I hope to do is a bit multifaceted. What I don't
do dabble in is web apps (though I'm not sure of the
similarities). No XML processing or database
interaction in what I do.

One thing I expect to have to do is to modify design
files. For example, there is a tool which takes ASCII
hardware desscription language (HDL) and converts it
to a C++ (augmented by hardware simulation library).
The translator is freeware, so has limitations which I
have to make up for by tweaking the HDL code. In the
past, I've eeked out sed scripts for such tasks, but
would appreciate a more traditional language. Since
Perl is used alot in digital IC design, I took a stab
at that, motivated by the simple need to convert my
mail aliases from one mail reader to the other. It
took a while to do, and I'm concerned at the difficulty
level. If I did this kind of thing constantly, I
would probably get proficient and use the power behind
it, but it's not my main area.

The alternative is Python, which is easier to read
from what I've read. My concern there is that I cut
myself off from large availability of stuff that's
out there. For example, I use a PC-to-solaris
viewer called VNC, and I've banged my head against the
startup script to change it a bit for my situation.
Likewise, the above translator uses Perl extensively
in its operation, as well as it's building and
installation. If I wasn't passingly familiar with
Perl, I would have had a much harder time installing
it. Being in the approximate area digit circuits,
I'm concerned about being on the band wagon, if only
to avoid reinventing things, or impediments to sharing
things.

An additional usage scenario is to (if reasonable)
replace my shell scripting e.g. I just converted to
bash from tcsh to write scripts that push a document
through a series of filters, or simply as a wrapper
around a tough-to-use utility e.g. pstops. A final
example is to take a file of design information and
do more than tweak it e.g. extract all the information
about interconnection s between circuit building blocks,
including which is the source block, and which are the
destination blocks. Typically, this information will
be read by matlab scripts and passed to my C++ code
(I've managed to avoid writing code to parse the
input file from C++).

Whichever way I go, I would like to avoid the overhead
of learning both Perl and Python. I will sculpt out some
time in a miserly fashion to slowly get to know one. Since
I spend most of my time exploring the algorithm in Matlab or
C++/STL, there's only so much time to pick up higher level
languages (it took years before I shelled out the time
to switch from tcsh to bash). One of the things that
makes the decision not clear is that despite Python's
claim to a gentler learning curve and clearer code, I
often like the expedience of sed e.g. a terse one-liner
that can be pipelined with other shell commands. I
also note that Perl's unweldiness only comes for big
projects, and I don't expect to using Perl quite that
way.

I've seen mention of parrot and perl6, which is quite a
ways off. I'm not sure how much that should weigh into
my decision, since it isn't real yet.

Thanks for any comments/suggestions.
--
Fred Ma
Dept. of Electronics, Carleton University
1125 Colonel By Drive, Ottawa, Ontario
Canada, K1S 5B6
Jul 18 '05
42 4147
In article <40************ ***@doe.carleto n.ca>,
Fred Ma <fm*@doe.carlet on.ca> wrote:
Just wanted to add another example of stuff that
I encounter alot of. As in many computer languages,
various kinds of scopes are delineated by things
like braces or begin/end statements. I often find
it valuable to find an occurance of certain things
(e.g. certain data declaration) within certain
scope structures. Sed is convenient for that:

/SomeStartPatter n/,/SomeEndPattern/{
Do some stuff,
including conditional branching
}

To avoid the hassle of writing a script file and
filtering the input source file to an output source
file, I often use gvim's awesome pattern matching
and macro recording abilities. A sed script file
can look pretty cryptic, especially when I want
to search across physical lines (lots of conditional
flow to append things to the hold buffer, etc..).
For that reason, I tend to stay with quick/dirty
practices in gvim. Crypticness (though not of the
same variety) is one of the things that I found
hard about ramping up on Perl, to the degree that
I did. As I hinted earlier, a fair comparison would
account for the fact that its power would be more
apparent if I became adequately guru-like, but
realisticall y, I will not spend enough time with
it on a regular basis to expect that. Here again
is a dichotomy; I appreciate the sed terseness because
I can make a command line pipe stage out of it, but
the same brevity in a scripting language can make for
rough going. Maybe it's wishful thinking to expect
one language to cover all the bases that I initially
mentioned.

Jul 18 '05 #11
Quoth cl****@lairds.c om (Cameron Laird):
....
| I *really* don't know how to respond to this; a
| sentence with "sed", "conditiona l" and "convenient "
| leaves me at a loss.

I personally find sed more frustrating than useful, for anything
past the common one-line application. But I know of a very
accomplished sed programmer for whom it's the other way around -
not only can he solve complex problems in sed, he once professed
to be baffled by the common structured-procedural languages.
I reckon him to be a person of extraordinary intellect, because
of his exceptional ability with sed, but he was pretty firmly
convinced that he couldn't do much with a programming language
like C or Python. Of course not a programmer by trade. I believe
he never did go on to prove himself wrong on that.

In my opinion, it's a matter of very deep learning about how to
solve problems. Most of us were introduced to programming with
procedural languages - BASIC, assembler, Pascal, FORTRAN and so
on, which for all their differences are essentially the same in
principle when it comes to solving a problem. We can move from
one of these languages to another fairly easily, but not sed -
what's the point of such a useless language! But here are these
few, mostly non-programmers, who started with sed and can do
amazing things with it. We see a crippling lack of features,
where they see spartan elegance, because at a very fundamental
level they get it and we don't.

Donn Cave, do**@drizzle.co m
Jul 18 '05 #12
Cameron Laird wrote:
In article <40************ ***@doe.carleto n.ca>, My current instinct is that you'll be happiest with Perl--
but it's a close choice, all around. I'm most accomplished
in Tcl, and would happily use it, or Perl, or Python. It
seems to me, though, that it's crucial that you be able
to exploit libraries that pertain to your domain, and, in
particular, optimized engines for linear algebra, graph
theory, and linear and mathematical programming. Tcl
lacks the weight that Perl and, to an increasing extent,
Python can boast in their libraries.

Since you happily use Perl, Python or Tcl, I have a question. How do you
decided which one to use? :-)

Robert
Jul 18 '05 #13
In article <1080406261.496 998@yasure>, Donn Cave <do**@drizzle.c om> wrote:
Jul 18 '05 #14
In article <kJ************ ********@adelph ia.com>,
zatoichi <ca*****@linuxm ail.org> wrote:
Cameron Laird wrote:
In article <40************ ***@doe.carleto n.ca>,

My current instinct is that you'll be happiest with Perl--
but it's a close choice, all around. I'm most accomplished
in Tcl, and would happily use it, or Perl, or Python. It
seems to me, though, that it's crucial that you be able
to exploit libraries that pertain to your domain, and, in
particular, optimized engines for linear algebra, graph
theory, and linear and mathematical programming. Tcl
lacks the weight that Perl and, to an increasing extent,
Python can boast in their libraries.

Since you happily use Perl, Python or Tcl, I have a question. How do you
decided which one to use? :-)

Robert


Most often, whatever is already at hand. It'll be interesting
some day to come across an organization that doesn't already
have a standard in place.
--

Cameron Laird <cl****@phaseit .net>
Business: http://www.Phaseit.net
Jul 18 '05 #15
Also sprach Cameron Laird:
I generally favor Python over Perl; in the absence of
more details, I think there's mild evidence that those
who don't specialize in programming are happier over the
long term with the readability of the former. They're
very close, though. The one most certain advantage
Python boasts is a dimension that I'd think important
to you, although you haven't mentioned it: Python's
interfaces to C++ are MUCH easier to manage than Perl's.
Perl6 will change this. For now, though, it's FAR
easier to practice "dual-level programming" with Python
and C++. If you have a large existing library of C++
work, I think that tips the balance toward Python.
Understand, SWIG and other alternatives make Perl-to-C++
links possible; with Python's facilities, though,
including Pyrex, they're *fun*.


When it comes to embedding C/C++ into Perl, SWIG is the last thing that
I'd recommend. It may be capable of transforming such a library into a
Perl module on its own with no user intervention. However, C/C++ doesn't
map particularly well onto Perl from an interface point-of-view: A 1:1
translation of a C++ API doesn't look particularly good.

Those things should be done manually. How much work this is depends on
the library. Some only require a few lines of XS. XS' learning curve is
admittedly a bit steep. Not because it is difficult in itself but rather
because the documentation leaves a few things to be desired. There are
some actions on completing perlxstut.pod on its way right now, though.

There is also Inline::CPP, although I don't think it is as mature as
Inline::C. And since you have mentioned Tcl, even that can be inlined
with the help of Inline::Tcl.

Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_ $;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus}) (rekcah{lrePbus })(lreP{rehtona bus})!JAPH!qq(r ehtona{tsuJbus# ;
$_=reverse,s+(? <=sub).+q#q!'"q q.\t$&."'!#+sex isexiixesixeseg ;y~\n~~dddd;eva l
Jul 18 '05 #16
In article <c4**********@n ets3.rz.RWTH-Aachen.DE>,
Tassilo v. Parseval <ta************ **@post.rwth-aachen.de> wrote:
Jul 18 '05 #17

"Tassilo v. Parseval" wrote:

Also sprach Fred Ma:
No XML processing or database interaction in what I do.
Who knows, though. The desire to do certain things grows with the skills one
acquired.


You might be right. Some digital CAD data is stored in XML.
This is a strong reason to use Perl. While it may not always be desirable to
toe the line, here it is. The availability of tools that can easily be
integrated into one's own work will save you a lot of work on the long run. I
didn't know that Perl was particularly strong in the field of IC design. If
so, good then.

Apart from this particular case, it's generally a good thing when pre-written
code exists that can be used. The amount of such code for Perl is immense
(several thousand libraries) and gathered all in one place (the CPAN) with a
unified interface to access and install them and a vast infrastructure built
around it.

I don't know how much or whether at all the situation for Python has
significantly improved over the recent past. A while ago at least there was no
such thing.
SNIP
As with text processing, both Python and Perl offer all the essential things
needed for that. On a cursory glance, the score of them is tied.

Perl wins when it comes to one-liners and maybe replacing shell scripts. As I
tend to forget the syntax of bash's scripting language easily, I've replaced
it entirely with Perl.

Perl's bad reputation for big projects is probably due to the variance of
those people using Perl. One large group is sys-admins who use Perl in an
entirely different way as compared to someone building larger systems.
However, there are enough very large Perl projects that show that it can be
used for that just as easily (at least as long as one keeps the sys-admins
away from the source;-).
I've seen mention of parrot and perl6, which is quite a ways off. I'm not
sure how much that should weigh into my decision, since it isn't real yet.


It shouldn't. Perl6 is mostly yet another leap towards fitness for large
projects. I don't think it will gain much for those more hackish tasks. Also,
no one quite knows when Perl6 will be due.

Thanks for the commentary on Perl, for clarifying the source of unweldiness in
big Perl projects, as well as its nonuniversality .

Fred
Jul 18 '05 #18
In article <40************ ***@doe.carleto n.ca>, Fred Ma says...
One thing I expect to have to do is to modify design
files. For example, there is a tool which takes ASCII
hardware desscription language (HDL) and converts it
to a C++ (augmented by hardware simulation library).
The translator is freeware, so has limitations which I
have to make up for by tweaking the HDL code.


The translator, is it doing the Verilog stuff you mention later in the thread?
Why not check if you can't replace the translator altogether with an existing
Perl module:
http://search.cpan.org/search?query=verilog&mode=all

Well, I know nothing about your problem area, but it's a tip in case you hadn't
thought about checking CPAN.
Petri

Jul 18 '05 #19
Hi Fred,
If there are particular C/C++ packages of algorithms that you use then
you might try searching for the package name +python on the web. You
might find someone who has already turned the library into aPython
module.

There are several Scientific libraries for Python that have good
graphing capabilities as well as speed advantages for certain
operations. - Try installing the Enthought Python distribution for
windows at: http://www.enthought.com/python/

Another good page is ScriptEDA:
http://www-cad.eecs.berkeley.edu/~pinhong/scriptEDA/ - I was using the
gate-level verilog parser a month ago.

On Scripting language choice, I find TCL to be in many EDA tools, but
its datastructures and syntax make it a language I use when I have
to, rather than a language of choice.

Perl IS used a lot in EDA but I like to think of it as being dangerous
in a lot of hands as great Engineers start scripting larger and larger
applications in Perl and usually end up with something that is hard to
maintain and hard to write. Perl does have its sweet spot - I do like
the `perl -p -i -e` mewthod of making sed like alterations to files
in-place, butthe languages support for subroutine arguments - compared
to Pythons; and the need to compute and pass around references to
lists and hashes for simple nested datastructures - things like that
shout small programs only to me.

Python is my language of choice for a large amount of programming in
the EDA field (when given the choince :-).

Perl has a large library, Python has a large library - what you need
to do is do some web searches for libraries in your field to see which
is more appropriate -

When I have to write an algorithm from scratch then I do it in Python.
It does get out of the way and allow me to concentrate on the
algorithm most of the time. (Although I wish it had constrained random
generation of integers like Vera or Specman :-).

I hope I've helped, Paddy.
Jul 18 '05 #20

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

Similar topics

14
2500
by: Tuang | last post by:
Does anyone (esp. Alex, if you're listening) know if there is an update of Python in a Nutshell coming for Python 2.4?
0
2271
by: Xah Lee | last post by:
One-Liner Loop in Functional Style Xah Lee, 200510 Today we show a example of a loop done as a one-liner of Functional Programing style. Suppose you have a list of file full paths of images: /Users/t/t4/oh/DSCN2059m-s.jpg
15
4315
by: Birahim FALL | last post by:
Hi, I'm very fresh to PostgreSQL, coming from Oracle. I want to developp web applications based on apache and postgresql. Is there an equivalent of OWA server (Oracle Web Application server) for postgresql. Shortly, OWA provides an apache module and a set of stored procedures/functions that generate html pages. A simple example could be the following procedure :
38
2694
by: ifti_crazy | last post by:
I am VB6 programmer and wants to start new programming language but i am unable to deciced. i have read about Python, Ruby and Visual C++. but i want to go through with GUI based programming language like VB.net so will you please guide me which GUI based language has worth with complete OOPS Characteristics will wait for the answer
28
1939
by: Rico Secada | last post by:
Hi. First let me start by saying, please don't let this become a flame-thing. Second, I need some advice. I am a 35 year old programmer, who program in C/C++, PHP and Bourne Shell almost daily.
0
9847
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
11282
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
10500
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
9684
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...
1
8048
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
6088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4726
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
4308
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3324
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.