Slashdot Mirror


Rubyx OS - A Testament To The Power Of Ruby

Andrew Walrond writes "Rubyx the OS is created from source by rubyx the ruby script. Got it? The same small ruby script handles all subsequent package management, customised parallel and distributed user-mode package builds, and can create a live CD. For good measure, Rubyx (the os) sports an all new init and rationalised service management system written in ....can you guess?..."

15 of 121 comments (clear)

  1. ROS by davegaramond · · Score: 4, Informative

    FYI, there's another initiative to develop a fully Ruby-based operating system (including the kernel), though one wonder when -- if ever -- this project will deliver something usable.

  2. Re:My thoughts on Rubyx by the_womble · · Score: 3, Informative

    If you had actually followed the link you would know that the whole OS is not written in ruby. It is Linux with a ruby installer and package system.

  3. Um, isn't this just another Linux distro? by ivern76 · · Score: 4, Informative

    I'm not too sure how this isn't 'Rubyx, the Linux distribution with an installer/package manager written in Ruby'. If it had been written in any other language, would it still be cool?

    1. Re:Um, isn't this just another Linux distro? by dagbrown · · Score: 3, Informative

      Actually, there are a couple of cool things about Rubyx that make it different from a run-o'-the-mill Linux distro, and the language they're in ain't one of 'em.

      The first is that it's self-bootstrapping--you can just download the Rubyx script and use that to build an install ISO. That's pretty darned cool if you ask me.

      The other cool thing about it is that it completely eschews the entire SysV init system with one of its own, based on dependencies instead of on educated guesses by the sysadmin (read: arbitrary order) as to what order services should start up and shut down in. This lets you speed up booting by starting independent services concurrently instead of waiting for each service to start up individually.

  4. Re:Enhanced Package Management by Jerf · · Score: 2, Informative

    I don't want to be accused of irrational advocacy of any particular distribution, but for the record, everything you mention in your posts already exists in at least one very popular distribution, and probably more.

    Perhaps you should poke around the existing world a bit more. If you've only tried one distro odds are good you haven't found your match. Red Hat(/Fedora), Gentoo, and Debian are probably good ways to sample the major ways of doing distros; each has a fairly different philosophy and is large enough to have good implementations of the philosophy in running code. OK, I'm a Gentoo myself, and that's the distro I was referring to above, but they are all good distros and I've had the opportunity to use them all lately from start to finish, and they are all fine choices.

    (I think Debian meets all your requirements too, but I'm not too sure about the multi-gcc one. I'd expect it is but there might not be a built-in switcher. Gentoo has 'gcc-config', which works as you describe, and also has a pretty clear "configuration files based on system-wide settings", the USE flags. Fedora I'd have to check on; I don't how clean you could make source integration but good package management in it is definately possible if you use yum in addition to rpm; rpm alone kinda sucks but with yum it's OK. I don't think multiple gcc's works well in Fedora, but I could be wrong. If you have a source RPM I believe it's rpmbuild --rebuild [source RPM] but I don't have Fedora handy to look at the man pages; corrections welcome on anything in this paragraph. I've used them all but I wasn't looking for these specific things.)

    "What's your distro?"

  5. Re:So when is PerlOS coming out? by cowens · · Score: 3, Informative

    If Rubyx is an OS then it does: Mandrake. The installer is written in Perl and the package management is done with Perl. That is all Rubyx is.

    But if you want an example of extreme silliness in Perl you can look at http://freshmeat.net/projects/perlbox/ a Desktop Environment written in Perl.

  6. Re:hmm.. maybe a bit Off Topic.. but by Jerf · · Score: 3, Informative

    Consensus gestalt that I've gotten as a Python user and reading a lot of debates on this topic is that structurally, Ruby is a little more pure OO then Python, but the practical differences seem minimal, especially after the type/class unification in Python. (Ruby advocates are proud of their block syntax but I'm yet to see something I don't immediately know how to write in Python, too; the question is which fits your mind better.)

    Syntactically, Ruby is more like Perl. If you consider sigils an abomination upon the land, as I do (despite working professionally in Perl), then you'll want Python. If you consider them Larry Wall's gift to syntax, then you'll want Ruby.

    The other thing is, if you're expecting to use a library of some kind, check for availability. Python has the edge right now AFAIK but that doesn't matter unless Python has something that Ruby doesn't that you need, or vice versa; for most people my impression is that the necessary modules are there in both languages.

  7. Re:hmm.. maybe a bit Off Topic.. but by Anonymous Coward · · Score: 5, Informative

    I use Python mostly for "work", but I much prefer Ruby and try to use it whenever possible.

    If you are a theoretical guy who loves a conceptually elegant and consistent language like Smalltalk or Scheme, you'll love Ruby. Ruby is so consistent, it's really lovely.

    If you're more practical and need good documentation and extensive libraries, you'll probably be annoyed by it.

    If you like to write programs FAST but not sacrifice readability like Perl, you'll really love Ruby. For instance in Ruby, you don't have to type "self" in method argument lists the way you do in Python. Ruby is 100% object oriented inside and out. Classes are first class objects, subclasses of Module objects. There are no "old style classes" or "new style classes", no cruft held over from previous versions of the language.

    In Python, you have built-ins like "str()" which can call the __str__() method on an object. None of that kind of repetition in Ruby. Just call obj.str (or actually, obj.to_s) directly. You don't need the parens in that case.

    Ruby has "blocks" which are a nice syntactic sugar for a whole class of operations. For instance a database transaction can be implemented as a block:

    transaction { |t|
    do stuff with t
    more stuff
    }

    in Python that would be:

    t = start_transaction()
    try:
    do stuff with t
    more stuff
    finally:
    end_transaction()

    The ruby version is easier to read.

    If you want a large selection of tools and implementations, well, Ruby doesn't have too many like Python.

    Also the Ruby community is still small and friendly. The python community is turning into the Perl community, in my opinion. A little arrogant.

    Python is starting to look more and more like Ruby every revision though.

  8. Re:hmm.. maybe a bit Off Topic.. but by Anonymous Coward · · Score: 2, Informative

    Sigils? You mean punctuation at the front of variables? That's a little misleading, Ruby doesn't *require* them because you can program entirely with method calls:

    class Thing
    attr_accessor :foo, :bar
    def add_me_to_foo_and_bar(me)
    foo + bar + me
    end
    end

    t = Thing.new
    t.foo = 5
    t.bar = 34
    puts "look: #{t.add_me_to_foo_and_bar(4)}"

    And class variables, in my opinion should never be used. You should use instance variables on the class object, which uses similar syntax to the above and feels more consistent.

  9. Re:hmm.. maybe a bit Off Topic.. but by Discordantus · · Score: 3, Informative
    It has some of them. But their use is mostly discouraged... the ugliness of the $s and @@s are supposed to keep people from using them :) Also, there are many excellent constructs built in to replace them. Take Perl's regex match variables, for instance. Here is an example of a Ruby way of using regex matching, where you can collect "MatchData" objects from a match:

    (note that '#' starts a comment, and => (value) in an end-of-line comment is showing the resulting value of an expression.)

    re = /(\d+):(\d+)/ # match a time hh:mm
    md = re.match("Time: 12:34am")
    md.type #=> MatchData
    md[0] # == $& => "12:34"
    md[1] # == $1 => "12"
    md[2] # == $2 => "34"
    md.pre_match # == $` => "Time: "
    md.post_match # == $' => "am"

    You can collect as many matches as you want before you process them. There are no freaky, hard to remember variable names that you need to remember. You can still do it the Perlish way if you want to, but a lot of that stuff has been slowly made less desirable to use. I wouldn't be surprised (or upset) if they disappeared altogether in the future.

    Then again, there may be the exact same thing in Python, and you're wondering why it's special. Since I went to Ruby straight from Perl, I wouldn't know.

    (The code was pulled directly from online docs, so I'm not pretending I wrote it :)

  10. Re:Logo OS? Try a Lisp OS by alex_tibbles · · Score: 2, Informative

    you might want to see Movitz a "Common Lisp OS development platform".

  11. Cleese by GerritHoll · · Score: 4, Informative

    At first glance, I thought this would be similar to Cleese, a Python-based operating system, but it isn't: RubyX is a distro with some stuff written in Ruby, and Cleese is an actual effort to write a kernel in Python. Not that it's progressing a lot, though... the CVS tree can be found here.

  12. Re:Japanese by ladislavb · · Score: 3, Informative

    The character ("li" in Chinese) means "power" or "strength" (in both physical and spiritual senses of the word).

  13. Re:hmm.. maybe a bit Off Topic.. but by Discordantus · · Score: 2, Informative
    You are correct, regexes are full-fledged objects in Ruby. In the Ruby interactive interpreter (">>" is me, "=>" is the interpreter):
    >> /foo|bar/.match("this foo that").to_s # the matched string
    => "foo"
    >> %r(/etc/hosts|/bin/sh).class # returns the object's class
    => Regexp
    >> a = /(foo)bar/m # stores it in a variable
    => /(foo)bar/m
    >> /test#{a}test/i # embed it using #{} (string interpolation)
    => /test(?m-ix:(foo)bar)test/i
    Usually the %r syntax is used to make the regex clearer, like when you don't want to have to escape a bunch of slashes. Similar to Perl, anything can be a delimiter, so you can pick what looks best in the situation.
    >> # an array of regexen!
    >> [ %r(foo/bar), %r:(foo/bar):, %r_(:foo/:bar)_ ]
    => [/foo\/bar/, /(foo\/bar)/, /(:foo\/:bar)/]
    After learning Perl, I went looking for a language with a clearer syntax. At first I looked at Python, and the only reason I didn't stick with it was that I like being able to use regex literals. So I guess it's a matter of taste.

    Ruby is the first programming language I've used where I can actually write an entire script and have it work the first time. Not always, but fairly often. I've heard similar things (about Python) from my Python friends. To me, that is the most important aspect of a language, since debugging bugs me :)

  14. Re:hmm.. maybe a bit Off Topic.. but by xteddy · · Score: 3, Informative

    The |x| is a block parameter list. Blocks are Ruby's way to emulate higher order functions.

    [ 1, 2, 3 ].each { |x| puts x }

    would print "1", "2" and "3" in three different lines.

    The block parameters are very clever, you can also put something else than only variables there. If you want to compute the sum of the products of some pairs, you could do it that way:

    a = [[1, 4], [2, 5], [3, 6]]
    sum = a.inject(0) { |s, (x, y)| s + x * y }

    The block would first be called with s = 0 and (x, y) = [1, 4], that would assign x to 1 and y to 4.

    The inject would compute
    s = 0 + 1 * 4
    s = 4 + 2 * 5
    s = 14 + 3 * 6 = 32
    by calling the block three times once for every pair in the list and adding the results in the s and returning the result s.

    The ||-syntax looks very similar to the Smalltalk syntax for local variables. Ruby is very strongly influenced by Smalltalk. The inject method name stems also from Smalltalk. You can use blocks to make sure something is done after a block of code has been executed instead of using destructors or finalizers. An example would be to close a file after reading it:

    File.open("/etc/passwd") do |f|
    puts f.read.count("\n") # => number of lines
    end # => file f is closed here

    do...end is equivalent to { } and usually used if the block is not an oneliner. Readability is actually very important in Ruby culture.

    Ruby has an exception handling that is very similar to Python's, but the keywords seem to be blatantly stolen from Eiffel's Design By Contract. The transaction example from above could also be coded that way in Ruby:

    t = start_transaction()
    begin
    do stuff with t
    more stuff
    rescue => e
    puts "Caught an exception: #{e}"
    ensure
    t.end_transaction
    end

    I don't think that Ruby has a problem wth "non-alphanumeric" characters - it uses them very wisely, actually. I remember that Python uses lots of __foo__ and """bar""" - that really makes me feel uncomfortable when I have to read Python code!