Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/23/d577870663/htdocs/techcogs/wp-content/plugins/jetpack/_inc/lib/class.media-summary.php on line 77

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/23/d577870663/htdocs/techcogs/wp-content/plugins/jetpack/_inc/lib/class.media-summary.php on line 87
programming – Tech Cogs

The Path to a Python Twitter Bot

It turns out when you’re trying to write an application that interfaces with the Twitter APIs you need a variety of keys and things from Twitter. In order to get those you have to provide Twitter with a valid phone number which can receive SMS messages for verification purposes. Despite the ubiquity of cell phones, still not everyone has one, or wants to give out their number, so I’m not sure what Twitter does in that instance. Either way, this is something important to keep in mind when trying to write a Twitter program.

Give Me Some Sweet GUI Love

When it comes to writing programs and applications even though these days the emphasis is on network things, Internet things, and servers, I still enjoy writing traditional applications too, so in order for me to really connect with a programming language it needs to have easy support of GUI development.

This is one of the reasons I keep coming back to Java for various projects, with its built-in GUI toolkit, and one of the things I like about Python, where it’s easy to put together a GUI using Tkinter or something like WxWidgets.

In order for me to be interested in a programming language, it needs to have good GUI support.

Lists are Slow in Vala

The other day I wrote a small program in Python. Part of the program involved reading a text file, parsing the information, then appending the information line-by-line to two lists inside a loop. It worked well and it worked pretty quickly but I decided I wanted to try rewriting the program in Vala, which is a programming language somewhat similar to Java and should be fairly familiar to Java developers. Vala cross-compiles its code into C before compiling the C code so I thought recreating the program in Vala would make it even faster.

All of the normal elements of the program, reading the file, parsing it, did work fairly quickly. But appending the data to the lists was incredibly slow. Whereas the Python program was able to do it almost instantly, the Vala program took a good 15 or 20 seconds to do the same thing. I tried a number of different things to make sure it was appending the data to the lists that was causing the program to be slow, and that is indeed what it was.

The only reason I can think of for this is because Vala converts the program into C and dynamic lists aren’t something C natively supports, Vala must have to do some sort of gymnastics to get the Vala lists to work in the translated C code.

Whatever the reason, I’ll just be sticking to Python for my projects.

Copyright ©2019 Magic Kazoo Media