Domain: pfdubois.com
Stories and comments across the archive that link to pfdubois.com.
Comments · 11
-
Re:FORTRAN considered useful...like SQL
I doubt that designers of armored cars and dump trucks worry about the slings and arrows of the Ferrari's designers; I think this rant is pretty much in the same vein as that. Beauty and utility are not synonymous.
Are you proposing that a Ferrari has no use?
When something is well-designed, it's both beautiful and utilitarian. They are not necessarily synonymous, but they're not exclusive, either.
For example, take a look at Matlab (or Octave). Easy enough for just about anybody to type in a simple equation, powerful enough to do some very sophisticated things, and without all of FORTRAN's old crap. All of the numeric computation guys I've ever worked with use Matlab, not FORTRAN.
If you want a more general-purpose programming language, take a look at Python with Numerical Python. (For at least one commercial game, Python was used not just by programmers, but by writers and artists and sound engineers. Beauty and utility.) -
Jython
You might want to try Jython and the Numerical Python for Jython.
I have not used either for a long time, but use plain Python and Numerical Python a lot; sure beats Matlab and Mathematica for most things. Right now for solving optimization problems with 10k+ s.t. constraints. -
Broken link, java jab
The link to the image should be http://www.cpjava.net/raytraces/DRUN.GIF (The www is necessary and was left out of the link in the article.)
People are already cracking jokes about how the fact that it's in Java will mean that it will run a lot slower than it could. While I love to pick on Java as much as the next person, I am curious how much it actually makes a difference for raytracing - does anyone know? My experience with numerically-intensive algorithms is that Java is 2-4x slower than C. You can get it within 2x of the speed of C if you ignore object-oriented programming and you're really good at Java optimization, but that's it. And it will run much slower on some architecetures because Java guarantees certain floating-point operation semantics at the expense of speed.
If I were writing a new numerically-intensive program from scratch that I wanted to use for a cross-platform distributed computing project, I'd probably do it in Numerical Python (NumPy) - my experience has been that it can be within a factor of 2-3 of the speed of C, but it's much more concise, requiring half as many lines of code as Java or C to do the same thing. And these days Python is just as cross-platform as Java - it definitely runs great on Mac, Windows, and Unix. -
Re:Python and data typesYou're already proposing several solutions, as others are as well -- SDL (probably most accessible through PyGame), PIL, Numeric, some extensions available through SciPy, and eventually moving into things like PyTables or even lower-level functionality like array or ctypes, there's also the possibility of coding in C or another compiled language, or using Pyrex. for some easy-Python-integration goodness, or Psyco which can do some pretty magic stuff in select situations.
No, it's not like MATLAB -- Python is a general-purpose language. If you want MATLAB, then you're looking for a more specialized environment, like SciPy (maybe using iPython to provide a nice interactive environment). As a MATLAB replacement, Python is probably a work in progress.
If you want homogeneous collections with fast transformations, you must do it with somewhat opaque containers like Numeric, where anything that runs inside the inner loops of transformations is written in a very fast language. (Oh, I just remembered Weave) This is true in Lisp as well, though Lisp has also had compiled forms which are pretty quick.
Anyway, lots of options. Stop complaining and enjoy what you got!
So, is Java really better? I honestly don't know the scientific or image processing domain, so I don't know where Java's at there.
-
Why stop with tagging?
-
Re:Explain Python to me
But Python's missing many of the goodies that make slow languages great. Macros.
Not having macros was a deliberate design decision. One of Python's key stengths is easy readability and adding the ability to add/modify language contructs might compromise this.
A good, scientifically-oriented numerical facility.
What facilities are you looking for, in particular? Python has a double-precision floating point type, unbounded integers and complex numbers as part of the core language. Are you looking for something else, like rationals?
Or is it libraries that you are looking for? If so, here are the docs for
Numeric
Python is odd: it has both models. Underneath the model is prototype-based. Kludged on top of this is a class model. What the heck?
I don't understand your complaint. Can you discuss it in terms of semantics e.g. I would expect method to get resolved like this but they get resolved like that....
I get the feeling that what happened was Python started as a procedural Perl-style language, then hacked on a prototype model, then due to, I dunno, misinformed "customer complaints", hacked on another class-based model on top of that. What a mess.
Python is fundamentally object-oriented. Even integers are treated as objects.
Cheers,
Brian -
free alternative
You can get a copy of Numerical Python and run PyPVM or PyMPI with it for distributed computing.
I think for numerical computation, that's technically actually a better environment than Mathematica. And, while I'm not usually one to harp on the fact that free software also doesn't cost money, given the steep price of Mathematica, in this case, the money saving aspect really does matter as we.. -
Try Numpy
Check out the numerical extensions to Python. They're quite good and can give you an environment with the power of Matlab for zero dollars.
Numpy uses the netlib libraries behind the scenes, by the way, so you get very good speed for array operations. You get the best of both worlds -- Fortran speed with Python's expressive power. It's much easier to do I/O and UI programming in Python than Fortran. :-)
-DA -
Python/Ruby bindings
Given the relative ease with which one can put Ruby and Python bindings on C++, C++ makes a better choice for a "low level" language to work in tandem with python or ruby.
Until there is the C++ ABI standard agreed upon and most compilers (actually, g++ alone would be enough) implement it, I won't touch any extension .so's built of C++.
For example, it's much easier to write a matrix library in C++ than it is to do the same in C
Ironically, we've already got NumPy.
Granted, C++ is not going away anytime soon, I myself program in it for a living, but it's not a magic bullet either. -
TISEANA very good package for chaos-theory-oriented numerical data analysis is TISEAN.
It does excellent job on its part. There is also some documentation on the site, including one of the creators' Ph. D. thesis that explains some of the theory behind the software. On Linux it requires gcc and GNU Fortran complier to compile (compilation is pretty straightforward).
I also found GNU awk extremely useful at numerical data analysis. You also would want to include Python and NumPy - python extension for numerical computations.
HTH
Alex
-
Re:My Guesslack of modularity features
Apparently you haven't used Python, or even read the docs; modularity is one of its strongest features.
Programming in python might produce better code, but it is enjoyable to write? Most write-only code (ie, scripting tasks) are tedious if you write them the "nice" way.
First of all, I use the interactive Python console to accomplish simple scripting tasks, which is a breeze. I spend so little time accomplishing my goal that I can move on to something I really enjoy in short order, such as a more challenging program.
If the task is slightly more complex, I figure out the basics on the console and then write the complete program in a module (in Python, a module is just a file of code--a "script"). When I'm done with my simple scripting task, that module lies around waiting for me to need some slice of its functionality (a function, for instance) in the future. If I do, I just 'import' it and go to town.
For more complex tasks I use OOP, which is pleasant in Python, though not as formal and featureful as in the likes of C++. For example, I've written a fairly involved network app that uses both multithreading and sockets extensively. OOP happens to match the way I think, so I consider solid support for it indispensable (before you suggest this, I was not "raised on OO" and therefore did not begin exploring the broad world of languages with a favorable bias toward it).
As for power, Python has it aplenty. The language's philosophy, though, is that extra power should be added uniformly--through the modules and class mechanisms--rather than cluttering the core language with lots of bizarre constructs.
Concurrent programs are a breeze with the threading, there's a parser module for manipulating Python parse trees, an shlex module for concocting simple lexers right off the bat, a Numeric module for maxtrix manipulation and other scientifically oriented numeric programming, various imaging/graphics modules for graphics programming. These are just a few of the modules that I actually use. All of this, and the core language remains the best compromise of simpilicity (Lisp) and comfort I've ever used.
For most programming tasks (even complex ones), C++/Java-type languages aren't clearly superior. Bruce Eckels, author of _Thinking_in_C++_ and _Thinking_in_Java_ (thus clearly well acquainted with both), says "Python is my language of choice for virtually all my own programming projects".