PyCon 2010
Labels: Conventions, PyCon, Python
Labels: Conventions, PyCon, Python
Labels: Bad Design, Dynamic Languages, failed language implementation, Python, Ruby, Speed
Labels: Hacking, OOP, Pascal, Perl, Professionals, Python, Rexx, Ruby
Labels: Django, dvcs, Hg, Mercurial, Project Planning, Python, version control systems
Labels: Burlington Coat Factory, Django, Engineering, Ethics, H-1B Visas, principles, Python, software engineering
Labels: Alpha, Automation, Beta, Cartography, Coming Soon, Kaart, Maps, Metric, Python, SimulaE, Update
Labels: Algorithms, Design, Objects, OOP, Python, Refactoring, SimulaE
for search_string in search_input: for application in search_schema.keys(): for attribute in search_schema[application]:
code_to_eval = "%s.objects.filter( %s__icontains='%s' ).order_by('-id')" % (str(application), str(attribute), str(search_string)) try:
eval_results = eval(code_to_eval) for eval_result in eval_results:
if eval_result not in container_xref[application]: container_xref[application].append(eval_result) container_xref['total_results'] += 1 except Exception: ### Case specific exception handler types, assignments and resultant actions ### specific to each application in which the above is implemented, go here.
-----
Labels: Code Evaluation, Django, Dynamic Languages, Post Compilation Dynamics, Python
Labels: Development, Dynamic Languages, Engineering, Guido van Rossum, Matz, Objects, OOP, Python, Ruby, Smalltalk, Static Typing
Labels: Arc, failed language implementation, Lisp, Paul Graham, Perl, Python, Robert Morris, Ruby, Scheme
Labels: Django, Inked Magazine, Joomla, PHP, Python, Rails, Ruby
Labels: Cheetah, Django, Engineering, Engines, GANTT Charts, Project Planning, Python, Rapid Application Development, Ruby, Scheduling, Team Projects, Website Design
Labels: BAMP, BSD, Design, human interfaces, Javascript, LAMP, MySQL, Python, Rapid Application Development, Templates, usability, user friendliness, Website Design
Labels: Agile, Cheetah, Perl, Python, Rapid Application Development, Team Projects, Templates
As was mentioned in a previous entry, I stated that I was willing to try being an independent contractor again sometime. That time is now. As such, my new corporate overlords are a media publishing group and I’ve been called in to do a ground up architecture and engineering job, along with continued long term maintenance. Unlike before this situation appeals to me because it lacks on of the most common issues in the realm of development in general, legacy upkeep. Sure, there is the little issue pertaining to a php application which needs to be put on a website short term, but after that we’ll be trying to limit php to specific applications on a limited (only as-needed) basis.
Ultimately we’re looking at starting with a fresh new remote server and that being said, my own experience brings me down to a quasi LAMP setup. Traditionally I’ve found that when I want a rock solid remote host, one which I know can go years on end in a reliable manner, I chose FreeBSD. Nothing against Linux other than I find it fine for a Desktop or a Server, but more so the desktop than the server. I find that there still is no substitue for Apache when it comes to matters related in pushing out pages to the web.
Next is a point of contention, the database. I’ve been using MySQL since version 3.23.24a (or something around that revision number), and have found that it met my needs about half of the time. Much of it (at the time) revolved around the issues pertaining to MySQL’s myisam faults and weaknesses regarding concurrence in high insert/update environments. I know some people out there (many actually) will start arguing this point right away, and I still say unto you that this is a known weakness. The myisam database storage engine is designed for speed, not high-concurrecy, nor transaction safety. When paird with the InnoDB engine, and the removal of the auto-commit flag (as it negates the whole point of using a transaction safe engine), most of those issues disappear. The other issues pertain to foreign keys, store procedures, etc., which have been slowly addressed in versions since the 3.xx base. Now we’re at the 5.xx family and much has improved.
However, all of these points still cause MySQL to pale in comparison compared to PostgreSQL. True, MySQL has proven to be very capable and very popular, especially among the Linux crowd and cheap hosting crowd. I will be installing MySQL on the new machine to handle support of third party web applications, though when it comes to hosting any important data, there can be only one choice, and it isn’t MySQL. PostgreSQL is the clear winner here, the closest db engine we have to Oracle without being Oracle.
Finally, we approach the last letter in our acronym. The ‘P’, which can stand for a multitude of langauges scripting, web and otherwise. We have PHP which is wonderful for quick and simple (an a handful of not so quick and simple) web based applications. It is an easy language for the novice to learn, and in the hands of an expert, even more so capable, though it has its faults, and among those security being the top. Much effort has been made (especially post 4.2.3 and 5.x versions/trees, and I hope to see this evolution continue, though I still don’t see myself using it much as I don’t feel compelled by the language as a whole.
Next we move to another ‘P’, which in actuality is a ‘p’, perl. The oldest of the languages we’re discussing here, but not by that much of a time frame. Perl grew out of the personal needs of a C programmer, Larry Wall as a combination replacement of both sed and awk (amongst other Unix utilities). I’ve been paid to code in Perl for the better part of the past 11 or so years, and I can say after all of that time several things. On the good side, perl is found everywhere, has a large code base, and is fast. On the bad side, I’ll have to limit my dislikes and faults found within perl so that this entry doesn’t go on for thousands of words. Limiting my issues with perl we will see that it allows, almost seduces people into writing ugly, cryptic code. Yes, yes, yes, the code some perl monks/mongers write may be very crafty. Crafty does not equate with great, let alone good quality.
All too often we see people referring to the TIMTOWDI (There Is More Than One Way to Do It) mindset of perl as being a benefit, though I see it (time and time against, countless of codebases later, even the CPAN library) as being a flaw and weakness. If you don’t enforce a certain level of clean design into the language itself, you end up with a mess, or as many others have stated, a write-only language, one which even the author(s) of programs cannot read/decipher down the line. My suggestion is for perl coders to follow Java coding guidelines. I mean, we’re talking about a language that doesn’t has several decent levels of rules and coding enforcement (such as the ‘use strict’ pragma), but is so foolish as to allow people to code in a manner contrary to that pragma when it already exists in the core language. How about a proper exception handling system? Eval blocks or non-core/second-class libraries do not make a proper first class handling system. This is asinine in a language that has been around for over 20 years as of this writing. I could go on, but I’d rather not.
This brings us to a non-p ‘P’ in LAMP, Ruby. Ruby to me is an evolution of perl in many regards, especially its object based design and proper exception handling system, however it still fails miserably in the sense of massive overuse of tokens and pascal-esque verbatim block terminators. Rails has made Ruby a mainstream language, and I do feel that it has considerable potential ever more so than Rails alone, but it still has a ways to go when it comes to speed and cleanliness. Matz has be working hard on it, and I’d like to think there are great things ahead for the language from the land of the rising sun, but at the current moment, I still find it lacking as non-web specific development platform.
Finally we come to where I’m heading, and I’m sure others have already figured that one out. Python rounds out the last ‘P’ in the equation. Python is almost as old as Perl, and is rooted in development languages as opposed to the shell and various utilities. In this language we see a very capable, 100% object-based development language which is capable of handling coding projects of any size which espouses clean design, human readability, code re-use, distributable byte-code compiled classes/applications and proper exception handling as a first class citizen.
So as we can see where, the solution i find most reliable and long-term maintainable with minimal development time, maximum return for design/coding efforts, security and platform flexibility is simple. So it isn’t technically a “LAMP” solutions, more as it is a BAMPP solution encompassing BSD for the OS, Apache for the web serving, MySQL and PostgreSQL for the database(s), and Python for application development.
I came to the above choices after years of experimenting and experiencing and I do suggest others experiment on their own if they have that luxury/time frame available to them, but I do offer the above as a recommendation as I would (and have, and will) bet my own future livelihood on the flexibility and reliability of the aforementioned combination of technologies.
Labels: BAMP, FreeBSD, InnoDB, LAMP, MySQL, OS, Perl, PHP, Python, Ruby
I’m not sure as to whom to attribute the following statistic, but i believe it was something along the lines of this; Code is read vs. written on at a 10:1 ratio, meaning that the is far more reviewing of any specific codebase than there is writing to said code. Furthermore, the majority of software positions involve maintaining and modifying existing code as opposed to creation of new code from the ground up.
To what does all of this allude? The importance of writing clean code. Knowing full well that other developers are going to have to read, understand and most likely modify your code in question at some point(s) in the future. This is where our responsibility as software professionals (even in the case of hobbyists) comes into play.
Several languages have tried to address this problem by intrinsic design decisions. Most notably among those in recent times are Java and Python. Java does so by its explicitness by design, and Python by its forced formatted a la the whitespace requirement. Both are effective in what they do, however there are still a multitude of ways in which both can be written in a harder to read format. Obviously choice of variable, function, class and object reference names is a very large point of readability (or not) which really cannot be enforced by a language specification. Let us take a look at this very issue and while we’re at it, i’ll be clear that this is not a Python vs. Java issue discussion.
All too easily so many coders (I know this from having had to look at, understanding and refactor their code) overlook one of the best sources for building readable code, and that is their naming convention. There have been several best practices and coding style specifications documents produced that one might think me as flogging a dead horse, but I assure you this is not the case.
In the following examples we see a variation of languages and how we might commonly see the same variable name referenced (and initialised as it were):
Smalltalk:
num_of_doors = 4 ;
Python:
numberOfDoors = 4 OR numDoors = 4 OR number_of_doors = 4
Ruby:
numberOfDoors = 4; OR numDoors = 4; OR number_of_doors = 4;
Java, C#:
int numberOfDoors = 4; OR int numDoors = 4; OR int number_of_doors = 4;
Lisp:
number-of-doors := 4;
C, C++:
int intNumDrs = 4; OR int num_drs = 4; OR int int_drs = 4;
Perl:
my $vzoiuwriozufsd = 0x04;
The point here is that there are many varied ways in which the same variable can be referenced. I am of the opinion that much along the lines of Guido van Rossum of Python (and to a lesser extent ABC) fame, that there really should be one and only one obvious way to do it. This isn’t to say that I think everyone should code in the same language, and speak the same tongue, etc. What it does mean though, is that to be understood by others (and sometimes by ourselves), we need consistency, and unless we have a set of strict guidelines set out for us as software engineers, developers, etc., we might as well code in our own made up dialects.
I am of the opinion that a proper interpreter, compiler, virtual machine, etc., should be more than capable of quickly turning long variable, class, function and method names into concise tokens with small internal footprints. So much to the point that there is no excuse for not being verbose. At one point in time, every single byte of allocated memory for names of the aforementioned items was a crucial issue which required extreme concise naming conventions to be followed. Those times are gone in this day and age, allowing us to be clearer and more expressive.
I can see using single letter counter variable names, but never could I imagine naming a class, method or function in such a sparse manner. I like to think that clean code reads somewhat like a choose your own adventure book, were it to have a greater variety of options available. Functional or Object Oriented is immaterial here, as cleanly written code isn’t tied to a specific construct or paradigm. I think most of the following rules are applicable to pretty much every language out there. Emphasis below pertains to items that I feel are not language specific guidelines.
As can be seen, most of the above are applicable to languages other than Python. I find myself at my current place of employment having to deal with the problems for which this list addresses. Much of what I’m doing is updating a legacy code base that is literally plagued with dozens of individual programs and modules that are blatant attacks on decent code. They (collectively) single-handedly break most of the above guidelines.
First off it is almost entirely written in perl, which instantly shoots down the Readability counts factor (and no, it wasn’t done with the strict pragma, and yes it uses a bunch of requires and plenty of global variables).
Secondly, errors don’t pass silently because there is no built-in exception handling in perl. Evals of code blocks does not equate to a proper exception system, nor does an add-in module. Exceptions are something which need to be a core part of the design of the language, and perl falls far short of the bottom of the heap on this issue alone.
Thirdly, when one is expected to maintain code in an environment wherein the expectation is to follow the existing coding schema as it were, with global variables, no exception handling, etc., it truly becomes a daunting task because one must force his/herself to think ‘wrong’. The logical and/or proper solution that is naturally though of as a solution would only lead to reprimand, simply because trying to think in such a manner will produce mistakes, primarily because trained seasoned professionals don’t think in the same manner as the less experienced coder(s) responsible for the legacy code int eh first place.
Finally, (I’ll leave it to three to be nice to those few perl hackers who’ve read this far), after ten plus years of coding in perl, I’ve come to learn that the TIMTOWDI (There Is More Than One Way to Do It) mantra of perl is one of the biggest problems that arise from the language. It is this careless and dare I say reckless mindset which has led to so many atrocities in the professional coding world.
My point is simple enough to follow. Write readable code, as it is a defining factor as to how far you’ve matured in the field of software development. It doesn’t necessarily mean you are even that good at what you do, but what it does do is show how you understand a rudimentary problem that so many others have failed to realise. Readability Counts, and without it, we are truly lost.
Labels: Amateurs, C/C++, Design, Java, Lisp, Perl, Professionals, Python, Readability, Ruby, TIMTOWDI
I’ve been rather busy recently now that our beta version of software where I am employed has made its way to production. Since that has transpired, all of our Trac entries can be attacked in a more systematic manner. Here’s a little rundown of what I’ve been doing.
Handling my son’s integration into his newest school year endeavour, as well as my wife’s into hers. She just completed her masters degree and is starting her second year (first full year) as a teacher of Biology.. to kids born the year that she and I graduated (together) from high school.
Creating the backlog of CodeDevl.com podcasts, and editing. I never realised exactly how much time it takes to edit a podcast recording. For every five minutes spoken, there are ten minutes spent editing and cleaning up.
Learning and implementing GIT version control/repository software at our place of employ, as well as my local network as a replacement for Subversion (SVN).
Wrote a python (base classes pure) application which handles all migration of beta software to both the GIT repository paths as well as handling moves to production (including automated changes to certain header includes). I’m rather happy with this application as it has saved many issue from transpiring. Due to the haphazard manner in which some of the code base is arranged (particularly the beta vs. live paths), problems can and have occurred, hence my reasons for taking the initiative to create said program.
Additional work with re-learning Java, and keeping current with other technologies (Python 3K/3000/3.0), Javascript, Ruby, Smalltalk concepts and to a lesser degree Lisp (not including additional emacs functionalities).
I do promise that I will be continuing to update both this written journal as well as the podcast site, and just wanted to let those reading that I have not dropped off the face of the earth, just immersed myself back into the changing flow at my workplace.
Labels: Automation, GIT, Javascript, Life Cycle, Podcasting, Python, Ruby, Smalltalk, Subversion, SVN
The solution was sitting right in front of me all along, the standard library's 'pickle' module (or alternatively the 'cpickle' variation for speed's sake). Due to the issues presented in a virtual world simulation the topic of object blueprints and simulation population ease come to mind rather quickly. The best environment for manipulating these new objects will ultimately be via the methods provided by both the the SimulaE package (SimulaE.loadObject(filename_to_load, [optional_load_path]) as well as at the code level in the parent class in SimulaE.SimulaeObject.saveObject(filename_to_save_as, [optional_save_path]).
By going this route it has been realised that a simple loop and/or script-like routine could be used to create all the generic object templates needed for design platforms, and for customisation all one need do is use the loadObject routine, make the necessary alterations and re-save said item as a more concrete, concise and specialised object, named appropriately of course.
Let us take an example of a room type object (more simply put, a larger container object). We'll use simple constructor information here for the sake of staying on focus. We're going to make a 4 metre x 5.5 metre dining room, with a 2.75 metre ceiling, simple called "Dining Room". It will be empty sans an already pickled to storage butler object we've created for the sake of this example (whose filename is simply "butler_jeeves"), though future discussions on SimulaE's container and stack loading methods are forthcoming.
import SimulaE
generic_dr = SimulaE.SimulaeObject(name='Dining Room', width=4.0, length=5.5, height=2.75)
generic_butler = SimulaE.loadObject('butler_jeeves')
generic_dr.addToContents(generic_butler)
generic_dr.saveObject('diningroom4x5.5x2.75wButler')
We now have a pickled version of this generic dining room of the aforementioned dimensions, sporting its own copy of Jeeves the butler, saved to a physical file on whatever storage device we're set to utilise. We can overwrite said object by simply saving the item with the filename as it exists on whatever storage device is in use. There is also the flexibility of specifying alternative file save and load paths with allow for multiple parallel simulations and/or individuals to work in safe separate but equal spaces, very much along the lines of a Unix mentality. Another advantage by working in this manner is being able to create a path full of simulation objects and copy said path en masse for alternative and/or backup purposes.
Either way you slice the pickle (module), it proves to be quite (ful)filling, making one feel quite (programmatically) satisfied.