4

I am interested in porting the protovis javascript visualization library to python for use in scientific computing. I have a general question and a specific one.

General: I have never ported a whole library before. What are some good strategies? Should I first just implement the user-facing API and then fill it in in a pythonic fashion? Or is it better to try to port over the internals/infrastructure first, and then rebuild the API on top of it?

Specific: This library appears to make heavy use of javascript's prototype-based inheritance, which is somewhat different from the python model. I found someone who made a pretty simple method to emulate prototypal-inheritance in python. However, from the perspective of porting a library, I'd rather not arm-twist python to be more like javascript. Any feedback on this issue would be greatly appreciated. Thanks!

Uri

7
  • 3
    Start at the top, and work your way down. Commented Dec 19, 2010 at 3:35
  • You don't port code from one language to another; the word you're looking for is rewrite. Commented Dec 19, 2010 at 3:41
  • Why not write your scientific code in python and let the GUI be javascript? Commented Dec 19, 2010 at 3:53
  • 4
    There are active porting/rewriting projects, such as: github.com/laserson/pyprotovis maybe check those out. Commented Dec 19, 2010 at 4:09
  • 3
    @Adam, You do realize that git belongs to the same guy as the OP, lol :-D Commented Dec 19, 2010 at 6:30

3 Answers 3

1

You might be better off looking at Prefuse (http://www.prefuse.org), or Flare (http://flare.prefuse.org). The former is Java based, the latter Flash.

Protovis is a little different in that it's plain old Javascript running the browser, using SVG as the canvas. You're not going to be able to readily leverage that in a Python rewrite.

If you're after a graph/network visualisation package, you might want to check out NetworkX: http://networkx.lanl.gov/

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the links. I am actually only interested in making static visualizations at this time. I figured I could connect my python port to something that spits out SVG, or connect it to a matplotlib backend. Later on, I could try to reimplement the interactivity using matplotlib. Regarding protovis, I find its "declarative" model particularly appealing, and would like to recreate it in a python package that could integrate into many scientific computing pipelines.
1

If you want to port from C/C++ to python you probably want to use swig. I don't know about javascript to python, but you probably have to do by hand. I would consider prototype inheritance in python unpythonic. I wouldn't recommend using the metaclass hack given in the link. Python programmers are not used to prototype inheritance and will probably not want to use it and you should be very carful when using metaclasses. Therefore I think it is best when you redisgn the inheritance model. I also think a redesign on the API wouldn't hurt to make it more pythonic.

Comments

1

The Python ecosystem is currently lacking a visualization tool such as Protovis, go ahead and good luck with your rewrite!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.