Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Friday, December 05, 2008

Introducing PyConsole!

I have been pretty inactive this year, unlike what I planned (yawn, haven't heard from DLTK since June either) . I started learning Python earlier this year and felt the need of an embedded python shell inside Eclipse. This was something PyDev is missing [Edit: Simone pointed out that PyDev already has this neat feature, I was late to discover it] as compared to other python tools in Linux such as Eric. So I decided to write one.

PyConsole is direct result of my irregular and intermittent Eclipse development (lately), it's very simple plug-in with a basic exploit of Eclipse Console View and manages two way synchronized I/O from the python interpreter process controlled by a background Eclipse job. It provides few basic features anyone might expect from a shell such as syntax highlighting, command history etc.

Here's the code repository if anyone would like to check it out. If you have suggestions or feedback please write to me or create a bug.

Tuesday, February 12, 2008

State of Eclipse based Python Development Tools

For starters, Python Interpreter console isn't a bad place for trying hands on the language. But if you plan on building larger programs with it you will need a good development environment, There are plenty of integrated development environments for Python today. Most of them are freely available open source projects, some have specialized support for GUI building while some are general purpose.

Since I'm Eclipse platform zealot, the first one I used was PyDev, PyDev is excellent python tooling built on Eclipse platform. It builds on excellent Eclipse UI and non commercial version offers basic refactoring, integrated debugging, Jython integration, Unit testing and several regular features which most Eclipse based IDEs inherit.

When it comes to dynamic languages tooling, DLTK is one potential place to look for in Eclipse Ecosystem. From time to time I'm lurking around DLTK newsgroups as well as keeping an eye on things moving in codebase for Python IDE. As of today, Python support in DLTK isn't too bad but it's still not as good as other IDEs out there, although it's coming up slowly. Eclipse DLTK is one fantastic tooling idea, it is so cool to build IDE for dynamic languages that you might want to try your hands building one, have a look at the guide here.

Out of Eclipse ecosystem, Eric is an IDE which I got chance to try hands on so far. Although It doesn't look as refreshing as PyDev or Eclipse in general, but it's pretty decent IDE nevertheless. It has lot of features, so many of them that you will confuse yourself on where to start, Eric UI has to be the last thing to impress anyone. It primarily features syntax highlighting editor, refactoring tool, debugger, package diagram viewer, regex builder, integrated version control and Python shell among others. While I'm not sure if Netbeans has any rock solid plan to support Python as Eclipse DLTK but I came across JPyDbg which is cross-IDE (and one of it's kind) for Python development. JPyDbg is kind of inspiring idea and I'm wondering if cross-ide-platform plugins would be a good idea? but that deserves separate post.

I haven't mentioned JyDT etc. because they seem to be dying or not actively compatible with later Eclipse versions. I would keep posting on python tooling as I go along working more on it.

PS: DLTK, I'm watching you.

Monday, February 11, 2008

Climbing the Python hill

Finally I have started working on new year's resolution. As a part of it, I'm learning a dynamic language called Python.

There are several reasons why I'm a new Python convert. One of them is not because blogosphere keeps intimidating Java programmers that they are writing crap. And I've honest sympathy for those who hold the assumption that Java is dead and other strangling naive opinions like that.

I am rather going ahead with some mature opinion like programming in a language with different philosophy gives you another way of solving the same problem, And sometimes the other way is better or at least, it will bring out interesting techniques which can be useful in general. Since I have very limited experience writing sizable software using them, I am expecting a lot from dynamically typed languages, Python in particular.

Python has been particularly interesting to me because I am curious about it since academics. I've played with it in past but that was just a stab that didn't bleed my nerve. I have no hard feelings for Ruby (or "hoopla oriented" Rails), because I'm not a huge fan of Web applications - web applications are boring.

Python is actually fun to program, programming in Python is like kidding, no it's not as frightening as it's name implies. For example, Methods in Java you know? they can't be moved around with out puzzlers and pain. But in Python, methods are also treated as types, called function types, which you move around like variables - no wait believe me it's as simple as passing around variables. Look at the closure example below and tell me how difficult it is to understand?
x = lambda: a,b: a**b

x(10,12)

Like you do in a regular mathematical equation, assign an expression to a variable or symbol and bind that symbol with value as shorthand like this.
a = x(10,2) * x(6, 8) / x(10, 2)
Also, any method which is not using 'lambda; keyword is also treated in same way, no partiality. Other obvious thing to like about Python is - it forces correct indentation in source code, that makes Python program much more readable in a consistent style. No need for one thousand formatters and coding standards.

I'm not comparing Java with Python, that's not my Job. I'm just trying to realize that how apt it is to solve the same problem aptly in a different way.

Python community, like Python itself, looks great. It isn't impossible to realize that - hangout on Python google group sometime and you will know. I am glad that they are very accepting and responsive to the n00bs like me.

I have started with SQLAlchemy ORM and db api in general to learn python because I'm curious on how they play with tuples and all. Later on I'll write a bit of parser as I've heard Python has some neat and funky stuff for parsing.

And oh, I'm having little trouble getting out of Java shoes lately - hmm, there is nothing like private fields or methods. But I guess that's better than writing getter and setter for that private variable which does nothing but to add overhead for dynamic compiler of hotspot VM to inline it after 3000 iterations, gosh!! But hey, Python is missing the package convention or let me say it prefers configuration over convention here, __init__.py is not as intuitive, is it?