Tuesday, July 31, 2007

The (role playing) games we play

RPG games have been around for years now, and with the onset of computerized RPGs they have evolved beyond games once played by groups of spotty faced geeks. with the invention of the MMO world , RPGs are more popular today than ever in human history[1]! There are many elements that make RPGs fun, but i want to focus on one impotent aspect of the role playing world - the classes and levels system. when you play a role playing game you need to increase your experience to gain more power and magic. you have to learn to use your powers wisely if you are to progress. this crucial concept- experience-based power-wielding ability - is missing from the real world. especially in the software world.

I have been a programmer for a while now, and I've seen horrors coded in many languages. I've seen all kinds of dangerous 'language features' that should not be left unattended for the inexperienced programmer to abuse.
In the same way you will not let a ten year old operate heavy machinery while intoxicated(well, maybe for some harmless fun), you really shouldn't let computer science students use parameter overloading in c++ when they can barely comprehend the concept of functions.

This is why i think we should learn from the RPG world and implement a class and level system for the coding world. the details of such a system are presented here:

First you start apprenticing (Levels 1-3) and you are only allowed to use non languages like LOGO or HTML, after a while when you have proven yourself worthy, you might be allowed to progress to more advanced scripting
[2] (Levels 4-7).you can use java/vb scripting but only in a web based environment, where the browser prevents you from causing too much harm. once you gathered more experience (Level 8-10) you will be allowed to choose a VB programmer class. experts[3] agree that VB is not really a programming language, so anyone who chooses to use VB is forever forbidden from writing code in any other language.
Anyone who tries to code in Perl will lose all their execution privileges, not that it matters since it seems Perl programmers are more concerned with how many "kewl" things they can do in a single incomprehensible line of code, they wont actually notice that the code doesn't execute.

if you decide to program in a real language you will be allowed to select one of the real languages (c, c++, java, c#, assembly is reserved to levels 50+) each language will have it's own restrictions for a beginner.

C :
beginner c programmer can only use if, for, while, switch, single parameter function (you can choose between return param or function param), and 3 global variables (any more and the beginner gets confused). loops cannot be nested until level 13, you get a nesting level for each level above 13. altho, if you need beyond 3-4 nesting levels for anything you will be converted into a VB programmer. function within function calls have a limited stack of 3 calls. this effectively disables the beginner from using recursion, and also helps reduce their confusion with all these functions calling functions. the use of pointers is only allowed from level 15, void pointers from level 20, you get a new level of pointer nesting beyond the first for every level beyond 21, function pointers starting level 35, malloc is disabled until you reach level 30. you get 1 ifdef per level starting with level 12, programmers above level 20 can use as many as they like.
syntactic sugar like using ++ is only allowed from level 14 and on.
copy and paste functionality is disabled in the IDE until level 18 to prevent use of the poor man's code reusability (lazy programmers that cant refactor things into functions).

C++ :
all limitations for c also apply to c++, with extra limitation for operator overloading (level 50+). the required use of classes lowers the required level for use of pointers to level 10 (entry level for c++) but only class and primitive pointers. the use of function pointers is forbidden in c++ (object orient damn it!) until level 50+ those who practice the black art of function pointers and operator overloading will be periodically reviewed by the great council :the ICCC[4]. any transgressions will cause immediate demotion to either VB programmer or perl coder.

Java:
well, no malloc and pointers, so that makes life a little easier, also use of classes is enforced by the language, and no param overriding or ifdefs so you can do less harm to begin with.
the limitations for java programmers like function call stack size, loop nesting etc. is the same as in c++ and c. the catching of Exception is forbidden for programmers under level 23, RuntimeExceptions can only be caught by programmers level 26+. NullPointerException cannot be caught by anyone (except by catching more global exceptions) attempt to catch a NullPointerException will result in immediate demotion to VB programmer. the use of Vectors is allowed starting level 20 but allows only for storage of primitive wrappers and strings. When you reach level 25 you can choose other things, but you must take a test on garbage collection before you can advance to level 25. passing the test also allows the use of HashMaps. reflection can only be used from level 30+. the use of threads is allowed from level 40 and on, attempt to use the double lock pattern will result in a hearing before the great council which may result in a 3 week transfer to customer support. inheritance depth will be limited to 2 until level 15, you get an inheritance depth level for every level beyond 15. the use of anonymous classes is allowed starting level 18.
using JNI is allowed starting level 45 and requires knowledge of either c/c++ of at least level 20.

C# :
mostly the same as java, but with the reintroduction of pointers and limited operator overloading. unmanaged code + operator overloading require a level 50 c# programmer.
c#/java programmers get a bonus level in the other language for every 2 levels they get their native language.

You too can help improve the future of coding, coders, and software in general by joining the great council and adding new, more draconian restrictions on low level programmers (only level 40+ programmers are allowed to join (but not vote). you get one vote[5] per level starting with level 50). Join today by leaving your email address in any public website or forum and get free Viagra commercials, exciting business opportunities from Nigeria and more!




[1] - well, known human history, or rather ... human history that is known to me...which is a somewhat limited scope..but , well, it happened so long ago that no one* could seriously say they care about it..

*- no one except old people. it seems that at a certain age a lot of people start caring about history. i think it might be driven by their quest to prove everything was better in the good old days, and everything sucks now. then again, it could be that they are simply bored...

[2] - OS scripting not included. if you wanna write OS scripts you can change your class to Sysadmin, of course, you'll have to apprentice as annoying user, then progress to user, windows installer, super user, computer tech, and finally sysadmin. level 1 sysadmin can only maintain windows servers, only starting level 10 are you allowed to even see a linux/unix system. attempting to do so earlier can result in sever shock and sometimes death. the lack of a mouse based gui system has caused many inexperienced sysadmins to lose their minds and start clicking on random monitors. before the LCD days this often ended in electrocution .

[3] - an expert is anyone programming in any of the real languages (assembly, c, c++, java, c#)

[4] - - International Council of Computer Coders (take that, I triple E) - not associated with the other ICCC

[5] - The votes don't count

Saturday, July 28, 2007

The rythm of writing

I sometimes find something lacking in the written word.
When i write there's a certain rhythm to the writing, i sort of expect the text to be read at a certain pace and intonation. all of this is lost in the written word and i always wonder how would this text 'sound' to someone else? can my particular way of expression cross over through the text?
I assume that people who know me and are aware of my style of conversation might be able to more accurately reproduce my rhythm from the text. but then again, i am not sure i can do this when i read their writings.

When i was in high school we where learning a Hebrew poem by Leah Goldberg called 'mi shirei ha ben haoved' (From the songs of the lost son. loosely translated) . Our teacher was reading the poem in a kind of empty voice, she was reading the words and sentences but she was ignoring the rhythm and intonation that to me where screaming from the page. it was just so obviously there. and the poet was obviously using it - the poem was build from three separate 'sub poems' and each had it own rhythm. eventually, when my teacher reached the last of the sub poems , which was the most obviously structured and had the most meaningful rhythm to it i couldn't take it any more. i stopped her reading and i asked why wasn't she reading the poem the way it was meant to be read? why was she leaving out the rhythm and intonation? she didn't understand what i was talking about and asked me to read it. there was a deep silence when i finished.

In a Hebrew bible you can find markings that details the precise way of expression for a word and a sentence. the precise tone , rise fall, rhythm and pace are described by numerous markings decorating the regular alphabet characters. certainly these symbols are not required in order to read the text and understand it and while i can read the bible , i do not know the meaning of all the different symbols that decorate it. the reason these markings are there is that the people who wrote the bible aspire to preserve not only the words but also the accurate 'sound' of reading the bible. there where no means of recording at the time, and since people wanted to preserve everything very accurately , they constructed a very elaborate and accurate method of conveying both the words and their pronunciation , rhythm, everything they could think of. add to that constant repetition and very strict methods of transferring the accurate knowledge of reading both the words and their decorations , and you get something very close to a recoding from two thousand years ago.

it would have been nice to have this sort of decoration, that way i could know exactly how my words would 'sound' to a reader. but maybe leaving the 'sound' to the reader provides some of what is called the 'power of the written word'. perhaps when you read the text to yourself, with your own internal voice , the words become more personal, more persuasive. maybe a bit more like your own thoughts than like someone else's writings.

Thursday, July 26, 2007

For the love of Embedded databases

mmm...there are a lot of dev blogs out there that focus on information for developers. they have guides, reviews and code samples.
i might do that (review, guide, code samples etc' ) from time to time, but really there's so much out there that i find it somewhat redundant to have yet another post on some tech or another.
the reason i am still posting this one is to share the results of some research, and to share what might happen when you fall in love with some crazy idea of embedded databases.

so , anyhow, today's topic is my experience with setting up O/R mapping and it's relational DB using .net.

first a short intro:
O/R Mapping stands for 'Object - Relational mapping' and it's a concept that makes databases a more useful , easier to work with thing. (it gets very close to making them worth while ;) ).
basically, it defines a way to easily map objects into database tables and structures. its a rather complicated problem when you start thinking about how to represent parent/child relations, or one to many ..or collection...joins...and other weird things db people like to do.
if you want more details, please check out the source of all knowledge for more details.

in the java world, there's only one O/R mapper worth its while - Hibernate. its a very powerful , well written , well maintained , open source O/R mapper.
the grate thing about .net is that its so much like java that all the cool projects out there started porting to .net (Spring, Log4Net, NUnit to name a few). its so much like java that you only have to learn how they renamed the classes and packages. the rest is pretty much the same.

anyhow, in the .net world there seem to be a few others. but i know the way the hibernate people do the job and i trust them more then some other projects. especially since they are amongst the few that are open source for .net . also, they already solved alot of the problems when they where writing the java version, so i guess they can do it better then other inexperienced dev's.
One other project i particularly liked the idea of was db4O. it used to be an open source, and is still free for non commercial use. its not actually an o/r mapper , but an embeddable object based database.
unfortunately , i am a commercial user , so we preferred the open and free option.

at first i thought i wanted an embedded database. it sounded so cool - no installation for the user, no DB administration for the user, none of the annoying hassle of a full blown DB.
sure, it wouldn't have the same performance , and it might have trouble working with too many concurrent users , but our project doesn't need either. but, as bono once said - love is blindness*.

since i already decided on hibernate , there was only the question of which db to use. this means we need a db with a dialect hibernate understands (one might think that SQL is enough of a standard , but as you soon find out, its very far from being standard. ). this gave me a very short list to work with. some databased i already knew and knew i didn't want :
Oracle - expensive and annoying
MS SQL - expensive and annoying, tho probably not as much as oracle
Access - not really a database
DB2 - expensive , annoying and made by IBM(to relieve and doubt - being made by ibm is a bad thing. one might think that its a big prestigious company , and it is. but their products suck. badly.)
so that left the databases i never heard about , and MySql. i'v always heard people say that its a grate open source database , and that everyone is using it. i'v never met someone who told me they where actually using it (they all use Oracle...those poor bastards)
now, MySql was such an obvious choice that i had to go with something else. and besides i was inlove with the concept of a the three no's of embedded databases : no-installation , no-configuration , no-administration.
so i checked out:
SqlLite - looked awful , no smooth integration with C# as far as i cared to look.
PostgreSQL - seemed nice but wasn't really embeddable.
Firebird - seemed nice and was also embeddable.
so i decided to give firebird a go. everything was fine for a while..it was a bit annoying to install it's driver and it took some effort to properly configure nhibernate due to some mistakes in their guide (which is very much unlike them , particularly since the corrections where present as user comments on the bottom of the configuration page) , but anyway, i got it to work. i was very happy with my shiny new embeddable database, and then DISASTER! i started getting : Internal gds software consistency check (cannot find tip page (165)).
hmmm... i thought to myself...this cant be a major thing, i just finished setting up the db, just committed my first tiny bit of data...i probably configured something wrong. quick google search turned up this page ... and...oh my...not only is this not a configuration error, its a critical DB error....database is completely destroyed....
Wait a minuet...when i started reading up on firebird ..all this backup, repair and fix tools where mentioned...1 .... + ..... 1 = wtf???
well, i guess i am fortunate it failed so soon. it would have been far more disastrous if these crashes only happened after we delivered it to our customers.

for the random google searching user i will state this plainly :
Don't use Firebird. don't use it with .net . don't use it with NHibernate. Just don't use it at all.

i ran some more searches, looking for some obscure database i might have missed but no go.
i also took a short look at the embeddable version of MS SQL express edition, but it only supports a max 4 gig database (it has other annoying limitations as well)..so it was useless for our app.

eventually i came back to MySQl... as it turns out , if you want a free, open source real DB...its the only serious option out there.

EDIT: read update at the end of this post , turns out MySql is not actually free.

it took half an hour to install and configure it to work with hibernate. and aside for an annoying problem i had starting it up (i wanted to use UTF8 as the charset because our users might need internationalization ..to set it up in MySQL you need to enter a freetext string, so i put in UTF8...turns out you have to put in lower case utf8....the the exception you get is just perfect "key not found in dictionary" worse yet - there's a gui and a ""test connection" which tells you everything is ok even tho you configured a nonexistent charset. how i figured it out i still don't know..i guess you come to expect silly things like that when you do this sort of work long enough) but after that everything seems to be working.. no complete database crashes for no reason , fast responses, and some nice db management tools.

As for my initial infatuation with the concept of embedded db, well, they** say "you never forget someone you loved"..so i still think some day embedded db's might be something we take for granted in every application. in the mean time we can all tell everyone that everyone is using mysql.

Join us next time for "Transparent Controls or: how i learned to stop trying and hate windows forms"


UPDATE (8/10/2007): German Viscuso mentioned that MySql isn't actually free. its distributed by a dual license - the dirty trick fake open sources use (free means free. not 'free under the following conditions') - a GPL infective**** or a Commercial license. so we turned to the only available alternative : PostrgreSQL. supported by NHibernate, works flawlessly and most impotently , doesn't infect my company with an evil licenses (PostgreSQL is distributed under BSD license - almost completely free. basically all they want is the credit for the db they wrote...) .


* - i told you it was the source of all knowledge :)
** - 5 points for anyone*** who guesses which happened first - i thought up the line, or i saw the quote in that link.
*** - only one vote per ip , the points don't matter.
**** - GPL is like a virus - if you want to use something licensed under GPL, you have to use GPL yourself. ad infinitum. they even have a philosophy as to why they have to make you be just as 'free' as they claim they are. so , in the eyes of the GPL people - software should be 'free' as long as they get to define the meaning of freedom.

Wednesday, July 25, 2007

Don't panic

at first i thought i might title this "the evolution of ui" but im not a UI expert, im mostly a UI user , and sometimes a UI designer.
What i would like to say tho, is that i like the direction new UI is heading. back in the DOS days, you where happy if someone was kind enough to give you a text based screen with some text boxes you can tab through. then this new "windows" fad came up. and alot of people where quite skeptical of this concept. it's sad to say that even in these modern times , when even the most dedicated linux* , who compiles his own kernel and in the mean time (it could take days , seriously ) argues which editor is better, VI or EMACs (if they had just asked me i could have ended the discussion and tell them the simple truth - they both suck :) ) have probably seen, if not used , a mouse controlled GUI based operating system , there are still people out there who refuse to join the civilized world of modern UI.

See, when people got their hands on GUI's and some GUI dev tools, they started going crazy. its like the first days of the internet, some companies built html authoring tools and suddenly everyone had a "homepage" , and they where ugly. i would have supplied links to some , but i oppose that sort of thing and i refuse to increase it's google score. for interesting result, try searching for "virtual reality glove" (yeh, i know...whatever happened to the whole VR thing?) and click on the first link..check out the wonderful 'scrolling' back button at the bottom of the page, and follow twice for a particularly vivid reminder of how most of the web used to look.
anyhow, people did some terrible things on the old GUI's, they started putting textboxes and images and other ugly things all over the place, and it only got worse as time passed. UI's became more cluttered , more buttons more menus with more options. have you ever tried enabling all the possible toolbars in word 2003? not to mention try and reach every possible setting available on the menus, submenus, and subsubmenus (maybe there are subsubsubmenus also, i never had the patience to find out). its not the worst of it. word is a "user" application, application for programmers or other professionals are much much worse , try your average CAD software for a taste of how horribly complicated UI can be. but this new trend of minimalist UI is wonderful.
people finally realized that cluttering their users with useless options in hundreds of unreachable submenus is not such a good idea. that maybe there are more useful features and , god forbid, LESS useful features, or even features that are completely USELESS.
it's kind of like a revolution, the people have been abused for years with annoying cluttered overcomplicated UI and they finally rose up and said : no more! we will not have your irrationally placed options! we will not use your incomprehensibly selected icon toolbars! and we will never again surrender to your annoyingly popping windows asking us silly "Yes-No-Cancel-Abort" questions!
well, it would have been nice if it actually came from the users, but i suppose in a way it did. programmers, designers and on the rare occasion even software dev execs are all horrible UI users...i'd like to think they actually got fed up with all this cluttered nonsense.
its like adams wrote about in hitchiker's guide : if you just have the words "dont panic" in big friendly letters on the cover, you will sell a lot more books :)
i dont know if adams ever considered this analogy but having a nice , clean , simple UI with big friendly buttons and large friendly fonts is a lot like having "Don't Panic" printed in big friendly letters on the cover.



* - while usually refers to an operating system, i find that its more of a way of life, almost a religion, for most people who use it (the OS) , so in the same way one may be a Buddhist one may also be a linux (plural linuxs or maybe linuxi ? any linguists out there care to comment on this one?)

Welcome to my new blog

Hi everyone (well, future everyone...).
Welcome to my new blog.
this is jumping ahead abit, but i was really impressed with this blogging platform..
im not very well versed in the blogging biz, but i do have another blog in hebrew, and this blogging platform is just so nice...but more about that later.

i suppose the first post should have to do with a sort of mission statement, so here goes:
this is intended to be a blog about science, technology, programming, software in general and probably some other random things i think about.


back to the blogging platform, now the random reader (U(0,1)) might think that perhaps this is some kind of commercial for Google , or for blogger.com or whatever, but really its not.
i just like the "feel" of everything, i love that it took me 5 mins to set up the blog, that it has nice features like autosave for posts while writing, many nice looking and tastefully done templates (so what if i went with the first one ..i like the "word press like" feeling) but mostly i like the nice friendly clean uncluttered interface.

but enough about that.

anyhow, i hope you enjoy your stay, and please feel free to feed on my RSS , it has 20% of the daily recommended dosage of news and updates!

Yossi.