java etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
java etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

30 Nisan 2009 Perşembe

Using GWT with Django

Image
Well i tried GWT a few days ago and liked it very much. I'm not a js expert and for that reason dont use it too much in my web applications. But from time to time i need some fancy client-side apps to do ajaxian stuff easily. I had written an Independent Django app which was an ajax-driven event calendar. Therefore i did most of the work remotely via Django. I used jquey for ajaxian calls. But if i were a better js programmer i would do that job with less remote calls. But the Magic in GWT is cool you create your application with Java ; a very cool and easy language and it converts the written code into javascript which is compatible with most of the browsers. Therefore you dont bother with strange behaviour of the js and dont bother about if your code will run on BrowserA or BrowserX.

I followed the tutorial in GWT site and had a running application (StockWather). To complete that tutorial you probbaly would need to complete the StockWatcher firstly and then go on from here or you can just pull the code i wrote for that purpose from here[1] and just inspect it.

For communication of both ends i used XML,if you're not a fan of it you can use JSON also. I didnt use JSON because of the JSNI usage in Java code. I dont like hybrid codes like that...

  1. First create the server side code in Django :LINK
  2. You need to build a GET request in you JAVA code so u do that from here: LINK
  3. Parse the incoming XML string from Django and convert it to JAVA objects: LINK
  4. Write unittests for your client side code (GWT) because if you have errors u will get some strange JS errors which are not so decsriptive. : LINK
  5. Put GWT application in your media and put the generated HTML file in your templates directory.

Well that is all,it took some time to glue both of them (Django and GWT) but we have here a happy end :) GWT is cool but it has some little weird stuffs i dont understand yet. One of them is Designing the applications.I should find
an easy way to explain it to my designer :)

[1]: GWT-Django app

25 Ağustos 2008 Pazartesi

Case Study Iterative Fibonacci

Wow, it has been long time and i didnt write anything here. That will be a series of articles in which i will be writing some of the algorithms with (mainly) Python. Sometimes i will implement some of them with Java and some of them as Python C extension. I wont use C++ sorry :) I think it is a failure of the object oriented programming but , that is another story. I like the old school C instead of it. In that series i will compare the written algorithms and codes in some areas; how fast they are (O notation and time),how easy was to write them . Any of the comparisons made here are my personal thoughts about that so , i dont claim anything ...

Python :Link
Time :
[makkalot@localhost pyalgorithm]$ time python py_fibo.py 1000000
Result written into fibo.txt

real 3m47.825s
user 3m46.481s
sys 0m0.391s

Level of writing : I think it was quite easy to implement that computation. Additionally i didnt have to think about large numbers python handled all the stuff for me which was cool .

Python Extension :Link

[makkalot@localhost fibo]$ time python ex_fibo.py 1000000
Result written into fibo.txt

real 3m43.437s
user 3m41.899s
sys 0m0.419s

Level of writing : Ah that one was not easy to write :) Firstly i had some difficulties and memory leaks with Py_INCREF and Py_DECREF stuff. The second problem was the big integers thing, so i had to use some Python stuff which made that problem easier.(I wont write that stuff in pure C no no ...) If someone has better solution here please post ...

Java:Link
Time:
[makkalot@localhost bin]$ time java sorts.FiboMan 1000000
The fibo result is :written to fib.txt

real 5m31.204s
user 5m18.196s
sys 0m8.927s

Level of writing : Yep that was really easy to write. And also Java has some good solution for these big integers so i only used BigInteger class to handle that situation.But, the code is a little bit longer than Python code.

Concluion : I was really suprised when the pure Python code had almost the best time, so i think i can use the iteratve computations in Python. The dissappointment was the C extension i was expecting some really big difference in time. However the reason seems to be used Python.h functions in C extension. And the Java code really suprised me, its time was really acceptable so people who use Java may write their iterative computational solutions without any concern. That wass my fibonacci iterative test. The second of the series will be the recursive solution for fibonacci and my comments about it ...