Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Rekeying a table - comparison in #Ruby #Perl and #Python

Albert knows Perl and Python, Barbara knows Lua and Ruby, Colin knows Perl, and Debbie is a dab hand at PHP. Eddie does Python, Perl and PHP and Fiona cooks a great dinner for Shrek. Gordon programs in Lua and PHP, and Harriet knows both Ruby and Perl. Who shall I ask for help on a Perl project?

The requirement to take a who series of records keyed by one field and rekey it by another is not an uncommon one, and it's something that Perl does very well - in fact you could say that it's an ideal application for Perl. Using a hash, you can read through each line of the data - each person's record - and build up a hash of lists which you can report from at the end, when you have read in all your records. The use of a hash, in which Perl can locate records by key very quickly, makes this operation efficient even for quite large data sets.

But Perl isn't in fashion as it was 10 to 15 years ago; people dislike some of the syntax such as the lack of a conventional OO interface and style, and they dislike the complexity of some of the statements (though they may delebrate their shortness_ - too many cases of % and @ and { and [ coming in a great long series. People worry about Perl's assumption that the programmer knows what he's doing (which can lead to some extraordinary results when it turns out (s)he didn't, and they're concerned at just how long they's been waiting for the first production version of Perl 6 - "we'll get it right, not rush it" the drivers of Perl 6 tell people; yes - that's good, but people can get a bit impatient after 10 years.

So other languages, which solve these issues, have become much more popular than they would have done if Perl 6 had been available in 2006. Ruby has been described as a sort of "Perl 5 and a half", and we see it moving from a single-application language (always used as part of 'Ruby on Rails') to a more general language. And Python, though it's been around a long time has very much come into its own - indeed Python, it transpires, was very much a language ahead of its time and is continuing to grow in popularity as Perl seems to be just gently plodding along in a quieter backwater.

The week before last, I wrote a Ruby program to invert a file of data as described at the top of this article, and I promised my delegates (I was giving a course at the time) that I would publish it here. I'm now writing this article seated in an train on my way to Germany to give a Python course, and I have taken the opportunity to recode the same application - for comparison - into Perl and Python.

"How about writing it in PHP too?" asks Lisa, seated beside me. No - I'm not going to encourage you to use PHP if this is the sort of thing you'll be doing a lot of. PHP's associative arrays use a different storage technique which have the advantage over Perl and Ruby hashes / Python dictionaries that they can be sorted, but the disadvantage that they get rather slower once you pile huge amounts of data in. In any case, there's already an example of analyzing teh same file for a particular language in PHP [here] which shows that - if you need to invert a little bit of data - you can do it easily enough.

Example sources ... [Ruby]i ... [Perl] ... [Python] ... and an example of how they differ:

  push @rz,$name if ($lang eq "PHP");

  if lang == "PHP": rz.append(name)

  rz.push(name) if lang == "PHP"

Course schedule - for Perl, Python, Ruby (and PHP and other languages too!) [here]
(written 2011-02-14, updated 2011-02-19)

Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
Q102 - Choosing your language
  [76] Learning to program in - (2004-10-07)
  [1990] Speaking all the languages - (2009-01-12)
  [2001] I have not programmed before, and need to learn - (2009-01-19)
  [2048] Learning to program in PHP, Python, Java or Lua ... - (2009-02-19)
  [2507] Admission - (2009-11-19)
  [2535] When should I use Java, Perl, PHP, or Python? - (2009-12-13)
  [2536] All the Cs ... and Java too - (2009-12-13)
  [2700] The same very simple program in many different programming languages - (2010-03-31)
  [2866] Ruby - how does it compare and where is it the right language? - (2010-07-11)
  [3558] Python or Lua - which should I use / learn? - (2011-12-21)
  [3619] Ruby v Perl - a comparison example - (2012-02-21)
  [3764] Shell, Awk, Perl of Python? - (2012-06-14)
  [3785] Programming languages - what are the differences between them? - (2012-06-27)

G908 - Well House Consultants - Language Comparisons
  [209] FAQ - Perl or PHP - (2005-02-11)
  [1582] Ruby, C, Java and more - getting out of loops - (2008-03-19)
  [1717] Q - Should I use Perl or Python? - (2008-07-23)
  [2755] Books in the store in the USA - still a portent of the UK market to come? - (2010-05-08)
  [2947] Teaching Lua to a Perl advocate - (2010-09-06)
  [3003] What will we be teaching in six years? - (2010-10-17)
  [3112] Public and private courses - subjects available for 2011 - (2010-12-29)

Back to
Web Sites - Subject to Advertising Standards from 1st March - check your sites
Previous and next
Horse's mouth home
Forward to
How far is something pictured from the camera?
Some other Articles
What is the Melksham Chamber of Commerce?
On consultations, car parking, and Melksham town centre
Train and boat journey - the passenger accommodation
How far is something pictured from the camera?
Rekeying a table - comparison in #Ruby #Perl and #Python
Web Sites - Subject to Advertising Standards from 1st March - check your sites
Can I take my dog by train? And other questions
Well house is strong - confirmed?
Journalism 101
Brown - or Mrs Sally Brown, accountant from Whitstable?
4759 posts, page by page
Link to page ... 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, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page

This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3169_Rek ... ython.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb