Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
WWDC 2014 and Swift — Gideros Forum

WWDC 2014 and Swift

john26john26 Maintainer
edited June 2014 in Relax cafe
Interesting to see Apple announce a new language, Swift, at their WWDC. Swift bears a certain resemblance to Lua (functions are first class objects) making me wonder if it would have been better to just use Lua (or maybe Python). However, I think that Swift is a strongly typed language not duck typed. But variable types are usually inferred so in practice you see few explicit type declarations. Generics are supported as well making it look a bit Java-like...

Whether the world needs yet another programming language I'm not sure...

One thing I do approve of is a nice, readable for loop "for i in 0..3" rather than the ugly C "its really a while loop" one (although that is still an option). They've also got rid of semi colons but kept the braces (ugly!). There is no elseif either so you still need stuff like "} else if (condition) {" unfortunately.

Here's a quick overview:

https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2

Likes: HubertRonald, jdbc

+1 -1 (+2 / -0 )Share on Facebook

Comments

  • HubertRonaldHubertRonald Member
    edited June 2014
    Hi @john26

    It has reminded me a little Python and Lua too. :D

    but Swift is faster for encryption (Apple not compare it with Lua)
    image


    Maybe Apple wants to simplify some things.
    Safari of its new OS X Yosemite It is made with Javascript
    http://www.apple.com/osx/preview/apps/
    And Apple shown as its safari have better performance than google chrome



    On the other hand is the issue of integrating Macs with iOS, as they have grown 12% last year while PCs have fallen by 5% in the same period.
  • john26john26 Maintainer
    edited June 2014
    I think Swift is most heavily influenced by Python. The fact they are doing speed comparisons to Python shows they were trying to do something like Python. I'd be a bit sceptical about speed comparisons as they have no doubt chosen examples carefully and you can compile Python too if you like...

    Looks like Apple never heard of Lua unfortunately... Would be interesting to see where Lua would sit on the speed chart above especially with LuaJIT.

    I think Swift is basically Lua/Python with strong typing. You cannot do (as in Lua),

    x=5
    x="hello" -- change type of variable

    and I think you cannot have heterogenous lists

    A = { "foo",1,{1,2,3},{} }
  • jdbcjdbc Member
    edited June 2014
    I hate Objective-C, so welcome this new language.

    Anyway they could use Python or Lua, why do they create a new language?
  • john26john26 Maintainer
    I think the main motivation was to have a strongly typed language with the flexibility of Python/Lua. However, the syntax looks pretty weird. The format of anonymous functions is completely different from named functions whereas Lua has the same format, just leave out the function name. On the whole, it looks a bit weird to me! The worst thing is keeping the braces as delimiters and having no proper if.. elseif..else..end blocks just the limited/fugly C-style "if". Also, lists seem to be zero-based which is WRONG ;-)
  • HubertRonaldHubertRonald Member
    edited June 2014


    Looks like Apple never heard of Lua unfortunately... Would be interesting to see where Lua would sit on the speed chart above especially with LuaJIT.

    Totally agree with you... it would be amazing :D

    I will review the Swift free book, published by Apple
    https://itunes.apple.com/us/book/the-swift-programming-language/id881256329?mt=11

    I think Swift is basically Lua/Python with strong typing. You cannot do (as in Lua),

    x=5
    x="hello" -- change type of variable
    I guess this is done in order to improve the performance of the code as C++ (string, bool, ...)

    I also think (maybe I can be wrong) as Swift looks like Python canno't make you do the next
    Va = "3"
    Vb = Va + 0  --#TypeError: cannot concatenate 'str' and 'int' objects
    -- I miss Lua
    but if Phyton allows you
    Va = "3"
    Va = 3
    Vb = Va + 0 -- or Vb = Va
    Or also
    Va = "3"
    Vb = int(Va) + 0
    But like I said, I will review the Swift book
  • eezingeezing Member

    Swift,

    I love it: No more headers, no more types (mostly), no more semicolons, is module based, retains native performance

    I hate it: Only Apple (obviously, but still!)
  • jdbcjdbc Member
    edited June 2014
    More info:

    https://developer.apple.com/library/prerelease/ios/referencelibrary/GettingStarted/LandingPage/index.html

    It seems easier and powerful than Objective-C.

    For example to use all Foundation API:
    import Foundation
    The following step will be How do we integrate Gideros and Swift for increase performance.

    My real question is if we can build mixed apps using Gideros and Swift where some scenes are developed on Lua + Gideros and some scenes using Swift. Or may be a Lua + Gideros compiler to Swift code.
  • Looks like Apple never heard of Lua unfortunately...
    Uhmmmm, Apple have very much heard about Lua, Angry Birds has 'Lua glue' and Steve Jobs had been well aware about Lua being used. Lua was perhaps a bit too liberal for the Apple's conservative walled garden approach. Hence their own new invention -> "Swift".

    To me it has taken it's life from modern languages like Ruby, Lua and Python while eliminating issues from each of them. The python's indentations, Lua's perhaps too relaxed aproach and Ruby - I have absolutely no idea (do not work with it) but remember seeing some articles where it was used like the extension example with Swift.

    3.repetation({println("Hello"})

    I was actively busy on another project involving a lot of dotNet (not my favourite language but more preferable than Java) and I was trying to integrate Lua into my code somewhat similar to what Wax does. Due to the wonderful reflections functionality iin DotNet, the entire classes and methods are available with Lua in a single Import function from Lua script similar to the example above by jdbc.

    If you want, you can head to this article http://howto.oz-apps.com/2014/06/swift-and-shift-new-language-from-apple.html on further thoughts on Swift.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • HubertRonaldHubertRonald Member
    edited June 2014

    If you want, you can head to this article http://howto.oz-apps.com/2014/06/swift-and-shift-new-language-from-apple.html on further thoughts on Swift.
    Hi @OZApps
    Nice Paper! :D

    Also I read: "...Apple wants to use its heft to weaken the Android app ecosystem. Thanks to their shared support for C, and tools to port Objective-C to Java, it’s currently fairly easy to port an app from iOS to Android. Porting Swift apps to Android, on the other hand, would be a lot more time consuming."

    But I think the above is a matter of time.

    What I want to know (as @john26 said) how quickly is LuaJIT against Swift or how it could be measured? :-? though first we would have to install Xcode 6 Beta.
  • eezingeezing Member
    Lua was perhaps a bit too liberal for the Apple's conservative walled garden approach. Hence their own new invention -> "Swift".
    I agree that Lua is super liberal, but I love it. If you read the Lua docs, it's inferred that the language was designed to be used in a very liberal manner. Lua was intended to be used by non-engineers.

    Anyway, back to Swift. Swift for a single reason could never be somethting like Lua, even if desired by Apple. Swift is not a dynamically typed language.

    What I want to know (as @john26 said) how quickly is LuaJIT against Swift or how it could be measured? :-? though first we would have to install Xcode 6 Beta.
    Again, swift is not a dynamically typed language. Swift is basically an easier way to build Apps for Apple stuff. The code is still compiled prior to runtime... it's native code.
  • HubertRonaldHubertRonald Member
    edited June 2014


    Again, swift is not a dynamically typed language. Swift is basically an easier way to build Apps for Apple stuff. The code is still compiled prior to runtime... it's native code.
    Hi @eezing
    thanks for your replay

    Swift looks like dynamic languages, but is not one... "There is type inference, which means you don’t have to actually write down the types everywhere, in particular within functions. But types are there nonetheless"

    Here I leave this article I also found interesting
    http://blog.bruchez.name/2014/06/thoughts-on-swift-language.html#fn:3

  • HubertRonaldHubertRonald Member
    edited June 2014
    Also I found this test (Floating point benchmark) between C++, Java, Python, Lua and LuaJIT
    http://marchdvd.com/?p=225&cpage=1
    and LuaJIT is like C++ in time compilation, in this case.

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • That's an interesting move.
    For those who see a future in HealthKit, HomeKit, iOS in the car and everything else, learning Swift (or finding a Swift coding ninja/rockstar with 10 years of experience) is the way to go I guess.

    Unless they can be targeted from cross platform frameworks but I am not sure about it.

    @OZApps read your article then went to check on twitter.
    I really hope that the two twitter accounts that you mentioned don't become the go-to resource for news about the language. I hate the fact that "something is going on behind the scenes".
    Not to mention the humour.

    Are you aware of more reliable (independent) sources of information?

    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps

  • @OZApps read your article then went to check on twitter.
    I really hope that the two twitter accounts that you mentioned don't become the go-to resource for news about the language. I hate the fact that "something is going on behind the scenes".
    Not to mention the humour.
    Are you aware of more reliable (independent) sources of information?
    Well the information about those accounts is correct however I do not think that they were 100% reliable to be the one-stop shop hence I have removed the reference from the article.

    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • jdbcjdbc Member
    I have tried to download Xcode 6 Beta from Apple developer web, but it does not appear.

    Does anybody try it and having same problem?
  • MellsMells Guru
    edited June 2014
    @OZApps my point was a statement that they were not reliable *at all* and that I wanted to keep myself away from those ones :)
    Maybe it's too early to find reliable channels to follow news on the topic.
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
  • eezingeezing Member
    @jdbc

    Assuming you're a registered developer, login to this page:

    https://developer.apple.com/devcenter/ios

    Select the iOS 8 beta tab in the main pane and xcode 6 beta download will be there.
  • jdbcjdbc Member
    @jdbc

    Assuming you're a registered developer, login to this page:

    https://developer.apple.com/devcenter/ios

    Select the iOS 8 beta tab in the main pane and xcode 6 beta download will be there.
    Thanks I did not find it!

    I have a look to swift then.
  • Maybe it's too early to find reliable channels to follow news on the topic.
    There are quite a few things happening in the Swift space. Since it is new, there are those that are trying to get in there first.

    It is unclear on what is covered by the NDA as the book on swift is free but pictures of OS X, xCode are all under the NDA. If you want to learn about any of these, the Apple videos are amazing and better in comparison to the earlier ones from previous years.

    Wait till september, there will be a lot of Books, courses, etc that would be available.

    GitHub already has several samples, stackoverflow is *overflowing* with swift discussions, reddit and IRC also is buzzing with advanced discussions.

    The point is finally this is a script like language and has a terminal (command-line REPL) or the GUI based Playground (Live-Coding) with amazing capabilities. It all depends on how easy it would be to integrate with what we want AND secondly, it is available for newer versions only, so it will be a while before everyone would be able to use them in apps and have apps made with swift.
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • @OZApps yes, Github/IRC/Stackoverflow.

    I'm wondering what the official learning center by Apple will look like.
    Dev oriented, and/or "want to be a dev in the future" oriented.
    Certainly, there is an idea behind the choice they made for demonstrating Playground.

    They might want to open it to the education field next, now that the barrier to entry is a bit lower.
    twitter@TheWindApps Artful applications : The Wind Forest. #art #japan #apps
Sign In or Register to comment.