Apple's top secret Swift language grew from work to sustain Objective C, which it now aims...

245

Comments

  • Reply 21 of 93
    freerangefreerange Posts: 1,597member
    The article is pretty much Greek to me from a technical standpoint, but it is obvious that the incredible Apple team is going to continue to make this company even greater!
  • Reply 22 of 93
    rayzrayz Posts: 814member
    Quote:

    Originally Posted by Rogifan View Post



    Of course ZDNET aka Microsoft's PR arm, pisses all over Swift. image



    http://www.zdnet.com/apples-new-swift-development-language-highlights-the-companys-worst-side-7000030150/

     

    That's a relief!

     

    If ZDNET hadn't gone into panic mode on Microsoft's behalf then I might have been worried.

  • Reply 23 of 93
    rayzrayz Posts: 814member
    Quote:

    Originally Posted by gwmac View Post

     

    I have no technical reason for stating this because I am no programmer. I can hold my on with some HTML and some scripts but when it comes to C and other languages I am lost. What I want to say is based strictly off a gut feeling, but I think Swift might not only be the biggest news this WWDC but possibly in many years. From what I can gather this is a leaner, meaner, more modern language that could allow an entire new generation and pool of talent that were scared to death of Objective C as being too difficult to even attempt to learn. All those people fluent in other languages shouldn't have many problems transitioning and learning Swift. It also seems a lot of the knowledge acquired with Objective C can be used with Swift.  So far it seems like Swift is a much less daunting language to learn. WWDC is sort of like the cement conference where they pour the foundation. In the fall the iPhone 6 and hopefully several other new products will be the skyscraper.


     

    I've done a lot of development over the last twenty years. Started out with C then C++ then Java, Ruby and now getting to grips with Python.

     

    I've avoided ObjectiveC because, quite frankly, I just didn't like the look of it. I've seen amazing things done with it and I'm happy to admit that I was being very narrow-minded, but with such great things happening in IT, I just couldn't see the point of learning something that looked like C in a pretty dress. I went through the Swift manual in one night (yes, I stayed up all night to read it). 

    No, it's nothing new in terms of language design, but it's something new on the fastest growing, most cohesive ecosystem out there. 

     

    The language is fast, buzzword-compliant and is backed by an cloud application platform (think Google app engine). This is the beginning of a massive assault on the enterprise market.

  • Reply 24 of 93
    ripperripper Posts: 7member

    Apologies if this shows up more than once; the previous attempt looks like it got et.

     

    I want to love Swift, but at this stage I just can't, not in its current state.  I've only gotten through about the first 200 pages of the iBook but there are things that, IMO, could/should be more rationalized, particularly some of the syntax.  A couple things off the top of my head:

     

    Variables are declared: var foo: Int

    That's fair enough, but then 'optionals' are declared: var foo:Int?

    That's too little of a difference (ok, I'm used to C's * for pointers and that's only a single character so...).  Anyhow, so I want to use my optional, it's easy in a boolean context to determine if it has a value:

     

      if foo {...

     

    but in a scalar context I have to refer to it:

     

      bar = foo!

     

    or decompose it in the boolean context:

     

      if var bar = foo {

        // do something with bar

     

    But, that's not all.  I could actually declare it:

     

      var foo: Int!

     

    What does that buy me?  The ability to refer to it in a scalar context directly:

     

      bar = foo

     

    In the boolean context it's still interpreted as 'does it have a value' thus the context is clearly known in interpreting it.  So, why two different ways to specify it and use it?

     

    In light of the contextual interpretation, I could argue that having all variables be 'optionals' by default would be a more natural and consistent approach.  The compiler can certainly warn you if you're attempting to use it before assigning it a value and even if you ignore that warning it's a runtime fault to use it if it doesn't have a value.  With 'optional' as the default (only?) type, all variables could be used in the exact same way; e.g.

     

      var foo: Int

      ...

      if foo {

        // do something with foo

      } else {

        // foo has no value

      }

     

    Second, the inconsistency between:

     

      let array = [a, b, c]

      let dictionary = [d : 1, e : 2]

     

    According to the documentation this creates, respectively, an immutable array and dictionary, except the dictionary is truly immutable and arrays are only sort-of immutable.

    While the dictionary cannot be changed at all and the array can't change size, the contents of the array can be changed.  That's hardly immutable and certainly different from the true immutability of NSArray.

     

    That's probably enough for now for you all to take me to task. :-)

    I'd love something more modern than Objective-C, something where everything is an object, say.  Or any number of other things, but as it stands, I don't think Swift is it.

  • Reply 25 of 93

    Originally Posted by Tallest Skil View Post

    Let’s muse:

    Will Swift really be able to supplant Objective-C?


    Given that the AppStore launched in 2008, and I'd have to surmise that the vast majority of submissions are from people who never looked at Obj-C before that point, that implies Apple convinced thousands (millions?) of people to pick up Obj-C in the last five years.

     

    So why shouldn't they convince them to switch to something that's supposedly much better? MS did with C#.

  • Reply 26 of 93
    tallest skiltallest skil Posts: 43,388member
    Originally Posted by Maury Markowitz View Post

    MS did with C#.


     

    They use some F#, too, don’t they?

  • Reply 27 of 93
    solipsismxsolipsismx Posts: 19,566member
    Given that the AppStore launched in 2008, and I'd have to surmise that the vast majority of submissions are from people who never looked at Obj-C before that point, that implies Apple convinced thousands (millions?) of people to pick up Obj-C in the last five years.

    So why shouldn't they convince them to switch to something that's supposedly much better? MS did with C#.

    And it's much easier 1) to learn, 2) to type (since it's less complex code structures and typically much shorter in length), 3) to read (for the reasons give for "to type"), 4) to see an error as you're typing it, and 5) to comprehend where and why your code is changing at any given point. Including with those points is the lack of header files.

    My comprehension of Obj-C is low and believe you me I've been trying to become proficient for years, but I'm picking up Swift quickly.
  • Reply 28 of 93

    Originally Posted by SolipsismX View Post

    And it's much easier 1) to learn, 2) to type (since it's less complex code structures and typically much shorter in length), 3) to read (for the reasons give for "to type"), 4) to see an error as you're typing it, and 5) to comprehend where and why your code is changing at any given point. Including with those points is the lack of header files.



    My comprehension of Obj-C is low and believe you me I've been trying to become proficient for years, but I'm picking up Swift quickly.

    Agree completely. With a few exceptions - "let", "->" and why oh god are there "@'s" in this language - I found it totally easy to grasp.

     

    If there were users that were turned off iOS/MacOS because of Obj-C, maybe this will grab them too. For those who haven't used it, this strikes me as all good.

     

    BTW, did you come across a way to call C code from Swift? I have whole libraries of C that do math, am I up the creek?

  • Reply 29 of 93
    SpamSandwichSpamSandwich Posts: 33,407member
    Quote:

    Originally Posted by SolipsismX View Post





    And it's much easier 1) to learn, 2) to type (since it's less complex code structures and typically much shorter in length), 3) to read (for the reasons give for "to type"), 4) to see an error as you're typing it, and 5) to comprehend where and why your code is changing at any given point. Including with those points is the lack of header files.



    My comprehension of Obj-C is low and believe you me I've been trying to become proficient for years, but I'm picking up Swift swiftly.

     

    ;)

  • Reply 30 of 93
    wizard69wizard69 Posts: 13,377member
    chandra69 wrote: »
    I only finished a little.  I felt like ... it is scripting language and awesome.
    I think I've managed to read a dozen or so pages and I have to agree it has a nice feel to it.
    How do you guys find time? ;)

    Obviously I haven't if the manual is yet to be read. Maybe a little less time on AI, Reddit and so forth.

    In any event I see some initial possibilities that will make this platform great if they come to pass:
    1. Apple submits the language to a standards body so that wider adoption can happen!
    2. The way this works within XCode would make it an excellent platform for use as a scripting language within apps. In fact if I was Apple this would be a high priority for iWork.
    3. I have a feeling this could crush Python if it gets widely adopted. I really hope that Apple is hard at work porting libraries to the platform and doesn't forget about non GUI apps. So I'm hoping that Apple has goals to develop a large standard library in the same way many scripting languages have such libraries. It would be even better if Apple supports the language with a repository of modules that are open sourced.
  • Reply 31 of 93
    SpamSandwichSpamSandwich Posts: 33,407member
    Quote:
    Originally Posted by Maury Markowitz View Post

     

    Agree completely. With a few exceptions - "let", "->" and why oh god are there "@'s" in this language - I found it totally easy to grasp.

     

    If there were users that were turned off iOS/MacOS because of Obj-C, maybe this will grab them too. For those who haven't used it, this strikes me as all good.

     

    BTW, did you come across a way to call C code from Swift? I have whole libraries of C that do math, am I up the creek?


     

    Just chiming in here, but I thought the beauty of Swift was that it will accept C in addition to Swift code. Am I wrong?

  • Reply 32 of 93
    wizard69wizard69 Posts: 13,377member
    Objective C isn't much more than an enhanced C as a language. What people had to spend a lot of time on was learning the APIs which are extensive.
    Given that the AppStore launched in 2008, and I'd have to surmise that the vast majority of submissions are from people who never looked at Obj-C before that point, that implies Apple convinced thousands (millions?) of people to pick up Obj-C in the last five years.

    So why shouldn't they convince them to switch to something that's supposedly much better? MS did with C#.

    The big problem here is that this is a bigger departure from C/Objective C and as yet they haven't indicated any desire to public ally standardize it. I suspect many developers would be happier if they had some assurance that Swift will grow outside if Apple.
  • Reply 33 of 93
    solipsismxsolipsismx Posts: 19,566member
    Agree completely. With a few exceptions - "let", "->" and why oh god are there "@'s" in this language - I found it totally easy to grasp.

    If there were users that were turned off iOS/MacOS because of Obj-C, maybe this will grab them too. For those who haven't used it, this strikes me as all good.

    BTW, did you come across a way to call C code from Swift? I have whole libraries of C that do math, am I up the creek?

    So the Swift Playground is just for Swift but the noted use of NSLog means that some C-based code is allowed on some limited, preconfigured basis. There is no direct import option but I'd imagine if you also have a great deal of C code you would just make a typical app where you could still use Swift alongside C and Obj-C. Right?
  • Reply 34 of 93
    fracfrac Posts: 480member
    For Python fans, I can see quite a bit in there...
    http://www.LearnSwift.tips/
    Heads up hackers - may be that scripting is supported.
  • Reply 35 of 93
    solipsismxsolipsismx Posts: 19,566member
    Just chiming in here, but I thought the beauty of Swift was that it will accept C in addition to Swift code. Am I wrong?

    I heard it as Swift, the language, is free of archaic C-based commands (mostly) but has the performance of C, and you can write apps that incorporate C, Obj-C and Swift in any manner as you see fit because the compiler is fully compatible.
  • Reply 36 of 93
    mstonemstone Posts: 11,510member
    Quote:
    Originally Posted by Ripper View Post



    That's probably enough for now for you all to take me to task. :-)

    I'd love something more modern than Objective-C, something where everything is an object, say. Or any number of other things, but as it stands, I don't think Swift is it.

    Ok you have been working with Swift for 24 hours. Lattner has been working with it since 2010 and working on the building blocks for 15 years. He also probably has an IQ of 200. He says it can replace Obj-C and by extension most likely C, C++, C#. He has a whole team of geniuses working together on this. I'd take his word over anyone else especially someone who has only one day under their belt.

  • Reply 37 of 93
    MarvinMarvin Posts: 15,326moderator
    gwmac wrote: »
    I have no technical reason for stating this because I am no programmer. I can hold my on with some HTML and some scripts but when it comes to C and other languages I am lost. What I want to say is based strictly off a gut feeling, but I think Swift might not only be the biggest news this WWDC but possibly in many years. From what I can gather this is a leaner, meaner, more modern language that could allow an entire new generation and pool of talent that were scared to death of Objective C as being too difficult to even attempt to learn. All those people fluent in other languages shouldn't have many problems transitioning and learning Swift. It also seems a lot of the knowledge acquired with Objective C can be used with Swift.  So far it seems like Swift is a much less daunting language to learn.

    A lot of modern development is based around web programming and the iPhone was originally going to be web apps only. It needed performance and access to graphics frameworks though and C-based languages are the most popular but they are no good for rapid application development and that's what's needed these days. Turnaround times are more important than raw performance for most apps. For the ones that need the performance, they can do it the way they know how. Swift offers both performance and fast turnaround times.

    It could even replace Applescript (hopefully).

    It would be nice if they'd open source it and make moves for it to compete with C#. If it was in 3rd party SDKs like Unity, they can natively compile apps without XCode and could more easily call iOS system APIs. That might mean people don't bother buying Macs for iOS development, although the simulator would still be Mac-only and wide support and adoption of the language would be beneficial.
    Given that the AppStore launched in 2008, and I'd have to surmise that the vast majority of submissions are from people who never looked at Obj-C before that point, that implies Apple convinced thousands (millions?) of people to pick up Obj-C in the last five years.

    I doubt that's the case. A lot of apps are very simple apps, they need to be turned around quickly and deployed to more than iOS. 3rd party SDKs are used a fair bit and many simply use web languages:

    http://www.sencha.com
    https://xamarin.com
    http://www.appcelerator.com
    http://phonegap.com
    https://www.unrealengine.com
    http://unity3d.com
    http://coronalabs.com/products/corona-sdk/

    An exception is the following used for Badland, which uses Objective-C:

    http://www.cocos2d-iphone.org

    The next step (pun intended) would be to allow Swift development on iOS itself. In fact, only Swift development and not C/C++/Objective-C. People can build their sprites in some drawing app, use the app extensions to bring them in to XCode for iOS and run it in real-time. That should make Alan Kay happy.
  • Reply 38 of 93
    mdriftmeyermdriftmeyer Posts: 7,503member
    Quote:

    Originally Posted by SolipsismX View Post





    I heard it as Swift, the language, is free of archaic C-based commands (mostly) but has the performance of C, and you can write apps that incorporate C, Obj-C and Swift in any manner as you see fit because the compiler is fully compatible.

     

    It doesn't have the performance of C or Lattner and Federighi would have put up the sorting and other graphs to show it. It doesn't have the added overhead of ObjC 2.0 [they've put the magic into the compiler] but it sure won't match C11/C99.

     

    The Python comparison was obnoxious.

  • Reply 39 of 93
    bdkennedy1bdkennedy1 Posts: 1,459member
    "LLVM not only powers Apple's software, but is also tightly integrated into the development of Apple's custom silicon, including the A6 and A7 Application Processors."

    And there we have the proof that Apple with put A chips in their Macs.
  • Reply 40 of 93
    cyberzombiecyberzombie Posts: 258member
    Quote:

    Originally Posted by wizard69 View Post



    Objective C isn't much more than an enhanced C as a language. What people had to spend a lot of time on was learning the APIs which are extensive.

    The big problem here is that this is a bigger departure from C/Objective C and as yet they haven't indicated any desire to public ally standardize it. I suspect many developers would be happier if they had some assurance that Swift will grow outside if Apple.

     

    My 17th thought (after a bunch of ooohs and ahhhhs) was that I could see most of it implemented on top of a JVM.

Sign In or Register to comment.