Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: What language should I learn?

by BrowserUk (Patriarch)
on Jan 08, 2012 at 09:37 UTC ( [id://946836]=note: print w/replies, xml ) Need Help??


in reply to What language should I learn?

in which I can make an easy(ish) transition from Perl?

For something completely different, but which will improve your Perl in ways you never dreamed of and just might become a favorite for recreational programming, take a look at Pure

This is not an "easy transition" in the sense that is it not 'perl with objects and nothing but objects'; or 'perl with bondage and only one way to do things'; or even 'perl without the sigils and memory management'. That is, you won't find yourself writing a perl program and then tweaking the syntax a bit to make it work in Pure. Pure is resolutely and unashamedly a Functional Programming language.

But is will be an easy transition in the sense that it is a dynamic scripting language. So no huge compilers and endless compile&link phases; no static types disciplinarianisms, nor the need to take a degree course to work out who Church was. Add a number to a string, and if the string contains a number, that's cool.

Just a simple edit/run development cycle with automatic memory management and useful error messages. And concise yet powerful code. As a teaser, here is a complete Sudoko solver written in Pure:

* Sudoku example by Peter Bernschneider. */ /* This is an example Sudoku solver inspired by the Queens example whi +ch terminates in reasonable time. m1 is ZEIT-Online Sudoku of Dec 6th +2009. Interactive usage example: sudoku1 m1; */ using matrices; using system; m1 = {0,0,3,9,0,2,0,0,0; 0,0,0,0,0,0,2,3,1; 0,0,0,0,0,3,5,0,9; 5,8,0,0,0,0,0,0,0; 0,0,6,0,1,7,0,0,0; 7,2,1,4,5,0,0,0,0; 0,4,5,0,0,1,0,8,0; 0,3,9,7,0,0,6,0,0; 0,0,0,8,6,4,9,5,0}; m2 = {0,5,0,0,6,0,0,0,1; 0,0,4,8,0,0,0,7,0; 8,0,0,0,0,0,0,5,2; 2,0,0,0,5,7,0,3,0; 0,0,0,0,0,0,0,0,0; 0,3,0,6,9,0,0,0,5; 7,9,0,0,0,0,0,0,8; 0,1,0,0,0,6,5,0,0; 5,0,0,0,3,0,0,6,0}; sudoku1 m = take 1 (sudoku m); sudoku m = search (0,0) m; search (i,j) m = [m] if i>=9; = search (suc (i,j)) m if m!(i,j)~=0; = cat [ search (suc (i,j)) (set (i,j) n m) | n = 1..9; safe (i,j) n m ]; safe (i,j) n m = all (~=n) (row m i) && all (~=n) (col m j) && all (~=n) (sub (i,j) m); sub (i,j) m = m!!(spli (i div 3), spli (j div 3)); spli k = 3*k..3*k+2; set (i0,j0) n0 m = { if (i,j)==(i0,j0) then n0 else m!(i,j) | i=0..8; j=0..8 }; suc (i,j) = (i,j+1) if j+1<9; = (i+1,0) otherwise; __show__ x::matrix = strcat [printi j (x!(i,j))|i=0..8; j=0..8] + "\n" with printi 0 = sprintf "\n%1i"; printi _ = sprintf "%1i" end;

It will make you think differently about programming, but that is all to the good. Even if it doesn't become a favourite for solving real world programming problems, a little exposure to FP will have good knock-on affects on the way you code in Perl. And Pure has the shallowest learning curve of any of the at least 10 FP languages I've looked at.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://946836]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-25 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found