RSS

Can’t decide between Python and Ruby !


The thing is I can’t find a solid intro to cs/programing book that uses Ruby.I’ve been reading Beginning Ruby from novice to professional , and it gets into OOP too soon like at page 130 or something.Because I come from Pascal I’m used to procedural programing and switching to OOP so soon gives me a headache.I understand the theoretical side of classes , objects , local , global , class and object variables , methods etc. But when it comes to writing a program I’m used to program things in a liner order.With OOP it’s like jumping all around the place.
On the other hand Python books for beginners introduce OOP much later and there is a bunch of them you can pick from , like Python Programming: An Introduction to Computer Science from John M. Zelle , Beginning Python: From Novice to Professional by Magnus Lie Hetland , Practical Programming: An Introduction to Computer Science Using Python etc.
Both languages are very similar.Ruby 1.9.2 is generally consider to be faster the Python3 , but if I’m look for a fast language I’m going to learn Java or C++.I love the “magic” of Ruby and doing things in different ways , but from what I can see Python community is more noob friendly.Like there is a section for beginners in the Python forum , there is the python tutor mailing list and whats more important there are more book filling the gap between total beginner-intermediate programers.
I’m starting to think that picking Python and then Ruby could be possibly a better choice then the other way around ! Anyway I’ll try to stick to Ruby for now and learn more about Python on the side.But I might change in the near future.

 
6 Comments

Posted by on April 22, 2011 in Programing, Python, ruby, Ruby 1.9

 

Tags: , , ,

interactive_editor for WindowZ !


I’ve been using irb lately and I find it to be a good tool to experiment and learn about the language.Since I’ve been doing the same thing in Python using the IDLE I always missed the text editor that IDLE had and irb didn’t.Today I’ve found out about a gem called interactive_editor that makes you run vi/vim inside irb so you can edit your code and run it in irb.The problem was that all the instruction I’ve found were for Linux and there was non for Windows so I wanted to write a simple tutorial how to do it in Windows.

Firstly I assume that you have ruby and irb instaled, and that you know how to install gems using the “gem install name_of _the_gem_here” without the quotes command in cmd (to run cmd go to start type cmd and press enter).

You need to download and install vim.The next step is to edit the PATH so you can start vim from windows console.To do this right click on My Computer go to Advanced system settings and then to Environment variables on bottom of the window.In system variables you need to find path and click edit.Then add “;D:\Program Files\Vim\vim73″ without the quotes at the end of the line (note: you need to enter the file path to the vim folder , on my pc it’s D:\Program Files\Vim\vim73 your might be different.)Or just follow this.

To test if everything is ok type vim in cmd.You should be in vim editor if you did ok.

Next in cmd type “gem install interactive_editor” without quotes.This should install the gem on your system.

You also need to create a .irbrc file in your home directory.The home directory is usually the first directory that you are in when you start cmd (e.g: C:\Users\User_name ).You can do this by typing “edit .irbrc” without quotes (dahhh :D ) in cmd.Then an editor will start.You need to enter:

require ‘rubygems’
require ‘interactive_editor’

Save the file and you are all most ready to go.

Next time when you start irb you can type vim and it will start the editor in your irb.
I guess all I need to do now is to learn how to use vim ! :)
Thx to the author of this post and the creator of this great gem.interactive_editor

 
Leave a comment

Posted by on April 14, 2011 in ruby, Ruby 1.9

 

Tags: , , , , , ,

Guessing some numbers !


I’ve been working with the Head first Programing book and in the first chapter there is a small guessing game that is used to explain things like variables , input , branching , loops . conditionals etc.The program in the book gets a random number from 1 to 10 and it tells you when you input a number if your guess is correct , too high or too low.Then it repeats / loop until you get the correct answer.Anyway I’ve done the same thing using Ruby this time and I only changed the range of number from 10 to 100 to keep it more interesting.Here is the code:

puts("Welcome!")
number = Random.new.rand(0..100)      #generates a random number between 0 and 100
guess_number = 0
while guess_number != number
  puts("Guess a number between 0 and 100 : ")
  guess_number = gets.to_i
  if guess_number > number
    puts("Too high!")
  else
    if guess_number < number
      puts("Too low!")
    else  
      puts("You win")
    end
  end
end  
puts("Game over!")
gets
 
Leave a comment

Posted by on April 5, 2011 in Programing, ruby

 

Tags: , ,

Head first programing !


I’ve been searching for a good intro to programing or computer science book for some time now and I think I finally found one worth reading.Head first programing is a book from the head first series published by Head First Labs.This book doesn’t assume you have any programing experience so it’s a great start for a guy like me.I’ve read most of the book now and I can say that it’s one of the most interesting technical book I’ve ever read.The thing that impressed me the most was the examples in the book.Most of the examples in the book were about programs solving real life problems.I find this really helpful because when you are just starting to program you can have a lot of information about variables , branching , loops , modules etc. but if you don’t know how you can implement these tools to solve real life problems then the knowledge is useless.Just by reading 5-6 chapters of the book and by doing some of the exercises I’ve learn a lot about programing, things like importance of commenting and not repeating your code , getting data from files and the web.This book teaches you how to program it’s not teaching you a programing language. Well it’s using a programing language to present the concepts of
course, but the focus is on the programing process not on the language.The book is using Python 3 as the language of choice.Python and Ruby have a lot of things in common when it comes to programing languages.They are both interpreted , general purpose languages that support multiple programing paradigms.The syntax in both Python and Ruby is simple , so you can spent a lot more time learning the concepts of programing and not on learning the syntax.
I’m planing to read the whole book and do the exercises in Python and then start again and do them in Ruby.I’ll try to post some of the code done in Ruby and compare it to the code done in Python.I’ll try to use a reference book or Google to learn about Ruby syntax and solve my exercises.I hope this will be a fun thing to do !!

 
Leave a comment

Posted by on April 3, 2011 in Programing, Python, ruby

 

Tags: , ,

Guides for non programers


When it comes to learning a new subject I always start by searching the topic on Google.Not having any useful guides and information can be frustrating. There are a tons of pages out there that claim they are giving you a good tips on how to become a programmer or how to learn a programing language. Most of these guides are just superficial or misleading , some are written by people that have no idea about programing and programing languages them self.Finding a good guide that will explain step by step what you need to do is a hard thing.I’m lucky I’ve found the How to become a programmer guide on Wikihow.This is the most informative guide for a guy like me that has no or very little knowledge about programing.I’ve learned a lot more things by reading and following this guide , like program conception techniques , databases , programming paradigms , difference between web and desktop application programmers.I still have a lot of reading to do, but if there is a one place I recommend non-programmers should start then this is it.

 
2 Comments

Posted by on March 26, 2011 in Programing

 

Tags:

Goals and Expectations


So I’ve decided I would like to learn how to program.I guess there are a lot of people like me out there that always wanted to do something but for some reason they never do it.I think that one of the main problem is that people don’t set clear goals and expectations about the thing they would like to do or learn how to do.
So I intend to spend at least one hour per day for 365 days trying to learn the basics of programing.

1. My primary goal is to acquire basic programing skills , or as many beginner programing books would like to say learn How to Think Like a Computer Scientist.
2. I expect to learn some of the syntax of the Ruby programing language.
3. Learn about programing, programing languages and programing tools in general.
4. At the end of the year I want to be able to implement some of the knowledge in solving real-life problems.Also if I’m able I would like to do a project on my own or collaborate with others on an existing project.

In order to do so I plan to read at least one Introduction to computer science or Introduction to programing book , at least one Ruby book for beginner programmers , at least one book about another programing language.I’m going to try to solve all exercises that are in the books.Search for help online and participate in discussions on the topic.
Also I will try to post as much as possible about the process of learning how to program and the obstacles I’ll met on the way.First of all by writing this blog I want to keep a track of my progress and improve my English writing skills.Then I hope that it will be a nice reference for people trying to do the same thing in the future.
It’s a lot easier to do things when you know what to expect !

 
Leave a comment

Posted by on March 24, 2011 in Intro, Programing

 

Tags: ,

OK let’s do this !


Hello World ! Probably the most common two words when it comes to writing your first computer program.
Computer programing if one of the things that I always wanted to learn how to do but for some reason I never had the motivation for it.Since I was a young boy I remember wanting to own my own computer so I can do all the magical things that the so called hackers did in the movies , they were mainly cracking into systems but hey, at the time I didn’t even know the difference between hacking and cracking.
So when I got my first PC I was ecstatic.But after a while I learned that using this thing the way I wanted is not the easiest thing in the world.This was the time when having a internet connection in my country for common people was a rear thing , so finding more about how computers work was hard at that time for me ( I confess PC games kept me occupied for some time ! ).
Then in my first year of high school I had an introduction to computer science class.I learned some basic things about computers: hardware , software , input , output , word , excel … and a thing called Pascal.Well Pascal was a programing language that we used to cover some programing basics , and at the time a had a great time doing basic computations and for the first time using my PC to actually do something that I need.
At the end of the year I was able to write some beginner Pascal code but I didn’t have problems to solve with the knowledge I had.For every “problem” I had there was already a solution/software out there.So I tragically decided to stop learning more about programing.
I went to college that had nothing to do with programing or computer science , so I forgot even the basic things I’ve learned.Now when I find my self at the end of my studies I have a lot more free time to do stuff just for fun.So I decided to go back and give programing another try.I decided I’ll invest a one hour per day ( at least ) for a year to learn more about the thing I wanted to do since I was a child.
Will I make it ?? Who knows , we are going to find out a year from now !!!
//

 
2 Comments

Posted by on March 24, 2011 in Intro

 

Tags: ,

 
Follow

Get every new post delivered to your Inbox.