Where can I compile my ruby code? - ruby

I started programming on ruby at codecademy but where can I compile my codes on doing a website?
When I was making some lessons on C I used codeblocks to run codes. I know any text editor can run a HTML code. So what about ruby?
Thank you.

I'll take a stab at answering the question that I think you're asking, but I'm not 100% sure here.
Ruby is an interpreted language (what does that mean? Not a whole lot nowadays. If you'd like a more in depth discussion on the distinction or lack thereof between interpreting vs compiling, read Jorg's comments below). To execute ruby code, you'll need to install ruby. Fortunately for you, this is freely available on any major platform. If you're on something unix-y (eg, linux or mac), I'd strongly recommend installing ruby via something like rvm or rbenv. If you're on windows, you can either go the cygwin route and pretend it's a unix-y environment, or there are prebuilt installers out there. Googling 'install ruby' should have some sites that can help you at or near the top of the search results.

Related

Create a ruby script installer for Linux OS

I wrote an application using ruby and I want to create an installer for that. I'm using Linux as OS.
I know there's the ruby script setup.rb written by Minero Aoki, but It's a bit harsh to understand by reading the source code and I'd like to write my own setup.rb. This is my final objective.
This is the first time that I try to write an installer and I don't know how to start. I carried out some research on Google but I can't find what I'm really looking for.
Can anyone suggest me any books or manual where I can learn to put the files on the right place (or whatever the installers do on Linux OS)? To put it better I would like to learn the basics of "how to install source code" in Linux systems and then apply the theory to try to install my ruby scripts.
Any suggestion is accepted.
Why don't you write a gem for it ? This is the best packaging system we know for ruby and you can just distribute a .gem file that can be installed with a simple gem command.
Check http://guides.rubygems.org/make-your-own-gem

Can I use ironruby that different from other implementation of ruby?

I am taking a ruby class this semester. In my book it said that there is an implementation of ruby for VS called IronRuby. I'd like to use visual studio that I use any way for work. My only concern is to know if there's significant difference (if any) with the other rubies so that I can go ahead and Use VS2012? In class we use a book called "Ruby Programming Language by Matsumoto"
Thanks for helping.
If you're just doing the exercises in the book, you should be fine.
Personally, I would not use it because:
IronRuby hasn't had a stable (or alpha) release in years, and its future is uncertain (little project activity and missing lead developers).
It's not 100% compatible with MRI, so you may run into weirdness, though I haven't been able to find a more detailed RubySpec.
More Ruby is written and tested on Unix-like machines than Windows, so if you need to use gems, you may run into weird issues with IronRuby that don't occur in MRI.
You should spend most of your time learning in irb, so Visual Studio doesn't really help you :). (irb is the interactive prompt -- you can test your code in real-time, instead of having to save and run [or compile].)

mingw32 Ruby Installer for Windows

How good is the new Ruby Installer for Windows?
I asked before about why Ruby was so slow on windows and now I've seen some impressive benchmarks showing marked speed improvements with the minGW compilation used in the new installers and am curious how it has worked for people who have tried it?
How many gems are broken for this version? Any big ones you have been bit by not on this list?
I've played with it a fair bit. It's definitely faster, both because of the new YARV VM in 1.9.1, and the use of a C compiler created sometime this century.
Pure Ruby gems are pretty reliable, obviously. Getting mswin32 binaries to work is a hit/miss situation (mostly miss IMHO), and native mingw32 binaries are still the exception, not the rule.
I wanted FXRuby on Windows, and went through the following to get it: Getting FXRuby Going with Ruby 1.9.1 and the new RubyInstaller
So it depends what gems you care about and how handy you are with build scripts and such. Despite the heroic efforts of Louis Lavena and the Ruby Installer contributors, Ruby on Windows remains a second-class citizen.
As you've already noticed, the RubyInstaller guys maintain a list of gems known to work, or not, but this is pretty fluid. The mailing list is usually pretty responsive to questions as well.
It's quite a bit faster, the exact experience varying according to your application. For low-volume Rails stuff, for example, I think you would probably not notice much: database access doesn't really change, for example.
Easiest thing is to try it. If you save your ruby\bin and ruby\lib directories first, you can install over your existing Ruby and be able to switch between the two. I think only those two directories are affected - it seems to work for me at least.
Once you have an installed mingw32 instance, start with the gem installs. The ones that have compiled components will hopefully already have mingw32 versions. Failing that, you could try modifying with the mswin32 versions from your "old" lib - I haven't done this myself and have only the vaguest memory of reading something that suggested it may work...
At the bare minimum, the mingw32 binaries run fine. If you start installing some esoteric gems, you might get some install failures. I highly recommend using Ruby on Linux or Mac, everything works better on those platforms. You will actually be spending time writing Ruby code instead of yak shaving your way to get gems to configure and build properly. I am writing this based on installing Ruby 1.9.1 mingw bins. The 1.8 version might be more stable. The msvc Ruby 1.9.1 binaries have their own separate set of issues, mostly run time ones.

Developing in Ruby, on a Windows machine, is too counter productive?

It seems to be very counter productive in that so many gems will break on windows. I have been dealing with so many mysql and ruby-mysql gem problems (seg faults occuring in the gem itself, a class called UnixSocket apparently doesn't work well on windows machines, etc etc).
I'm I just wasting my time here? Should I move onto a different scripting language?
I have very little experience with Ruby on Windows but when I was starting with Ruby I was on Windows and I got the general impression that it wasn't a Windows-native system.
So after many years of using primarily Windows, getting into Ruby prompted me to switch back to my original system, Unix, this time to Linux. Ruby did run with less hassle and running bash in its native environment was better than the just-mostly-OK Cygwin. I was happy.
Then my new employer had me switch to the Mac. Now I'm really spoiled, but really happy.
I realize this is subjective but ISTM that Linux was a lot better than windows and the Mac is a lot better than Linux. I could still run Windows in VMWare Fusion if I wanted to, but I don't. I do have some Linux VM's.
I think what I'm really trying to say is that there is a reason Ruby isn't best deployed on Windows. The kind of people who run Ruby are .. I'm trying to think of a non-pejorative word here .. not likely to be found on Windows.
So this is a turning point for you. Yes, .net is a sophisticated and well-documented environment, yes, windows has been reliable for several years now, and yes, it's a respectable system at this point. Yes, it runs Stack Overflow and some of the gurus are Windows guys. But it's just kind of a litmus test for .. darn, missing that word again ..
A lot of people run Windows because they just don't know what else to run. Linux is a good alternative if you have to buy the system yourself. And if you or your employer can afford it, the (Unix-underneath) Mac gives you everything Linux does plus the Mac-specific world.
It's time to choose... :-)
I've been developing with Ruby on Windows for several years, including building and deploying "enterprise" intranet Rails apps running against Oracle, MySQL and SQLServer on both Windows and Solaris servers.
Agreed, there are a few gems that have compiled components whose authors have not built Windows versions - that's OK, it's an open-source platform and they don't have to if they don't want to. Similarly, you're perfectly entitled to (a) ignore libraries that don't have mswin32 or mingw32 versions or (b) give something back by compiling them yourself!
As for the MySQL gem, IIRC on Windows you need the "pure Ruby" adaptor, which does not use the MySQL C API: http://github.com/tmtm/ruby-mysql or gem install ruby-mysql
I don't think you're wasting your time. I've worked with two guys who've done extensive projects on Ruby on Rails apps using Windows XP, like major, long-term projects. They seem to not mind it at all. They both worked on it using the NetBeans IDE. (It has a Ruby-specific version.)
I tried it myself when I first got started with Ruby and didn't run into a lot of errors or problems with gems, though there were some things that worked awkwardly. Usually there was a workaround.
I decided that I greatly preferred using OS X or CentOS Linux for Ruby development. But I know for a fact that working on Windows is possible.
One thing to look out for is that 90% of the Ruby community is on OS X and deploys to Linux, so you'll get more help if you're on one of those OSs.
Another thing to look out for is that the whole Ruby universe and culture is very oriented towards the Unix command line using the bash shell. All your tutorials and stuff are going to kind of assume that. They're going to have instructions like "Go to the shell and run # rake db:migrate and it will be a lot easier to follow those instructions if you have a full-featured shell with command completion, command history, etc. So if you want to work on Windows you might look into installing something like MinGW.

Going Ruby: Straight to IronRuby?

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.

Resources