Live data from Hacker News

Build iOS Apps In Ruby - Available Summer '12

mobiruby.org

51–54 of 54 posts

Re: Build iOS Apps In Ruby - Available Summer '12

#51
post #37

Earlier quoted context omitted.

what's an advantage of being too verbose? extra exercise for your fingers? ;-)

You can always make use of APL if you don't like typing.

You could always make use of enterprise Java if you like verbosity.

The extremes are probably not the place to be.

Re: Build iOS Apps In Ruby - Available Summer '12

#52
post #51
post #37

Earlier quoted context omitted.

You can always make use of APL if you don't like typing.

You could always make use of enterprise Java if you like verbosity. The extremes are probably not the place to be.

Verbosity is good when you need to maintain projects developed with 300+ developers, scattered across the globe with multiple companies working on the project.

Why do you think verbose languages are so loved by big enterprise companies?

It is a total different scale of development.

Re: Build iOS Apps In Ruby - Available Summer '12

#53
post #50

Earlier quoted context omitted.

With autocomplete you don't get much extra exercise anyway. It helps to strain your brain less however when reading the code.

I don't think "arrayByAddingObjectsFromArray:" is particularly clearer than "concat" or "+" unless you're just totally unfamiliar with the language. In fact, for many selectors I find the shorter names easier to read because my brain sees them as a single token while I have to mentally parse Cocoa's behemoths every time I run across them. There is some benefit to clarity, but very often Objective-C's glut of informat…

oh crap, does concat create a new object, or mutate the current one? is it the same as using + or do they handle objects differently....? should I be using I agree with you that the verbosity of ObjC makes it harder to mentally parse fast, but I also think there is a lot of clarity to it when you read it slow.

Where I see ObjC fall down is more in terms of command verbosity. For example in Ruby,

    File.open("readfile.rb", "r") do |infile|
      while (line = infile.gets)
        puts "#{line}"
      end
    end
...would be ~150 lines of code in ObjC (Dave DeLong: http://stackoverflow.com/a/3711079/196358). Which is not really a failing of the language, actually. It's a failing of the libraries that come with the language.

Apple chose to give you a couple ways to read a file. The easy way is `stringWithContentsOfFile:encoding:error:error`, but the next level of control is way to low level. Dave DeLong's solution to reading a file line by line exposes an api that looks like this:

    DDFileReader * reader = [[DDFileReader alloc] initWithFilePath:pathToMyFile];
    [reader enumerateLinesUsingBlock:^(NSString * line, BOOL * stop) {
      NSLog(@"%@", line);
    }];
Not actually much more complex or verbose than the ruby.

Re: Build iOS Apps In Ruby - Available Summer '12

#54

Earlier quoted context omitted.

Well any way you slice it you're still going to have to interface with the Cocoa frameworks that make up the OS. Anything that masks the interface too much just causes friction. e.g. you can't look stuff up in the docs anymore. MacRuby does a bit better job at first glance than this does, but you can't get past the way the framework you're using works. In Objective-C: Person *person = [Person new]; [person name]; [pe…

current method role is tentative. I'll do more improvement.

In your example you have:

  alert = UIAlertView._alloc \
    ._initWithTitle _S("Hello"),
    :message, _S("I'm MobiRuby"),
    :delegate, nil,
    :cancelButtonTitle, _S("I know!"),
    :otherButtonTitles, nil
  alert._show
Presumably you don't want to stray from UIKit method names in order to make translation automatic, which is understandable, however translation could be automatic couldn't it - is all that _S necessary? Did you consider a chained, hash syntax something like this:

  alert = UIAlertView.alloc().initWithTitle(:title => 'Hello', 
                                            :message => "I'm MobiRuby",
                                            :delegate => nil,
                                            :cancelButtonTitle => "I know!",
                                            :otherButtonTitles => nil).show()
With the syntax above someone could omit nil arguments and still get the right result, if you fill in missing arguments for them.

Or would that not work for some reason? I understand why you need to keep the method names (for automatic translation), but perhaps the syntax could be a little friendlier and more in line with expectation for Ruby code? I would love to write code for iOS in Ruby (have already written some, but it wouldn't get on the app store due to restrictions), but interfacing with views etc is not too painful in ObjC currently, so if it was more painful in something like this it would put me off.

Having looked at your pages further, I see the possibilities of a cross-platform Ruby framework for iOS and Android or WinMo, but if you tie it so tightly to UIKit, how did you plan handling cross-platform issues elegantly? Would that be down to the developers (it is a huge task of course)?

Post reply on HN