473,881 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Choosing Perl/Python for my particular niche


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

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

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 4138
In article <40************ ***@doe.carleto n.ca>,
Fred Ma <fm*@doe.carlet on.ca> wrote:
Jul 18 '05 #21
Hi, Paddy,

Wow, there's more information coming in than I expected. Having
a bit of a nonengineering day (at least not at the ground level)
keeping up. I did ask for it.

Paddy McCarthy wrote:

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
Actually, verilator (does verilog to SystemC, which is a C++ library
that provides HDL simulation capability) is a Perl-based module.

As for the glue functionality I need to modify the my original verilog
source, there's no specific functionality. I'm still trying to think
of ways in which to modify to code to work around the translation
limitations of verilator. So the filter will be very much ad-hoc.
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.
Wow. The screen shots on for enthought are impressive. The software at
scriptEDA reminds me that I'm an a newbie in this area. The level to
which interfacing environments and languages have been brought boggles
the mind. I think that I need to take a bite of Perl and/or Python
before I even consider looking at the offerings there with any degree
of appreciation. For the computation engine and post-process/graphing,
I'll stick with C++/matlab for now, due to lack of thesis time, and
because I've got a familiar system (or "idiom"?) setup to use them
together. As I mentioned in another post, I'll start with Perl as
the starting point, and keep tabs on Python, something that is feasible
because of its readability.
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.
I got the same impression, but there have been other explanations given
in this thread for the unweldiness of big projects, as well as the fact
that this is not universal. Myself, I will be using "P..." for glue
functionality, so I won't run the risk of creating dangerously
unmaintainable code (finger crossed here). Besides, it's for the thesis,
which has to be finished soon, so I won't have the problem of looking
back a ways to figure out code written long ago. By the time I get to
an industrial situation (fingers crossed, since jobs are leaving North
America), I hope to have a bit for breathing time to ramp up on Python.
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 -
Well...I did it...verilog to SystemC boils down to verilator unless one
has money to shell out. Despite its professed limitations, I am still
astounded to read even the help pages. That degree of sophistication,
for free. Kind of makes the thesis look like small time, though of
course, the challenges are of a different nature.
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.

A great deal. Thanks.

Jul 18 '05 #22
Cameron Laird wrote:

In article <ro************ ***********@rea der1.panix.com> ,
Roy Smith <ro*@panix.co m> wrote:
2) It's dead simple to embed in a C/C++ application. This is one place
where it really outshines Python. It's literally two lines of C to get
a Tcl interpreter up and running. It's equally trivial to extend Tcl by
providing functions in C. Compare this to the native Python/C
interface, boost.python, or swig, and you really appreciate the

For most general purpose tasks, I reach for Python first. But if I
needed to provide a quick scripting interface to an existing C library,
or wanted to embed some easy scriptability into a large C/C++ app, Tcl
is what I would be looking at.

Me, too, to a large extent. I think you overstate Tcl's
advantage, though, Roy, in a couple of ways. First, I
agree that Tcl is objectively easier and more reliable
in embedding; Python still has blemishes in ease-of-use
and portability in this role. It can be hard getting
all of Python embedded correctly, especially, in my ex-
perience, when working on multiple platforms.

However, Tcl has historically been so easy that it hasn't
bothered documenting the process. Python has a definitive
(if aging) embedding manual that I regard as more inviting
than what Tcl offers.

Also, ctypes, Boost and Pyrex *are* successful, and appear
to me progressing faster than any of their Tcl cousins.

Yet another way to look at the comparison is that a sig-
nificant number of people rely on SWIG, and, to them,
Tcl and Python are indistinguishab le.

Follow-ups narrowed. Most of Perl's response to all of
this is, "Wait 'til 6!"

Thanks, Roy & Cameron, for the glimpse into TCL. I had just
a passing bout with it in trying to use Synopsys's TCL based
shell. It was far too brief to be a fair assessment, since
the documentation wasn't quite up to it, and I fell back to
their conventional shell (which itself was suppose to be
a brief detour to get some design information mulched out
from some verilog files). Certainly didn't get to the level
of using it to interface to C libraries. For the most part,
however, I'll be using "P..." for data conversion rather
than coordination of different library routines. I've got
a pretty good template worked out with matlab on top and
C++ on the bottom. I'll probably stick with this model until
I graduate. I'm looking at "P..." to help with converting
design information from verilog to SystemC (C++ library for
digital hardware simulation) so that I can use it in the
matlab/C++ model, but it won't be part of the main line of

Jul 18 '05 #23
Paul McGuire wrote:

"Fred Ma" <fm*@doe.carlet on.ca> wrote in message
news:40******** *******@doe.car leton.ca...
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.

If you eventually find yourself in the Python realm, please look into the
pyparsing text parsing module, more information at
http://pyparsing.sourceforge.net/. I have implemented an easily-extended
99% Verilog parser using this module, and it may provide some shortcuts for
you in dealing with your HDL files.

-- Paul McGuire

Hi, Paul,

I took a look at your website. I've decided to go Perl for now,
and ramp up on Python on the side. I think a parser has a higher
level of intelligence than regex'ing, but I hesitate to jump into
it at the moment because thesis time is running out. I may do some
adhoc regex'ing, either with sed/Perl/gvim (it's quick and dirty,
but suitable for the time crunch of my current circumstance, which
is a hard deadline on the thesis). Also, I'm doing the quick-and-
dirty because of limitations of an *existing* verilog parser (and
translator) which I don't want to delve into right now, for the
same reason. But thanks for the heads up. If things work out in
the long run, and I get to know Python, I know there is a verilog
parser to keep an eye out for.

Jul 18 '05 #24
Petri wrote:

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:

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


Actually, I was spending much of last week installing many
of those tools! The translater (verilator) is Perl-based,
written by Wilson Snyder (author of many of those tools)
and relies on many of those tools. But thanks for the tip...

Jul 18 '05 #25
Jim Keenan wrote:

You are at Carleton University, which was the site of Yet
Another Perl Conference::Can ada in May 2003. So you have an excellent
pool of local Perl experts to draw upon -- and there are many more not
far away in Montreal, Toronto and Kitchener/Waterloo. Look them up
via http://www.pm.org/groups/north_america.html .

Thanks for the pointer, Jim.

Jul 18 '05 #26
Paul Prescod wrote:

Neither Pyrex nor Inline::C are going to be great for C++. They were
both created by C programmers for C programmers (I'd like to see this
change about Pyrex some day). BOOST::Python, on the other hand, is
probably a good fit.

I just checked out Boost (visited there before based on a pointer
by Scott Meyers, author of a book on the STL). I wasn't quite
prepared to put the time into getting to know libraries at
that time, and I really needed to get to know basic standard
C++ library before delving into expansions of them, but the
example for the python interface looks very cool. My current
use of a "P..." type scripting language, though, wouldn't be to
replace my matlab wrapper around C++ (the main engine until I
graduate). It would be to mulch data to get it in a palatable
form for the engine code. It's good to know about the python
interface, though, for future investigation. Thanks.

Jul 18 '05 #27
cl****@lairds.c om (Cameron Laird) wrote in message news:<10******* ******@corp.sup ernews.com>...
Some scientists are very successful with "slash-and-burn"
techniques. That manifests itself in this area as "con-
science-free" coding: they write whatever programs get
them the results they're after, and don't care that no
one else can reproduce their results, nor can they them-
selves, six months later. A LOT of that goes on.

It makes me uncomfortable. A lesson I've learned over
and over is that computer programs live far longer than
you expect. It pays to do 'em better at the beginning,
'cause you're likely to live with them quite a while.

I'm not a successful scientist, though; odds are long
against me ever being one.

The relation between programming and science is rather complex.
There are still lots of sciences where the programming part is
very minor and the "slash-and-burn" technique is the right thing
to do. For instance, I have worked with very successful scientists
using "slash-and-burn". Their requirements were the following:

1. we want to spend at most 5% of our time doing coding and 95% doing
2. our group is composed by two persons and our code will never be
3. if a Ph. D. student reach the group and has to study the code, we
will explain it to him in person;
4. the largest program we will ever write is a thousand lines long;
for the rest we will use standard routines and write as little code
as possible;
5. we don't care at all about fancy graphics: the output will be a list
of numbers write on a file and displayed by gnuplot;
6. all we care is numerical performance in floating point computations;
the logic of the program will be trivial.

They actually used old fashioned Fortran 77 and I think they made the perfect
choice given their requirements; they essentially had to do numerical
integrations and solving differential equations, tasks were Fortran is
incredibly strong. Other persons I know doing particle Physics and doing a
good deal of programming (good deal means something like 50% of their time
spent on programming; spending more than 50% means that you are actually
a programmer, and scientists don't want to do that) were using a mixture
of Fortran and C. Here I am referring to people doing numerically
intensive tasks; I have seen a trend to switch to C++ for large projects,
since there is a perception than C++ scales better than Fortran. In
any case, the core routines are still in Fortran and always will be.
For scripting tasks, scripting languages are used; I know a few
astronomers who were using Perl to control the telescope movement.
Many physicists/astronomers use Python too. Specialized languages
and tools (Mathematica, Maple, Matlab, Octave, Yorick, etc. etc.)
have their place.

Finally, it may be weird in XXI century, but there are still scientists
not doing programming. For instance, the only programming language I used
for my scientific research was Latex, to write the papers; my reseach tools
were paper and pencil and blackboard, which are still as effective as

Michele Simionato
Jul 18 '05 #28
>>>>> "Cameron" == Cameron Laird <cl****@lairds. com> writes:
Since you happily use Perl, Python or Tcl, I have a
question. How do you decided which one to use? :-)


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

Many organizations don't, esp. if the actual product they produce is
not written in either of the languages. Some code may exist, but there
is no "official" standard. And if there is, there is a good
possibility of changing it if you are able to demonstrate clear
technical superiority in skunkworks projects. And w/ Python, you
are. Been there, done that :-).

Ville Vainio http://tinyurl.com/2prnb
Jul 18 '05 #29
Fred Ma wrote:
I took a look at your website. I've decided to go Perl for now,
and ramp up on Python on the side.

That's fine. Good luck. Many of us have tried it.

Just remember, that when you have been swimming under the dark cold
waters of Perl for a few weeks, you can allways swim up to the surface
and gasp a few fresh breaths of python.

You will then find that those few breaths will take you as far as the
previuos weeks did.

regards Max M
Jul 18 '05 #30

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

Similar topics

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?
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
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 :
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
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.
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...
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...
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,...
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...
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();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.