Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a scripting language like ruby

I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.

I am wondering how to do debugging. At present the steps I follow is,

  • I complete a large script,
  • Comment everything but the portion I want to check
  • Execute the script

Though it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that.

My question is, is there any better way of debugging?

Note: I guess it may be a repeated question, if so, please point me to the answer.

like image 653
Alphaneo Avatar asked Oct 07 '09 06:10

Alphaneo


3 Answers

Your sequence seems entirely backwards to me. Here's how I do it:

  1. I write a test for the functionality I want.
  2. I start writing the script, executing bits and verifying test results.
  3. I review what I'd done to document and publish.

Specifically, I execute before I complete. It's way too late by then.

There are debuggers, of course, but with good tests and good design, I've almost never needed one.

like image 61
Dustin Avatar answered Oct 21 '22 17:10

Dustin


Here's a screencast on ruby debugging with ruby-debug.

like image 6
statenjason Avatar answered Oct 21 '22 18:10

statenjason


Seems like the problem here is that your environment (Visual Studio) doesn't support these languages, not that these languages don't support debuggers in general.

Perl, Python, and Ruby all have fully-featured debuggers; you can find other IDEs that help you, too. For Ruby, there's RubyMine; for Perl, there's Komodo. And that's just off the top of my head.

like image 4
Jim Puls Avatar answered Oct 21 '22 18:10

Jim Puls