tonybaldwin: tony baldwin (Default)
tonybaldwin: tony baldwin (Default)
python v. tcl/tkSo. I have now made two little denter/tweeter programs (to send updates to twitter.com and identi.ca), one with Tcl/Tk, the other with Python. I figured a little comparison, perhaps, was in order.
If you look at them, of course, they look, well, just about the same. Tkinter is, after all, analogous to Tk.

 

The Tcl/Tk program made it incredibly simple to display the response from the remote server, which I haven't succeeded in doing with the python script, yet. Both rely on calling an external program (curl) to send updates, rather than relying on the languages' built-in tools. I could probably work out HTTP POST in tcl rather painlessly. I did try to use python's urllib to post, unfruitfully, and resorted back to calling curl.


the code for both programs is available at the above wiki links

The Tcl/Tk program, which has the added feature of displaying the server response, has only 47 lines of code, 245 words, 1844 characters. It took me less than an hour to write it.
The Python program, however, which does precisely the same exact thing as the tcl/tk program, without displaying the server response, has 104 lines of code, 564 words, and 4073 characters. It took me the better part of a day to write it.  Oh, but the python program tells you if your update is too long, something I didn't program into the tcl/tk script, yet.  There's a plus.

 

One must ask oneself, of course, is this a testament to the power and simplicity of tcl/tk? Or, is it simply an indication of my lack of skill with python?

I can't answer that defnitively, but, to me, it really looks like tcl/tk is a bit more efficient. Admittedly, I'm not a very skilled programmer at all, in truth. Timewise, of course, I have been writing tcl/tk for a couple of years, and only just now delving into python. As such, I was able to throw the tcl/tk program together quickly, while, my efforts to "translate" my tcl/tk program into python required a bit of research on the syntax for writing tkinter guis, and other elements. It just really looks to me as though Python/Tkinter takes a lot more code to do the same thing. I really have drawn that conclusion. Especially building a gui, it seems, is more cumbersome with tkinter than with simple, good old tcl/tk. I know there are other means of building a gui with python (wxwidgets, pygtk, pyqt, etc.), but I wanted to try the one most similar to that with which I am already familiar, and, I believe it is a fairer comparison when using a similar gui ToolKit.

 

At this juncture, I do have to say, I feel a great loyalty and deep affinity for tcl/tk. I don't understand why it isn't in wider use, frankly. It is an incredibly powerful language, used for a vast array of purposes, and, in my opinion, is probably the easiest programming language to learn (of course, I haven't tried them all), especially for a beginning programmer. One can be up and running, creating useful programs in a relatively short time. I also feel the need to give kudoz to the tcl/tk community and the tcl.tk wiki, which is replete tons of example code, detailed explanations, and great resources for learning how to program in tcl/tk. The tcl-ers that hang out at #tcl on irc.freenode.net, additinoally, are extremely helpful, and patient. They won't hold your hand, but they'll tolerate a newbie, and point them in the right direction, without any snobbishness or derision.

I can't say the same for my experiences with pythonistas. Their irc channel was a little less friendly, imho. Maybe I just caught them on a bad day, or maybe I was having a bad day. After all, Pythonistas are known for having a sense of humor. Admittedly, I was frustrated when I finally went to their channel for a bit of support, and frustrated, whiny n00b is no fun to play with, any way. Moreover, the python community does have a lot of documentation available online. Nonetheless, to me, it seems that it is written for other programmers, not for the uninitiated, so, is not so easily read as much of the tcl/tk resources. Their sample code is not well explained, where someone new to programming can really make sense of it. This may also be a function of time, since tcl/tk has been around a bit longer than python.

 

I do want to make it very clear: I'm really not here to pick on python. I know that it's a powerful language with a great many uses, and a favorite of a great many real hackers who know a lot more about programming than I do. I will continue to learn to write it, and believe it will serve me quite well for various purposes, and I believe I will continue to have fun learning it. But, I think I might continue to point out how tcl/tk is much easier and seemingly efficient, too...

 
tonybaldwin: tony baldwin (Default)
iDenTweetyPie

I hacked up a little more python/tkinter silliness.

iDenTweetyPie sends a dent/tweet(update) to twitter or identi.ca.

That's all, really.

I have no plans to make a full-blown client for either site, just a quick-n-dirty updating tool. I would like, however, to figure out the pubsubhub thingy to send buzzes to google/buzz.

That would take some additionaly work, since, at the moment, iDenTweetyPie tells you that you talk too much and refuses to proceed if your update is longer than 160 characters, which, of course, isn't necessary for buzz, since buzz tolerates longer updates.

I might work on that. I don't know. This was just a little exercise, really.

I had already written a similar little program in tcl/tk, iDenTickle, which initially only did dents, but I have updated that one to send tweets, too.

my dents : my tweets

./tony



Originally published at tony baldwin | bloguiando.
tonybaldwin: tony baldwin (Default)
I've decided I need to drag out the transprocalc code and get hacking again.



TransProCalc is a little program I sarted building back in late 2007/early 2008, when I was outsourcing a lot of translation work, and found that the time I was spending managing the projects didn't justify the meager profits I was making from outsourcing. I determined that I really needed to find a way to automate parts of the process, and I couldn't find any existing free/open source software projects that would meet my needs. I was "scratching an itch", as they say in the hacker community. I had a need; I started hacking.

TransProCalc IS handy, too. It helps me keep track of all the documents and assignments for a project, and crunch of the financial numbers, and spits out handy little reports. It needs work, though. I want to get it playing with a database to manage information on clients and providers, get it hooked up with a real calendar/reminder system, to remind me when invoices are due (to providers, or from clients), keep track of which clients have online invoicing systems and help me automate the process of dealing with those, etc....much trabajo.
I have good ideas on how to get a lot of that accomplished, but I need to set aside some time to get to work on it.
Additionally, I would not mind other devs jumping on board with the transprocalc project.
I added transprocalc on google code this morning, which may assist in finding other hands to get into that code, perhaps, and provide tools to manage the project.
Of course, it is already on sourceforge, too.
At the moment, I have some academic articles from Brazil to translate that are keeping me pretty busy.

Furthermore, I have a lot of really good friends in Santiago, Chile, where there was an 8.8 earthquake early this morning.
So, today, I am spending a lot of time, today, worrying about them and trying to track them down and make sure everyone is okay, and obsessively checking the news, etc... VIVA CHILE, MIERDA! (a todos los chilenos, les quiero mucho, mando abrazos, cuidense)



Originally published at tony baldwin | baldwinsoftware.com.

tonybaldwin: tony baldwin (tony baldwin)
Not much to report today...I went to interpret in a medical appointment for a Portuguese gentlemen, then returned to the office.
I'm working on translation of internal labor regulations for a Colombian company.
I though I'd share this: wallpapers by tony baldwin
I put up a page for some of the wallpapers I've made, mostly gnu/linux, debian, and related.

Originally published at tony baldwin | baldwinsoftware.com.

tonybaldwin: tony baldwin (Default)

Originally published at tony baldwin | baldwinsoftware.com. Please leave any comments there.

Someone asked me what this:

was all about…having astutely noticed it in the last screenshot I posted.

I often have to quick math on the fly while generating estimates for clients and doing other off the cuff calculations.
Previously, while using openbox or fluxbox, I had a keybinding bring up a calculator and did the math and then killed the calculator with ctrl+q.
But, I’m all about efficiency, and lately have been learning more and more of the powerful tools in bash to do various things, from navigating the file system to handling files and manipulating text. In wmii, I always have at least one bash terminal open (my preferred terminal emulator currently being roxterm).
So, I figured there had to be an efficient means of doing math without bringing up a gui calculator, too, but bash doesn’t like floating point numbers so well.
Now, with expr or echo or let one can do some basic math (ie. expr 220+34, or echo $((220+34))), but not with floating point numbers (with decimal points), which I need.
But bc can do it. One would have to type in something like:
echo ‘5467 * 0.09′ | bc
or
bc -l <<< 5467*0.09
to get the result....
Not really quick-n-dirty...
So, I scripted it:

#!/bin/bash
# do math with bc
echo “Enter your equation:”
read e
echo “The result is:”
bc -l <<< $e

I called the script ‘M’ (for ‘Math’), and stuck it in /usr/local/bin.
Now, I just type
$ M
and I see:

Enter your equation:
(enter equation here)
The result is:
(result appears)
$
all done.
I type 1 letter (two keys, shift+m), and my equation.

tony@deathstar:~$ M
Enter your equation:
3452*0.09
The result is:
310.68
tony@deathstar:~$

./tony

Profile

tonybaldwin: tony baldwin (Default)
tonybaldwin

December 2013

S M T W T F S
1234567
8 91011121314
15161718192021
22232425262728
293031    

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags