see whatever…

jump to menu

November 5, 2007

wasting time

Filed under: Death,Java — see @ 11:51 pm

On my more private site I have a massive problem with spam send via the contact form (which all ends up in my mailbox as there is (as far as I know as least) no way to use it to send mails to other people but still :( ). So I thought putting recaptcha on the form just like on this blog. Problem is the contact form is JSP which I build a couple of years ago (when still interested in Java). Today just doing all the stuff you need to do when writing Java (e.g. compared to Python or Javascript: all these “;” or just the compiling, baah) is just awful and makes no fun at all. Luckily the java implementation and the example provided are very very good and easy to use. I just forgot to generate a new recaptcha ID for the different domain…

I hope this whole undertaking (more or less more than an hour wasted) helps at least getting rid of all this meaningless spam. Actually all mails coming from the form was almost always considered spam by me so it may have been easier to remove the form completely…

August 19, 2007

Parsing XPath…

Filed under: Java,Python,XML — see @ 8:00 pm

… not using XPath on XML but actually parsing the XPath itself. I did a quick googling and about one of the few libs there seem to be is SAXPath which is part of Jaxen, the Java XPath lib also bundled with XOM. While I do like XOM and try to use it whenever I need to use XML and Java I was actually looking for an XPath parser for Python. Of course I could use SAXPath with Jython, but I could not find a XPath parser for pure (C)Python.

A basic splitter simply splitting an Xpath in its steps would be sufficient for the beginning so I thought so write my own. This basic functionality should not be too hard but in the end not too useful either… A complete XPath parser would probably be very hard to do, even XPath 1.0 is not the easiest, XPath 2.0 support would even be better.

So I am still wondering though if there is a library (or a part of a library like 4Suite, libxml (or better lxml) which does not seem to do this on first sight…) which does  XPath anyway and would emit the actual parsing of the XPath itself?

September 2, 2006

and switching programming languages

Filed under: Java,Javascript,Jython,PHP,Programming,Python — see @ 11:18 pm

In Reqiem for an operator Barry Warsaw farewells the <> operator which will be removed in Python 3000. I have no real opinion on the topic itself although I think <> and != are one of the few not TOOWTDI things in Python and so a reasonable decision to remove one. But the followoing question in the same blog entry got me thinking:
“How often do you type semicolons at the end of your Python statements? How often do you type colons at the end of your C conditionals? Yeah, me neither.”

Actually I do tend to forget colons in Python after programming a while in Javascript or PHP, and I do forget using braces in e.g. “if” clauses in Javascript or PHP or Java after programming in Python for a while. Actually I forget to use a lot of things in other languages that are not needed in Python like () {} ; etc. What really made me nervous was building a simple JSP form this week where I had to use Java and I almost got angry about all the stuff I had to type which would have not been necessary if it would have been a Python or even Jython form. All the declarating, casting, complicated and verbose looping etc was simply a nervekiller.

So I guess getting rid of <> in Python in favor of != makes language hopping at least a bit easier.

About the only thing I sometimes wish for Python would be the removal of mandatory colons at the end of if, for, class, def etc. I guess this would make parsing of Python sourcecode impossible or at least “indeterminable” (is that an english word?). But the colon is one of the few places where a special character makes the code not more readable but a bit convoluted. Not a big problem as the parser complains about missing colons (which I see frequently ;) .

BTW, this post is somehow related. It makes me like the language even more as there still seems to be space for a bit of fun.

August 4, 2006

Jython for Java programming

Filed under: Java,Jython,Programming — see @ 8:05 pm

I try to avoid Java programming as it normally is not really fun. But I had to do an adjustment to a JSP in which a XML was loaded as a file and parsed with basic DOM (no libraries available so just plain DOM ;) . The change was merely to load the XML from a URL instead. But I never did that before so I thought before trying this in the JSP itself I rather try it out with Jython first. I had installed Jython 2.2a1 as my new Laptop at work has JDK 1.5 installed (which seem to work better with 2.2 instead of 2.1). So i simple started the jythonconsole script (a bit scruffy but perfect for this simple task as it has auto-completion) and hacked away without even looking at the Java API docs. I know myself around the libs a bit so it took nothing more than about 5 minutes and the thing worked. Translating the stuff back to the JSP took a bit longer as all the declaration and exception catching stuff does get tedious. But all in all I reckon this was much easier and also quicker than working in the JSP itself.

I sometimes wonder why not more people at work use Jython. Most are full time Java programmers but I noticed even they tend to take quite some time with exploration of new (or simply unknown) features or libraries. This is very easy with Jython and also really fun too. But maybe a full time java programmer does not know how to have fun (ok, sorry ;)

January 11, 2006

jylluminate

Filed under: Java,Jython,Programming — see @ 12:12 am

found this presentation on Jython which mentions jylluminate, a thing I was looking for for a long time now. Quite often I try some java library to test and check how it works or how to do something with it in Jython, so much more convinient than actually using Java itself.

BTW, a colleaque insists Eclipse does all he wants so he will even be quicker (regarding typing) with it compared to my Jython but of course less typing alone is not everything Jython makes a better Java or even bearable…
Even he admitted conversion of arrays to lists and back with all the casting and even for a java programmer unusual syntax is at best awkward.

I guess quite a few programmers in the java world give up on certain libraries and work a way around the original problem as I just experienced with a simple problem in DOM4J which took only a few lines in Jython (or even better the jyconsole (forgot the link…)) which is really great to work with.
Maybe just my experience but I saw it a few times and wonder if that might be a general thing.

Actually now after using Python and its really good docs make the Javadocs of e.g. the JSEE look a bit shabby. Javadoc and of course the whole standard library is just huge with loads of classes. Python on the other hand almost always seems to have same functionality but with a much simpler API. Now I jump from x to y I know but that’s almost anagolous to DOM4J’s huge API compared to XOM‘s tiny, easy and well thought through API (which is expected from Elliotte Rusty Harold of course). So a nice API in Java is possible but does not seem as ubiquitous as in Python (which of course has bad examples too).

Powered by WordPress