6 ms·
Why Rubyist Will Love Swift
- Argorak 12y agoI'm not buying this. It basically says "there are a few concepts in Ruby that map nicely to Swift". There are quite a lot of concepts that don't map, for example evaluated classes, which enable things like: 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.
- asolove 12y agoThe comparisons with scala and c++ are stronger. This is a large language, with a lot of complexity from having to maintain compatibility with an existing environment, plus lots of new concepts bolted on top. Like those languages, the time to basic proficiency may be faster than with their predecessors, but the time to mastery will be much longer.
- tendom 12y agoScala, yes, but not C++ at all. Indirectly from C#, perhaps (and there is a fair bit of that), but there is very little that borrows from C++ at the language level.
- Glide 12y agoOh I would love to see a write up comparing it with Scala idioms. As a person who has done C# for a while a lot of idioms translate very well to Swift. The if let x = whatever {} syntax in Swift is damn brilliant after looking at a ton of C# code with the as check.
- tendom 12y agoI agree, there are more than a few features I'd like to see C# adopt from this, and that's a big one. Proper string interpolation is another.
- nileshk 12y agoHere is a Swift vs Scala syntax comparison: https://leverich.github.io/swiftislikescala/ https://leverich.github.io/swiftislikescala/ And also, a comparison to C#: http://pietschsoft.com/post/2014/06/07/Basic-Comparison-of-C-and-Apple-Swift-Programming-Language-Syntax http://pietschsoft.com/post/2014/06/07/Basic-Comparison-of-C...
- angersock 12y agoif 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?
- Karunamon 12y agoYou realise that you're talking about a prerelease, right? The language hasn't even been available to developers for a month yet, let alone the general public. Give the vibrant community effort some time.
- jerluc 12y agoI could be wrong, but I believe the parent is referring to the inability for a "vibrant community" to maintain Swift as a language implementation (instead of Apple), which is very different than Ruby. There's no doubt in my mind that there will be swarms of people developing with the language, but AFAICT, we'll mostly only see Apple developers working on the language itself.
- riffraff 12y agoalso, isn't swift intimately tied to Cocoa & co? Even if apple made great strides in open sourcing the language, compiler etc, I doubt we'll ever be able to run it on anything other than OSX/iOs.
- Jtsummers 12y agoThe swift API, not necessarily the language. No more than obj-c is at least. With the support for swift to call obj-c code, if they release an implementation it might be interesting to see where projects like Etoile can take things.
- coldtea 12y ago>There's no doubt in my mind that there will be swarms of people developing with the language, but AFAICT, we'll mostly only see Apple developers working on the language itself. Well, it's not like there's a "vibrant community" working on Ruby either. AFAIK, the core developers are Japanese ( http://rubycoreteam.heroku.com/ http://rubycoreteam.heroku.com/ ) and the core communication and decisions is mostly opaque to outsiders, and new language stuff mostly comes in bunches pre-formed. As opposed say to Python and the PEPs discussion, PHP etc.
- galfarragem 12y agoI'm not a rubyist, neither I am a professional programmer, but I'm sad that Apple didn't/couldn't choose Ruby as their main language. Nowadays I'm deciding what programming language to learn as a hobby. Reality (market) tells me that should be JavaScript or right now Swift (looks like javascript for me). It makes me sad, I wish it could be Ruby. So clean and clear. Everything makes sense, I don't need to memorize almost nothing. Edit/Disclaimer: My first contact with programming (besides BASIC) was Autolisp (Autocad scripting) and my professional field is design.
- tendom 12y agoRuby isn't fast enough, and it would chew battery on a phone and make some apps impossible to do correctly. Ruby is a great language, it's my favourite hands down, but all that sugar comes at a cost. Even in ruby, we often use c libs to do the heavy lifting, they're just wrapped by ruby using the C extension framework.
- samstokes 12y agoThe RubyMotion folks disagree: 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-sneak-peek-android-support http://blog.rubymotion.com/post/87048665656/rubymotion-3-0-s...
- tendom 12y agoIt's a bold claim, but I haven't seen anything to back it up. I haven't tried all the apps made with the framework, but I haven't seen too many heavy apps that would require the power. Every game is a puzzler of some sort it seems. Nothing to really test if it is fast enough for gaming, or time critical operations.
- Karunamon 12y agoAs a wannabe-rubyist who thinks reading Obj-C is somewhere between having a migraine and using H2SO4 eye drops, so far I'm in love with the language. I'm doing lots of tripping over the Cocoa APIs, though, in no small part due to Xcode. 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.
- allsystemsgo 12y agoIt's still in beta dude. Night and day difference between beta and gold master. If you're turned away from a brand new language due to an IDE's autocomplete, then you're in for a world of hurt when you start learning all the Cocoa APIs.
- e1ven 12y agoSure, and he acknowledged that they're still working on it, and is filing bug reports ;) 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 ;)
- heydenberk 12y agoOptional binding in JavaScript is a misfeature, and Ruby's looks that way too, because 99% of the time when you do this: 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) }
- chc 12y agoThe thing that's interesting about optional binding is Swift is that it is a special construct for unwrapping optionals, not a normal assignment. If you try to bind to something that is not an optional using that syntax, it won't work. For example: 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.
- mcosta 12y agoWhy Rubyist Will Love Swift? Because Apple has published it. Disclaimer: I have walked the tutorial and reference and I belive it is fantastic. I am waiting for someone to release a linux compiler.
- sigzero 12y agoThat might be a long while.