class Foo
include Virtus.model
attribute :foo, String
end
Now, I could go on like this, but that would be moot. I just question the basic premise of saying that just because 5 features match somewhat nicely (even if it involves more braces of different kinds), those would be reasons for Rubyists to love Swift. Much in contrast, similarity might not be the most compelling reason to switch to something different. if (hasAccess = true) {
doSomething();
}
you meant to compare, not assign. So when I saw this Ruby example, I was not amused: if current_user = find_current_user
notify_user(current_user)
end
However, the Swift equivalent is the best of both worlds: if let currentUser = findCurrentUser() {
notifyUser(currentUser)
} if let currentUserIsAuthorized = true { // COMPILE ERROR
...
}
This makes it useful for the one case where you'd actually want it without introducing any pitfalls, because using it incorrectly will be a syntax or type error. if current_user = find_current_user
notify_user(current_user)
end
Funny to see an anti-pattern in C/C++ so lauded in another community.Also, you know what I like about Ruby? I can write it and it'll run everywhere, and it is maintained by a vibrant community effort. Where's that on this list?
Give the vibrant community effort some time.
While I can think of usages where I could see myself use it, the given example is definitely not one.
Disclaimer: I have walked the tutorial and reference and I belive it is fantastic. I am waiting for someone to release a linux compiler.
The if let x = whatever {} syntax in Swift is damn brilliant after looking at a ton of C# code with the as check.
The error messages you get when you've done something wrong are unintuitive at best and downright misleading at worst.
Example: I've got a field I want to render an image in. It's represented as an object of type NSImageCell.
I've got my image file defined as an object of type NSImage. So far, so good.
I type the . after the image cell, and I'm presented with a number of autocomplete suggestions. One of which is a method called "setValue" which accepts an object as an argument.
Okay cool.
myCell.setValue(NSImage(named: "myImage"))
Compile and.. instacrash with "Unrecognized selector"What?
Some research turns up that this error means you've tried to send a message to (call a method on) something that doesn't accept that type of message.
Turns out that the method I needed is called setObjectValue. And it also accepts an object as an argument.
So, Xcode. Why did you give me setValue as an autocomplete when it isn't valid on that object? Why are these method names nearly identical? facepalm
And that's before I get into the almost completely worthless inline error messages. "Cannot convert to $T1". What?
I really, really like the language, but Xcode is trying its damndest to turn me away. I've got a stack of bugs/feature requests that need to be entered into Apple's reporting tool - hopefully some of these are just warts that'll get fixed as Xcode 6 comes out of beta.
Having new people join a project/language, and finding it's warts/weird parts is awesome! It's part of how you learn where the REAL issues that bother people are, and set a development roadmap. He's using it, and telling Apple where it should evolve. That's the whole -point- of a Beta ;)
Edit/Disclaimer: My first contact with programming (besides BASIC) was Autolisp (Autocad scripting) and my professional field is design.
On the other hand, an existing language with the right type system features would've needed a lot of rework to make it suitable for the object model and API.
Or it'd be like C++, where you can program C++ for Linux, or C++ for Windows, and a lot of things may be the same, but then you find out that one of them has different semantics for what you thought was a standard library.
RubyMotion for Android features a completely new Ruby runtime specifically designed and implemented for Android development. This is a new implementation of the Ruby language, it does not share code with RubyMotion for the Objective-C runtime. We are using the RubySpec project to make sure the runtime behaves as expected.
...
We feature an LLVM-based static compiler that will transform Ruby source files into ARM machine code. The generated machine code contains functions that conform to JNI so that they can be inserted into the Java runtime as is.
...
RubyMotion Android apps are packaged as .apk archives, exactly like Java-written apps. They weight about 500KB by default and start as fast as Java-written apps.
http://blog.rubymotion.com/post/87048665656/rubymotion-3-0-s...
I presume you haven't programmed lisp, because although there is very little syntax to memorize, there are a huge number of functions.
I programmed a little bit in Autolisp (lisp dialect for AutoCAD scripting) as amateur and what I liked about it is that everything works the same way (even if you don't know all functions is not a big deal), it's just a list. JavaScript looks like a mixture of paradigms and syntax, trying to please everybody. When I don't program in it often I forget most of the stuff. Probably it needs to be like this but it doesn't look like an optimal solution.
I'd say on the power spectrum of programming languages, ruby is MORE powerful than swift.
There are so many things you can do in ruby that you can't do in swift, especially along the lines of reflection. The only stuff swift has that ruby doesn't comes in way of restrictions eg. typing.
If this was the main and only reason such that removing this limit Apple would have used Ruby, then why in your opinion didn't Apple try to implement themself something like RubyMotion (which was made by a company a thousands orders of magnitute smaller)?