ZyeLabs http://zyelabs.net WEB APPS, STRATEGY, MASHUPS & OPTIMIZATION posterous.com Mon, 30 Jan 2012 00:20:00 -0800 [Infographic] PHP vs. Python vs. Ruby http://zyelabs.net/infographic-php-vs-python-vs-ruby http://zyelabs.net/infographic-php-vs-python-vs-ruby

Programming-language-3-620x3450

via RWW

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat
Fri, 20 Jan 2012 05:46:00 -0800 Why (some) programming languages are actually designed well http://zyelabs.net/why-some-programming-languages-are-designed-w http://zyelabs.net/why-some-programming-languages-are-designed-w

I came across this article on twitter, "Why Aren't Computer Programming Languages Designed Better?"

Which say's: 

 According to findings by researchers from Southern Illinois University, this reaction isn’t just because you’re a n00b: they found that Perl, a major programming language used by untold zillions of developers, is no more intuitive to novices than a language with a randomly generated syntax.

and

So why aren’t all programming languages designed this way? "I doubt that most language designers meant for their languages to be hard to understand or use," Stefik says. "The problem is that programming languages are created either by committee or by extreme technical wizards with magical math powers. The broad computer science academic community has not paid a tremendous amount of attention to programming language usability. I think that our discipline mostly uses anecdotes to argue about programming languages. As such, it is no wonder that the arguments get heated."

...

Why shouldn’t those "interfaces" be as humanely designed as the ones we tap and swipe?

First, it's no real surprise that perl would be more difficult to learn than a randomly generated language. Perl is often regarded as one of the most difficult languages to maintain.  I am not going to rehash all of the commentry against perl again, you can read this excelent article for that. A few extracts:

One of the first things I discovered I didn't like was the syntax. It's very complex and there are lots of operators and special syntaxes. This means that you get short, but complex code with many syntax errors that take some time to sort out. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
sub soundex
{
  local (@s, $f, $fc, $_) = @_;

  push @s, '' unless @s; # handle no args as a single empty string

  foreach (@s)
  {
    tr/a-z/A-Z/;
    tr/A-Z//cd;

    if ($_ eq '')
    {
      $_ = $soundex_nocode;
    }
    else
    {
      ($f) = /^(.)/;
      tr/AEHIOUWYBFPVCGJKQSXZDTLMNR/00000000111122222222334556/;
      ($fc) = /^(.)/;
      s/^$fc+//;
      tr///cs;
      tr/0//d;
      $_ = $f . $_ . '000';
      s/^(.{4}).*/$1/;
    }
  }

  wantarray ? @s : shift @s;
}

However, even this isn't really bad. The Perl Journal has conducted an Obfuscated Perl contest. The winners are here . Be warned, though. These programs gives the word unreadable entirely new and previously unimagined meanings. (And no, this isn't an argument for Perl being unreadable, but mainly included as a funny and curious item.)

Programmers and readability

Some people reading this have complained that 'But anyone can write unreadable code in any language!' and this is certainly true. However, some languages seem to encourage hard-to-read code, while others seem to discourage it. 

If we were comparing Perl & Python, i would say that Perl is actually the more 'Human' language (But more difficult) Why?

Because perl was designed like a language the inventor was actually a trained linguist, see this :

 

Multiple ways to say the same thing

This one is more of an anthropological feature. People not only learn as they go, but come from different backgrounds, and will learn a different subset of the language first. It's Officially Okay in the Perl realm to program in the subset of Perl corresponding to sed, or awk, or C, or shell, or BASIC, or Lisp, or Python. Or FORTRAN, even. Just because Perl is the melting pot of computer languages doesn't mean you have to stir.

 

All of these 'features' of perl, make it difficult to learn, difficult to read, and difficult to maintain. People who program in perl actually see it as a matter of pride to write Obfuscated code. It can also be used for Art.

Now, lets compare this to Python:

  • It forces you to write readable code, by using whitespace as part of the language
  • There is usually only one way to do something, avoiding confusion , ensuring you get expected results, resulting in reliability
  • See a like for like comparison between perl python and ruby
  • There are too many advantages to list

From the history of python blog (Highly recommended for an inside look by Guido on the design of python)

Although I will discuss more of ABC's influence on Python a little later, I’d like to mention one readability rule specifically: punctuation characters should be used conservatively, in line with their common use in written English or high-school algebra. Exceptions are made when a particular notation is a long-standing tradition in programming languages, such as “x*y” for multiplication, “a[i]” for array subscription, or “x.foo” for attribute selection, but Python does not use “$” to indicate variables, nor “!” to indicate operations with side effects.

 

Python was created first and foremost with usability in mind.

While i agree, languages should be more 'usable' to make things easier for non coders to pickup, it should not be easy at the expense of flexability and features.

There is nothing wrong with a language designed by a mathematician as it follows the principals of logic, which is the only language computers speak. They should not be designed to be more 'Human', as you could end up with programming languages that look like spoken languages such as Perl.

Python

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1415468/ismaild_crop.jpg http://posterous.com/users/f99D0xwX8 Ismail Dhorat Ismail Ismail Dhorat