Learning Ruby advice needed

R

Rubist Rohit

While learning a new language, I find it very boring to read again the
same things like variable declaration, data types, loops etc. Somehow I
just brushed up quickly from a basic Ruby programming book, I learn fast
when I am working on a live project and read simultaneously.

With Ruby (and Python as well) there is a confusion for me. They don't
have a fixed IDE like Visual Studio for .NET. I am not dipping my hands
in Rails at this time but want to write simple Windows apps. to learn
the basic concepts. For this, I either need to learn wxRuby or FxRuby,
which are third-party implementations.

Please let me know how to practice basic Ruby? What type of applications
you wrote to practice and what topics you consider important before
jumping to Rails?
 
R

Regis d'Aubarede

...I find it very boring to read again the
same things like variable declaration, data types, loops etc.

So try to learn really different language like Prolog, Haskell, Pure,
Lisaac....
You'll be thrown enough for not being bored :)

... want to write simple Windows apps. to learn
the basic concepts. For this, I either need to learn wxRuby or FxRuby,
which are third-party implementations.

Gui framework are too complexes for basic learning.
I use Shoes (green-shoes), but it is perhaps too rubish for the basic
learn (it use systematically block with instance_eval, DSL ...)
IDE as Visual studio...

Use irb constantly, and a simple editor will be ok (sublime, komodo
edit...)
Please let me know how to practice basic Ruby? What type of applications
you wrote to practice

* simple script for file manipulation, web scrapping,
* Very little web application with CGI and/or Sinatra :
To-do-list manager, show task list/kill process, file explorer
Vector drawing to client canvas, ...

And one big principle: never learn in writing production
code; learn by practice on micro 'game' subject.
and what topics you consider important

* blocs, yield (try to never use 'while') ,
* singleton class (very specific to ruby)
* thread/join/queue,
* error catching/log
 
J

Johnny Morrice

Please let me know how to practice basic Ruby? What type of
applications you wrote to practice and what topics you consider
important before jumping to Rails?

Can't help with rails but here are a couple of fun ideas:

1. A tiny text-based game using the socket library (networked hunt the
wumpus?) Using the network is pretty easy in ruby if you are used to
doing it via the operating system.

2. Text-mode mandelbrot fractal. Easy if you were to only use one
character.

Damnit now I want to code these things.

Cheers
Johnny
 
R

Rubist Rohit

I don't understand how you all feel so comfortable with "irb". It is
good for one line syntax. I want to create a simple Windows app. where I
want to keep classes in a separate file and UI in another file.

How is Aptana Studio 3 that comes bundled with RadRails?
 
J

Johnny Morrice

I don't understand how you all feel so comfortable with "irb". It is
good for one line syntax. I want to create a simple Windows app.
where I want to keep classes in a separate file and UI in another
file.

Yes, store your code in files. It's The Way (tm).

But irb lets you inside of your code.

It's a good way to exploit the reflexive properties of ruby.

So say we're reinventing pygame and have a file at ui/screen.rb that
looks like this:

class Screen

# Draw a surface onto this screen
def blit x, y, surface
# Unimplemented
end

# Flip buffers
def flip
# Unimplemented
end

# Does this screen support OpenGL?
def opengl?
false
end

end

You can load this into irb like so:

irb(main):001:0> require "./ui/screen"
=> true
irb(main):002:0> win = Screen.new

Then you can tell win to do things, or ask stuff of it. Like ask what
methods it has.

=> #<Screen:0x00000000a8a278
irb(main):003:0> win.methods

=> [:blit, :flip, :eek:pengl?, :nil?, :=== ........and so on]

Considering you can do that with every single value in ruby, it's
pretty handy, no?

You can ask it what its class is:

irb(main):004:0> puts win.class
Screen
=> nil

Or you could get it to do something you've written. In this
case it just a query.

irb(main):005:0> puts win.opengl?
false
=> nil

I guess I just find it very handy! It's not really hugely exciting,
just very useful.
 
7

7stud --

Rubist Rohit wrote in post #998271:
I don't understand how you all feel so comfortable with "irb". It is
good for one line syntax. I want to create a simple Windows app. where I
want to keep classes in a separate file and UI in another file.

How is Aptana Studio 3 that comes bundled with RadRails?

I never use irb or python's irb. I consider them a complete waste of
time.
 
J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

Can't help with rails but here are a couple of fun ideas:

1. A tiny text-based game using the socket library (networked hunt the
wumpus?) Using the network is pretty easy in ruby if you are used to
doing it via the operating system.

2. Text-mode mandelbrot fractal. Easy if you were to only use one
character.

Damnit now I want to code these things.

Cheers
Johnny
lol, did you read the "Land of Lisp", too?
 
P

Phillip Gawlowski

I never use irb or python's irb. =A0I consider them a complete waste of
time.

Suddenly, enlightenment.

--=20
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
S

Stu

Glad to see I inspired you. A blog post and everything. I have hacked
that gem a bit a this point. Have you built anything on it?
 
J

Johnny Morrice

I never use irb or python's irb. I consider them a complete waste of

I find this sentiment rather amusing!

I do use irb on occasion but it does suck rather.

For instance, it has no memory of the last session (it does not keep
records like .bash_history).
 
J

Johnny Morrice

lol, did you read the "Land of Lisp", too?

No! It looks fantastic though, cheers for putting me on to it.

I learned functional programming the dull and boring way by
implementing virtual Turing machines in Haskell. I really prefer their
sort of silly thing.
 
H

Hassan Schroeder

I do use irb on occasion but it does suck rather.

For instance, it has no memory of the last session (it does not keep
records like .bash_history).

? Funny, the irb I'm using does :)

And +1 to using interactive_editor -- handiest new tool that I've found
in months... YMMV
 
J

Johnny Morrice

? Funny, the irb I'm using does :)

Ah good shout, I'll have to see what's wrong here. Thanks!
 
J

John Mair

I added an `edit-method` command to pry, which works in principle
similarly to interactive_editor.

Except you can just go `edit-method obj.meth` and the source file for
the method is opened and fast forwarded to the first line of the method.
The file is re-loaded once the editor returns to the pry session too.
Check out the docs on the `edit-method` command here if you're
interested

http://rdoc.info/github/banister/pry/master/file/README.markdown
 
A

Adam Prescott

[Note: parts of this message were removed to make it a legal post.]

I added an `edit-method` command to pry, which works in principle
similarly to interactive_editor.

Except you can just go `edit-method obj.meth` and the source file for
the method is opened and fast forwarded to the first line of the method.
The file is re-loaded once the editor returns to the pry session too.

Cool!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top