It may or may not be worth to convert
them, and in some cases the Python version may actually become a
literal translation without any added structure.OK, I suppose I would have to see an example of that, preferably
something that wasn't organized around a class. One of the things I
have always disliked about C++ is how you have to dig around in the
headers to figure out what the heck the code is doing. Python at
least keeps it together, but it's still a mess in the sense that the
code layout has little to do with control flow. It's an extra hurdle
to understanding I could do without.
This is the straight and complete Python translation of the original
rlux.csh (inheriting most of its usability and portability problems):
import os, sys
if len(sys.argv) < 2:
print("Usage: $0 [rtrace args] octree")
os.system("rtrace -i+ -dv- -h- -x 1 %s | rcalc -e '$1=47.4*$1+120*$2+11.6*$3' -u" % ' '.join(sys.argv[1:]))
The boilerplate I added around that is simply there for user
friendlyness, and the use of direct process management for platform
independence. With any script as popular as rlux, we *should* add
those things.
There's still the issue of all the supporting libraries, their many
classes and associated methods.
I don't quite see why that is supposed to be a problem.
Actually, I think you've got this one exactly backwards.
Using modules from Python's standard library does not add
dependencies, it reduces them! Those modules are very well documented,
and anyone working with Python will be familiar with them.
I think this is a bit different with Perl, where many popular modules
come from third party sources, and may or may not be present in a
given installation.
You're not refusing to use something like <stdio.h> "because of its
many functions" either, are you?
This ease of maintenance is also one of the reasons why those things
should rather *not* be converted to C. There's simply no need to do that,
as long as we can delegate the number crunching to other tools.
However, I don't see how Python is less work
than Perl given the examples I've seen. Why not Ruby? Why not any of
the other myriad languages out there? You have your favorite; I have
none. I simply went with something that was familiar and supported,
and don't feel like changing canoes midstream as the expression goes.
Some years ago I would have argued solely with Pythons practical
merits, and its "batteries included" approach bringing such a complete
and useful standard library. It used to be my "secret weapon", giving
me a significant productivity advantage.
Today, another added benefit is the large pool of people who know how
to work with it (probably larger than Perl and Ruby together).
Ruby has many similarities with Python (not sure about its library), but
in comparison it's still a niche language. Without Ruby-on-rails it might
still be largely unknown.
Your rlux.py ended
up being a bit more complex than its C-shell progenitor...
As for
That added "complexity" has little to do with the fact that it's
written in Python (apart from not really being very complex).
ugliness, I don't really see the differences you do. I have employed
languages like TCL, which I do consider write-only (to use Randoph's
term), but Perl is OK for me.
Very few people will be able to make that last claim. And if you
manage to avoid Perls many syntactical and semantical pitfalls, then
you are truly a rare exception. For most people, Perl is just an
accident waiting to happen.
I do find Perl easy to read compared to Python, mostly because I don't
have to jump around the class methods or read up on the add-on
libraries. There are plenty of functions in Perl, no doubt about
that, but they aren't such a growing concern.
You're mixing up choice of language with choice of design method here.
Perl also offers object oriented possibilities nowadays, even if by
far not as simple and elegant. Those features just don't seem to be as
popular with the target audience.
I don't own a Windows box, so it's difficult for me to produce test
cases. I only hear complaints from people about certain commands not
behaving with binary data on Windows, even when it doesn't go into an
intermediate file. In other words, piping the binary output of one
command into another still screws up. Does Windows create a temporary
file when it does this? Maybe if it's on a FAT filesystem (as
Randolph mentioned), this is the source of the problem. It would be
nice to track this down. Although I don't have a ready solution, it
would be good to at least determine the parameters of the problem.
(Radiance's binary files are immune: octrees, HDR pictures, triangle
meshes, even binary matrix data -- it's just the raw IEEE floats &
doubles that usually mess up.)
I've searched for similar complaints online. In the few instances I've
found, it usually was because a terminating null byte wasn't written
to the receiving buffer for some reason. The purportedly received
garbage data was then simply the previous random contents of that
buffer. That may or may not be the cause here as well.
If there really was an inherent problem with using pipes on Windows,
then I'm sure I would have found a lot more information about it.
Cheers
-schorsch
···
--
Georg Mischler -- simulations developer -- schorsch at schorsch com
+schorsch.com+ -- lighting design tools -- http://www.schorsch.com/