October 10, 2006

Meeting at 19:30 - location: The Amiado (Students.ch) offices

Presentation

pro-js.pdf

pro-php.pdf

Results: Javascript sucks harder than PHP(!?!)

Individual Topic Ratings

Overall Suckage

PHP: ******************************************************************** (68)

Javascript: ************************************************************************** (74)

Javascript sucks harder!

The Suckometer

#!/usr/bin/perl -w
use strict;
use QWizard;
use IO::File;

my $RESULTF = $ENV{HOME}.'/suckometer.txt';
if ( -f $RESULTF ) { `rm $RESULTF`; }

my $TOPICS = [
	      'Syntax',
	      'Data Types',
	      'Scope / Namespaces / Packaging',
	      'Standard Library',
	      'Extension Libraries',
	      'Procedural Programming',
	      'Object Oriented Programming',
	      'Functional Programming',
	      'Meta Programming',
	      'AOP',
	      'Networking',
	      'Error Handling',
	      'Multi Tasking',
	      'Reflection',
	      'Garbage Collection',
	      'Security',
	      'Tools',
	      'Server Side',
	      'Client Side',
	      'Final Rave',
	      ];

sub score {
    my $answer = shift;
    $answer = lc($answer);
    my $answers = {};
    $answers->{'ok'} = 0;
    $answers->{'annoys'} = 2;
    $answers->{'sucks'} = 4;
    $answers->{'sucks hard'} = 6;
    $answers->{'blows'} = 10;
    return $answers->{$answer};
}

sub record {
    my $in = shift;
    my $fh = IO::File->new;
    $fh->open(">> $RESULTF");
    print $fh "$in\n";
    $fh->close;
}

my %primaries =
  (
   'topprimary' => {
		    title => 'The SuckoMeter',
		    introduction => 'What sucks harder - PHP or Javascript?',
		    questions =>
		    [{ type => 'label',
		       name => 'justalabel',
		       text => 'Please answer the following questions...'}],

		    post_answers =>
		    [sub {
			 my $wiz = $_[0];
			 foreach my $t ( @{$TOPICS} ) {
			     $wiz->add_todos(-late, "primary_$t");
			 }
			 $wiz->add_todos(-late, "last");
			 return 'OK';
		     }],

		    actions =>
		    [sub {
		
		       my $add = sub {
			 $_[0] += $_[1];
			 for(1...$_[1]){$_[2].='*'};
		       };
		
		       my $php_total = 0;
		       my $js_total = 0;
		       my $php_bar = '';
		       my $js_bar = '';
		
		       foreach my $t ( @{$TOPICS} ) {
			 $add->($php_total,
				score(qwparam("php_$t")),
				$php_bar);
			 $add->($js_total,
				score(qwparam("js_$t")),
				$js_bar);
		       }
		       my $result = 'PHP and Javascript suck equally!';
		       $result = $php_total > $js_total ?
			 'PHP sucks harder!' :
			   'Javascript sucks harder!'
			     unless $php_total == $js_total;
		       my $result = ['',
			       '-------------------------',
			       "Overall Suckage",
			       '-------------------------',
			       '',
			       'PHP:',
			       "$php_bar ($php_total)",
			       '',
			       'Javascript:',
			       "$js_bar ($js_total)",
			       '',
			       "$result",
			      ];
		       record(join("\n",@{$result}));
		       return $result;
		     }],
		   },
  );

foreach my $t ( @{$TOPICS} ) {
    $primaries{"primary_$t"} = {
	title => "$t",
	introduction => "$t : which sucks harder?",
	questions => [{ type => 'radio',
			name => "php_$t",
			text => "PHP $t:",
			values => [
				   'Blows',
				   'Sucks Hard',
				   'Sucks',
				   'Annoys',
				   'OK',
				   ],
			    default => 'OK'
			       },
		      { type => 'label',
			name => 'seperator',
			text => sub {
			    my $s = '';
			    for(1...30){$s.='-'};
			    return $s
			    },
			    },
		      {	type => 'radio',
			name => "js_$t",
			text => "Javascript $t:",
			values => [
				   'Blows',
				   'Sucks Hard',
				   'Sucks',
				   'Annoys',
				   'OK',
				  ],
			default => 'OK'
		      },
		     ],
				post_answers => [
					sub {
					    my $res =
						   sprintf(
							   "%s: PHP - %s, JS - %s\n",
							   $t,
							   qwparam("php_$t"),
							   qwparam("js_$t")
							  );
					    record($res);
					    return "OK";
					}
					   ],

	};
}

$primaries{'last'} = {
		      title => 'Ready to calculate',
		      introduction => 'The Suckometer is ready to process the results',
		      questions =>
		    [{ type => 'label',
		       name => 'justalabel2',
		       text => 'Ready to find out?'}],
		     };

my $qw = new QWizard(primaries => \%primaries,
		     title => 'The SuckoMeter',
		     no_confirm => 1);

# $QWizard::qwdebug = 1;

$qw->magic('topprimary');