I'm thinking of writing a basic Ruby debugger (interactive). Can you direct me to some resources or projects to learn more from?
A simple introduction into debuggers: http://t-a-w.blogspot.com/2007/03/how-to-code-debuggers.html. It even has a small part using ruby hashes as an example.
I guess you mean a Ruby debugger implemented in Ruby. A good place to start would be to take a look at the introspection and reflection interfaces documented here
If you want to be a bit more adventurous you could look at the source for ruby-debug
Related
So I see that unity has the support for c#, JS and Boo.
I could learn one of these but I would like to make a 'compiler' or something similar that would let me write ruby code and either output JS code or make a layer that could be read by the Unity compiler.
Is this even a possibility. Im willing to invest many hours in this and have a fair bit of experience.
If your question is actually "how do I compile Ruby to JavaScript" then that's easier to answer:
Opal: Ruby to JavaScript compiler
However, you're going to be mucher better off learning one of the supported languages. It's very hard to debug "your" code when what's running is a paraphrasing of the code in another language.
I'm not that familiar with C# but if it's anything like C, it's quite possible you could create bindings from Ruby to Unity and just use it directly. Likely you could even get some kind of community going. This would be much preferable to trying to auto-refactor languages.
I recommend the "play my code" site.
It is possible to "conpiles Ruby to JavaScript", to operate the Ruby Game in a browser, just as JS.
http://www.playmycode.com/build/edit/6172
Unity 3d doesn't use Javascript, i think unity corporation call it as javascript just for marketing purposes, Unity uses UnityScript which is Boo based implementation, you can see the source here https://github.com/bamboo/unityscript
So, even if you got some compilers ruby to javascript such as Opal, you'll still compile it to JavaScript and not UnityScript, there's a big diferences between them:
Javascript is a prototype based language, and UnityScript is an class based.
UnityScript is more JScript.NET than Javascript.
See more at http://wiki.unity3d.com/index.php?title=UnityScript_versus_JavaScript
I think the easily way to integrate ruby language rather to write a full compiler is integrate IronRuby, which is a Ruby implementation written in C#, which will generate bytecodes for CLR that Unity can read.
I did a similar project with python, which uses IronPython (https://github.com/cesardeazevedo/Unity3D-Python-Editor), it's still very limited, such you still have to call python code from C#, but it works and there's a interpreter that can help you in your development, if you want to create thousands of game objects with simple python commands.
Is there an existing library to write code for the PIC32 in Ruby?
Currently I've been writing code in C to perform tasks on it, but I would love to use Ruby.
Thanks,
Andy
I doubt that there is an existing library for that task, but it should be possible (surely not without some effort) to extend Metasm to include a new assembler backend for your processor. It also includes a C parser/compiler.
EDIT: I just realized you are looking for a Ruby interpreter on that platform, which I hardly can believe exists.
I also doubt that Ruby on iron exists, but it would be nice to be wrong. :)
If your pic32 can handle an OS that would run Ruby, that might be an option. Otherwise you may be able to prototype a lot of your algorithms in locally run Ruby and then translate them to C on the PIC32.
Probably too late, but according to this link, mruby can run on pic32
As a consequence, the interpreter is now much reduced in size and can
be cross compiled for low cost 32-bit microcontrollers including ….
the PIC32 (MX7)! The official repository on GitHub contains already
examples for a few embedded platforms including the chipKIT MAX32!
https://github.com/mruby/mruby
I am starting out on Ruby and have heard that there is a 'Ruby way' of coding. What are some projects, apart from Ruby on Rails, that are suitable for study and is agreed upon as well designed?
Prawn was explicitly created to be not only a damn good PDF generation library, but also designed from the ground up as an example of well-designed, well-factored, idiomatic Ruby code. Prawn also spawned the Ruby Best Practices book and the RBP Blog.
I just started to learn Ruby and as a .Net developer, I'm wondering if I should just go straight ahead and use IronRuby, without trying some pure Ruby first.
What do you think? Will I be missing anything?
-- rauchy
I would use pure ruby (Matz Ruby Interpreter (MRI)) to start off. My understanding is that iron ruby is not quite ready yet.
If you are looking for a good book my current favorite (over pickaxe) is http://www.amazon.com/gp/product/0596516177 by matz and flanagan, the book is very concise well written paragraphs and they provide great examples (in 1.8.* and 1.9)
Enjoy! :D
Use pure Ruby first, IR isn't quite finished yet. Check out http://poignantguide.net/ruby/ - even though it's quite strange, it's a very good introduction
Ruby has a somewhat unique syntax and style that you'll pick up more quickly by working with other people's ruby code. You could certainly learn this while using IronRuby just as well as in any other implementation of the ruby language. (Although, you may run into trouble with some more obscure syntax or libraries with IronRuby; it's not a 100% complete implementation, yet.)
One interesting resource for learning idiomatic ruby is http://www.rubyquiz.com/.
I know this is an old question, but I'd like to say that four years later (today), the JRuby implementation is certainly far enough advanced to be worth starting with.
Has anyone ever done work to get Ruby to do continuations (like Seaside on Smalltalk)?
Yes, in most cases. MRI (1.8) have supported them as far as my memory reaches, Ruby 1.9 (YARV) does it, too, so does Rubinius. JRuby and IronRuby don't have continuations, and it's quite unlikely they will get them (JVM and CLR use stack-instrospection for security)
Ruby as a language supports continuations via callcc keyword. They're used, for example, to implement Generator class from standard library.
continuations on ruby-doc
Continuation-based web frameworks (like seaside, or one from Arc's std. library) seem less popular. I've found wee that claim to let you do optional continuations, but I've never used it.
As others have said already, Ruby 1.8 supports continuations.
Ruby 1.9 has not supported them for a while however. They have been added back some time this year, but most of the other Ruby interpreters (JRuby, IronRuby, etc) don't support them.
If you want your code to be usable on other platforms than the mainline Ruby, I'd suggest not using them.
Read this InfoQ article for a more comprehensive discussion on the topic.
Btw this is an example of restartable exceptions (aka conditions) implemented using continuations. I used it few times and it's a cool thing to have in a Ruby toolbox.
neverblock uses 1.9 fibers for a single threaded ruby web server