SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Enough of the bashing...real Ruby usage

    Come on this is getting stupid. Enough of the "Ruby sucks" or "Ruby is overhyped" or "I dont like Ruby and Im going to use such and such language instead and I just really felt the need to post here to let the world know" etc., and enough of the Ruby vs... nonsense already.

    How are people using Ruby in their everyday work? What are the things about Ruby that people really like?

    For me, the main use of Ruby right now is of course with Rails. I find it very productive and one of the niceset frameworks I've used.

    I've also started using Ruby for more general scripting tasks. The Rake system looks very cool and I intend to start using it more in future.

    I love the IRB console. Its great for quickly trying things out. I even load it up from time to time as a quick and easy calculator.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I don't use Ruby in my everyday work, I use Java/JSP. However, the Ruby approach is giving me ideas that can somewhat translate over to my Java work and it's giving me an even better grasp on OO in general.

    My Rails work is mostly limited to homegrown apps that help only me, but I plan on expanding that and working on more Rails projects for fun and profit outside of work

  3. #3
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am mainly just dipping my toe into the Ruby pool. I have made a few command line utility scripts to run some diagnostic SQL queries, but I have been reluctant to introduce and support a new tool in our production environment yet. I have only recently began to play with Rails, mainly becuase it is focused on MySql and our production environment is Oracle, thus I do not seem to be in the Rails sweet spot.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  4. #4
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm in the process of making some Rails sites.
    Quote Originally Posted by Luke Redpath
    ts great for quickly trying things out. I even load it up from time to time as a quick and easy calculator.
    After reading this, I used script/console for the first time today. It was very simple, like typing code into a controller as it is running. Definitely going to use that next time I've got some controller/model stuff to work out.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  5. #5
    SitePoint Zealot bronze trophy
    Join Date
    Jun 2004
    Location
    Stockholm, Sweden
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used Ruby recently for a small task at work.

    The task was parsing two Excel worksheets, perform some calculations and magic on the combined results and write it all to a new excel file. It included some data validation as well.

    I figured I would write this in C++, as I thought parsing the Excel files might be a heavy task (several MB each), and decided to use Ruby to prototype the application (my first real use of Ruby, ever).

    After two days I was sitting there with a full-fledged application that did what was required (IO from/to Excel worksheets, validate certain fields, make calculations based on data from both input sheets and write all the new mumbo-jumbo to a new excel worksheet) plus error handling and logging as well.

    I used the WIN32OLE package provided with the 1.8.2 Windows Installer version of Ruby, and it worked out great. I don't have the worksheets here with me at the time, but they are on the order of 4000 rows (15 columns I think) and around 10000 rows with roughly 8 columns for the other. Data needs to be matched between the two files (the smaller file contains 'Nodes' and the larger contains 'Asset'. One Node has_many Assets).

    Now, I haven't benchmarked this, but execution time is around two to four minutes. Since this script is supposed to run once every six months... the speed is not an issue.

    Now, however, I'm stucking hacking Perl which is a considerable downgrade
    If there is a way to overcome the suffering, there is no need to worry; if there is no way to overcome the suffering, there is no point to worry.
    - Shantideva

  6. #6
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Yakima WA.
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I am using Ruby and Rails full time...

    Guys I have switched to full time ruby and rails work from 4 years of heavy PHP and some python. This is a bit of a long post I am about to drop here but maybe it will help to give a few people some perspective on how someone coming from a php background rewrote a 5500 Lines of Code PHP website with 1500 Lines of Code in Rails. I was the only one coding this project and I had one other person create some of the views.

    I can say that I am _very_ happy about how ruby works, how rails scales and with ruby's 'speed'. Yes ruby is slower than some other scripting languages for now but that will be changing soon. ruby 1.9 already has speed improvements over the current branch and YARV beta's can give up to a 30x performance boost to certain parts of ruby.

    So here is the story of the development of a substantially sized ruby and rails project: http://yakimaherald.com. You can still see the old php site that I rebuilt here: http://legacy.yakimaherald.com:

    -------Development---------
    We got the approval and started rebuilding the yakimaherald.com
    site on May 1st 05. So it has been almost 4 months from start to
    finish building this app. When I say we I mean myself, the sole
    developer and my designer who made the views. But during those 4
    months I still had to do the daily maintenence and upkeep of the
    papers website and advertising plus we built 2 or 3 smaller sites
    with RoR during these 4 months. So if I had worked on nothing else
    except the new site <http://yakimaherald.com> I estimeate it would
    have taken me about 2.5-3 months to develop with just myself and one
    designer.
    The final app in the state it is in today weighs in at 1479
    LOC/models/controllers and 867 LOC/tests. I have 8 controllers, 12
    models, 9 layouts and 69 view templates. The system is very heavy on
    content. There are 4 main data sources for the app:

    1. A local postgres 7.x db for cms functionality and static
    page contents. This database holds the info that reporters and
    photographers input through the admin interface. And it also holds
    the new banner management system I wrote in ruby. Config is pretty
    much vanilla postgres and it performs great for my situation. I used
    the C postgres bindings.

    2. A BaseView database that is a proprietary db that many of
    the worlds newspapers run for their newsroom database that holds all
    the content that gets printed in the paper. This db is not SQL. It
    has a proprietary scripting/templating language called LiveIQ. My
    rails model that handles this db is a custom ruby lib that I wrote.
    It creates a little DSL for querying the BasviewDB. I converts my
    ruby DSL into the LiveIQ scripting language on the fly so I can think
    in ruby. All the local Yakima and central washington content comes
    form this DB. This model accounts for 307 LOC out of my total app
    because of its complexity. I may be able to make this component open
    source because it could definitely benefit any other newspapers that
    use Baseview that are thinking about ruby and rails.

    3. Custom xml feeds from the AP news wire. This content
    comes from the AP newswire subscription our paper has for the print
    version. It contains thousands of news items from around the world
    that get constantly updated throughout the day. These feeds are a
    little rough and require a fair bit of text processing before they
    are ready to go live on the web. The feed come across the wire as a
    Base64 encoded xml file. After unpacking it I have to scan for the
    relevant feeds we use out of the 2 or more thousand that are
    available. So my app processes and regenerates the online content
    every 1.5 hours unless we manually make it sooner.

    4. The Seattle Times own the Yakima Herald. So we get some
    of our content from them.We don't have a whole lot of content form
    this source yet but we will be using more soon as we just got the go-
    ahead to use their RSS feeds.

    So this app is very data and content heavy. When the index page
    gets regenerated after a cache flush it is pulling local postgres
    data, Baseview DB data from a server on the local LAN, Custom xml
    feeds from the AP wire and a few headlines feeds from the Seattle
    Times. This still is relatively fast. It takes about 200 milliseconds
    which is very good for everything it is doing to create the page
    including the network latency. But this only happens every 1.5 hours
    on one hit, the rest of the time it is cached .html files in the
    public/ dir these get served _fast_ by lighty. But it can serve up
    to 200 requests/sec with only 5 fcgi's on no network latency dynamic
    pages. So for me Rails __CAN__ scale for largish web apps with a
    largish amount of users.

    -------Deployment-----------
    The new app runs on a brand new dual 2.5Ghz G5 Xserve running
    Tiger server with 1 gig of ram and 480Gb scsi RAID. We just got this
    in 10 days ago and I configured it myself. I am running Lighttpd
    1.3.16/fcgi and it is running great. I initially tried to run on
    apache2/fcgi but in testing I got too many random 500 internal server
    errors. Lighttpd has proven itself to me over the last few months in
    production on some smaller sites and I think it is pretty much ready
    for prime time. We are getting around 60,000+ hits a day and thanks
    to judicious caches_page and fragment caching the server is barely
    breaking a sweat. Here is a paste of the relevant section of top
    running on the Xserve right now:

    PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD
    RSIZE VSIZE
    26609 ruby 0.8% 12:46.00 2 16 132 22.9M 2.00M
    24.2M 50.4M
    26606 ruby 0.4% 12:11.00 2 16 129 22.9M 2.00M
    24.2M 50.4M
    26605 ruby 0.4% 14:43.20 2 16 137 23.0M 2.00M
    24.1M 50.5M
    26604 ruby 6.7% 17:06.96 2 16 133 23.2M+ 2.00M 24.5M
    + 50.6M+
    26603 ruby 12.8% 18:19.70 2 16 129 23.0M+ 2.00M 24.4M
    + 50.4M+
    26602 lighttpd 2.4% 4:58.44 1 10 39 4.25M 704K
    4.59M 27.5M

    I have 5 dispatch.fcgi's running (the ruby processes above) and
    they fluctuate from below 1% to around 13%cpu when they are working
    on a complex page rebuild after a cache is swept. But for the most
    part they just hover around 1-3%. And light is awesome it's never
    gone above 9% cpu yet and it mainly stays around 3%! And these
    percentages go to 200% since there are dual procs. So for the most
    part I am using about 16% of all my processing power on this box for
    my rails app at any given time.

    I have a few launchd scripts(Tigers new xml version of cron)
    running for maintenence tasks. I have launchd launch an instance of
    the awesome ruby daemon daedalus at boot time. This daemon checks to
    make sure that lighttpd is running every 3 minutes and if it is not
    it relaunches a new instance of lighttpd/fcgi. It also wipes out the
    ruby_sess files in /tmp every 6 hours. I end up with around 8-9,000
    of these session file in 6 hours and my app runs much better when
    these are not allowed to build up.

    Daedalus also bashes my cached pages every 1.5 hours. I have
    many data sources that wont work with cache_sweeper because they come
    from remote computers. So this script erases the pertinent files in
    public so the cache can rebuild with the new content from all remote
    locations. We also have an intranet page where people from the
    newsroom can go and run a script to clean the cache whenever they add
    new content they want to be picked up.

    I also have a lot of "glue" code written in ruby to do various
    text processing and ftp'ing and other things. The classified ads are
    processed to format them for online display. I have a bunch of admin
    tools written in ruby as well.

    --------Wrap Up-----------

    All in all I am _very_happy with my experience with Rails as
    well as ruby. Rails is a super productive environment for me to
    develop web apps in. But I have really fell in love with ruby
    _itself_. Ruby is so elegant and the syntax allows for me to open up
    code from 7-8 months ago and at an instance see exactly what it does.
    So it is much more maintainable than the PERL and shell scripts that
    I have replaced. I think that anyone considering rails and ruby for a
    decent size project should not be concerned with how does RoR scale.
    It scales great. The shared nothing architecture works great. If I
    need more power eventually I can just fire up another linux box and
    run fcgi's on there. Rinse, repeat..



    Cheers...
    I hope I can help some people with any questions you might have as I
    have greatly benefitted from the very knowledgeable people of the
    ruby and rails community.

    -Ezra
    ezra@yakimaherald.com

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    USA
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    !
    Last edited by DaveB2; Jan 14, 2007 at 16:57.

  8. #8
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Written a couple of scripts so far.

    So far I've done two things with ruby. At work I've been having to parse text files, so I've written several ruby scripts that involve taking configuration files and extracting information from them and generating new config files. Ruby has worked great for this task, I've found it to be a very natural language to use

    The other thing I've done, is I wrote a program that will allow you to search and replace using regexes with a nice TK Gui frontend. I basically wrote this script to teach myself how to write GUIS in TK, and also it's nice to be able to visualize what text is being grabbed by a regex while your crafting it. It's slow on large text files which is sortof a drag, but to be honest this is more the fault of how I get and manipulate the text from the TKText object and do my marking with TkTags then it has to do with the speed of ruby. If I were a smarter programmer I'd have probably figured a way around it by now.

    My only major complaint thus far has been, I wanted to write a script the other day that would spin off a process, and wait for that process to either finish or for a certain amount of time to elapse and then terminate the process forcefully. If I were coding ruby on linux, this would be easy, however since fork doesn't work on windows, I would have to make a windows system call to achieve the same result so I kindof gave up. I suppose if I were REALLY needing to get it to work, I could use the cygwin version of ruby which supports fork.

    I love the language and expect to keep using it for whatever seems natural for years to come.

  9. #9
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ezmobius1
    Guys I have switched to full time ruby and rails work from 4 years of heavy PHP and some python. This is a bit of a long post I am about to drop here but maybe it will help to give a few people some perspective on how someone coming from a php background rewrote a 5500 Lines of Code PHP website with 1500 Lines of Code in Rails. I was the only one coding this project and I had one other person create some of the views.
    Great writeup and the new site looks really good. Looking at the old site it looks like it is written in old-school, controllerless style -- probably procedural with content and code mixed. I wonder if you could give your thoughts on how your new Ruby development would compare to doing the same site using an ActionPak style controller in PHP?
    Christopher

  10. #10
    SitePoint Zealot
    Join Date
    Nov 2004
    Location
    Yakima WA.
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arborint
    Great writeup and the new site looks really good. Looking at the old site it looks like it is written in old-school, controllerless style -- probably procedural with content and code mixed. I wonder if you could give your thoughts on how your new Ruby development would compare to doing the same site using an ActionPak style controller in PHP?
    First let me say thank you. I spent a good deal of time making the new site highly extensible so I can easily plug in a module here, a little panel there and consume a remote rss feed over here.

    As far as comparing the rails/ruby style of website dev with a php ActionPak style I would have to say that there are a good many similarities. But I find that the way the rails framework is very complete makes it an entirely mor enjoyable process. ActiveRecord makes the databse access so dead simple that its really enjoyable. SQL is not my favorite thing to be writing.

    I have a small PHP framework that is in the style of MVC with a simple database abstraction class and it has served me very well for the last 2 years or so. Making me what I thought was a very fast and efficient web developer with PHP. And I must admit that when I first heard about rails last fall I was suspicious of the hype and claims of productivity. I thought "No way could that be much better than what I do now so why even bother checking it out". But the newspaper I work for asked me to write a bunch of text processing and general glue code and I don't really like using php on the command line so I looked for something else to use. I tried out python and ruby. Python os a great language but the significant whitespace doesn't jive with the way I think. So I got the 'Pickaxe' ruby book and started writing some glue code to do text processing. After 2 days or so I was in love with ruby. I found it very easy to pick up after php being the only other language I knew well. And so after I got a little more familiar with ruby I thought that I would check out rails and see what it was all about.

    After making a few small projects with rails I was ready to drop php for anything complex and start using rails and its very clean implementation of MVC. A little tid bit here is that you can setup your webserver so that you can still serv .php files out of the public folder of your rails project. So if you don't want to leave php behind or want to make the transition slower, you can set up a rails app and just serve .php files out of the doc root while you build parts of your site with rails. This way you can slowly transition the site as you learn more about rails and ruby.

    I feel like I have learned a lot about best practices web development from using rails. Since ruby is a pure OO language and rails leverages this fact to the fullest, it tends to rub off on you. So I still have some php I have to maintain and not every client wants to switch out of php yet. So when I do php work now I find it comes out much cleaner and more sensible than I would have done before I started using rails.

    I know that the hype machine behind rails is a little hard to swallow sometimes but it is really something to look into. If you find yourself writing php in an OO way and you are maybe running up against a few of its limitations in that aspect then you owe it to yourself to try out ruby/rails. People say that there aren't any rails jobs out there. But I am able to make everything new at work with rails. And beside that after I released the http://yakimaherald.com website I was approached by quite a few people just getting into rails and asked to do consulting and contracting. So right now I have my hands full. I work 40/hrs/wk at my day job and then I have 2 other projects that I spend 10/hrs/wk on and they pay very good money. More than I was ever able to get on any php project i have been involved in.

    So I have to say that deciding to pick up rails has been the high point of my career as a web developer. It has brought the fun back into it and has given me something new to learn that really pays off well.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •