TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why Rubyist Will Love Swift

36 pointsby mattsearsalmost 11 years ago

7 comments

Argorakalmost 11 years ago
I&#x27;m not buying this. It basically says &quot;there are a few concepts in Ruby that map nicely to Swift&quot;. There are quite a lot of concepts that don&#x27;t map, for example evaluated classes, which enable things like:<p><pre><code> class Foo include Virtus.model attribute :foo, String end </code></pre> 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.
heydenberkalmost 11 years ago
Optional binding in JavaScript is a misfeature, and Ruby&#x27;s looks that way too, because 99% of the time when you do this:<p><pre><code> if (hasAccess = true) { doSomething(); } </code></pre> you meant to compare, not assign. So when I saw this Ruby example, I was not amused:<p><pre><code> if current_user = find_current_user notify_user(current_user) end </code></pre> However, the Swift equivalent is the best of both worlds:<p><pre><code> if let currentUser = findCurrentUser() { notifyUser(currentUser) }</code></pre>
评论 #7889774 未加载
angersockalmost 11 years ago
<p><pre><code> if current_user = find_current_user notify_user(current_user) end </code></pre> Funny to see an anti-pattern in C&#x2F;C++ so lauded in another community.<p>Also, you know what I like about Ruby? I can write it and it&#x27;ll run everywhere, and it is maintained by a vibrant community effort. Where&#x27;s that on this list?
评论 #7889384 未加载
评论 #7889858 未加载
mcostaalmost 11 years ago
Why Rubyist Will Love Swift? Because Apple has published it.<p>Disclaimer: I have walked the tutorial and reference and I belive it is fantastic. I am waiting for someone to release a linux compiler.
评论 #7889819 未加载
asolovealmost 11 years ago
The 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.
评论 #7889498 未加载
Karunamonalmost 11 years ago
As a wannabe-rubyist who thinks reading Obj-C is somewhere between having a migraine and using H2SO4 eye drops, so far I&#x27;m in love with the language. I&#x27;m doing lots of tripping over the Cocoa APIs, though, in no small part due to Xcode.<p>The error messages you get when you&#x27;ve done something wrong are unintuitive at best and downright misleading at worst.<p>Example: I&#x27;ve got a field I want to render an image in. It&#x27;s represented as an object of type NSImageCell.<p>I&#x27;ve got my image file defined as an object of type NSImage. So far, so good.<p>I type the . after the image cell, and I&#x27;m presented with a number of autocomplete suggestions. One of which is a method called &quot;setValue&quot; which accepts an object as an argument.<p>Okay cool.<p><pre><code> myCell.setValue(NSImage(named: &quot;myImage&quot;)) </code></pre> Compile and.. instacrash with &quot;Unrecognized selector&quot;<p>What?<p>Some research turns up that this error means you&#x27;ve tried to send a message to (call a method on) something that doesn&#x27;t accept that type of message.<p>Turns out that the method I needed is called setObjectValue. And it also accepts an object as an argument.<p>So, Xcode. Why did you give me setValue as an autocomplete when it isn&#x27;t valid on that object? Why are these method names nearly identical? <i>facepalm</i><p>And that&#x27;s before I get into the almost completely worthless inline error messages. &quot;Cannot convert to $T1&quot;. What?<p>I really, really like the language, but Xcode is trying its damndest to turn me away. I&#x27;ve got a stack of bugs&#x2F;feature requests that need to be entered into Apple&#x27;s reporting tool - hopefully some of these are just warts that&#x27;ll get fixed as Xcode 6 comes out of beta.
评论 #7889595 未加载
评论 #7889892 未加载
评论 #7889608 未加载
galfarragemalmost 11 years ago
I&#x27;m not a rubyist, neither I am a professional programmer, but I&#x27;m sad that Apple didn&#x27;t&#x2F;couldn&#x27;t choose Ruby as their main language. Nowadays I&#x27;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&#x27;t need to memorize almost nothing.<p>Edit&#x2F;Disclaimer: My first contact with programming (besides BASIC) was Autolisp (Autocad scripting) and my professional field is design.
评论 #7889594 未加载
评论 #7889578 未加载
评论 #7889694 未加载
评论 #7889950 未加载