Slashdot Mirror


A Beginner's Guide To Programming With Swift

Nerval's Lobster (2598977) writes Earlier this year, Apple executives unveiled Swift, which is meant to eventually replace Objective-C as the programming language of choice for Macs and iOS devices. Now that iOS 8's out, a lot of developers who build apps for Apple's platforms will likely give Swift a more intensive look. While Apple boasts that Swift makes programming easy, it'll take some time to learn how the language works. A new walkthrough by developer David Bolton shows how to build a very simple app in Swift, complete with project files (hosted on SourceForge) so you can follow along. A key takeaway: while some Swift features do make programming easier, there's definitely a learning curve here.

14 of 72 comments (clear)

  1. Just what we needed... by __aaclcg7560 · · Score: 2

    Another language filled with adverbs.

    1. Re:Just what we needed... by MightyMartian · · Score: 3, Insightful

      Another attempt by a vendor to try to lock in software development and make cross platform development incredibly difficult by introducing a new language.

      Fuck, I do tire of the sociopathic tendencies of corporations.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    2. Re:Just what we needed... by iluvcapra · · Score: 4, Insightful

      Thank god we have Android Dalvik, where I can use my existing Java ME codebase. Oh wait.

      We're going from Obj-C to Swift, this seems like a pretty lateral move from a "cross platform" perspective. I would have thought the Great Java Wars had taught everyone that true cross-platform development is a chimera that isn't worth either the vendor or developer's effort. Platform vendors compete on features -- cross platform is antithetical to competition on features.

      --
      Don't blame me, I voted for Baltar.
    3. Re:Just what we needed... by iluvcapra · · Score: 2

      From most perspectives Swift is ridiculously ugly and not very interesting.

      public interface Troll {
        void post();
      }
       
      public class Complaint implements Troll {
        @Override
        public void post() {
            System.out.println("Swift is ridiculously ugly, especially compared to Java!");
        }
      }
       
      public class TrollFactory {
        public Troll getTroll(String trollType){
            if(trollType == null){
              return null;
            }
            if(trollType.equalsIgnoreCase("COMPLAINT")){
              return new Complaint();
            }
            return null;
        }
      }

      --
      Don't blame me, I voted for Baltar.
  2. Yeah but does it run on by Spy+Handler · · Score: 2

    Linux? Or do I have to buy a mac.

  3. Slight Misunderstanding by iluvcapra · · Score: 3, Informative

    TFA is actually mostly a Cocoa application stack guide. Discussion of the actual distinguishing features of Swift is minimal -- in fact I think the only thing they even passingly mention is unwrapping of Optionals. Otherwise it's just "How to build an iOS app"

    --
    Don't blame me, I voted for Baltar.
  4. Re:Embracing the bird by MightyMartian · · Score: 4, Funny

    If you start with PHP, even Brainfuck looks fun and refreshing. Jesus pal, talk about damning a language with faint praise.

    --
    The world's burning. Moped Jesus spotted on I50. Details at 11.
  5. Re:learning curve? by narcc · · Score: 2

    They did ... once upon a time. Remember HyperCard?

    I don't know why people are so desperate to believe that programming is difficult. How old were you when you (very likely on your own) learned to program? 8 or 9 years old?

    I know, I know, if we give the unwashed masses simple and powerful tools they'll write bad code. The horror. Better leave it to the professionals. Surely, they never produce unmaintainable garbage...

  6. Yeah but does it run on by slashdice · · Score: 2

    The 1.0 syntax was just barely frozen. There are a couple open source swift implementations (check github... you won't find them on source forge!) that are making progress. Not sure how useful it would be without a Cocoa/OpenStep library, though.

    --
    Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
  7. Re:learning curve? by Dutch+Gun · · Score: 2

    Programming is sort of like cooking. Anyone can learn the basics and make some interesting and satisfying stuff - even an eight year old can to do some rudimentary stuff. I'd even venture to say that many people can make a living at it, as there are lots of jobs that don't involve doing incredibly demanding tasks - just basic production work. But there are also top tier jobs that require extremely experienced and talented professionals with years of study under their belt. Not everyone is suited for that job, but that's fine, since there are quite a bit fewer of them anyhow.

    In other words, there's nothing wrong with making tuna casserole (using Hypercard to create a simple database application), but don't try to kid yourself it's basically the same thing as creating a full course meal at a four-star restaurant (writing low-level, high-performance code in C).

    And, just like there are bad chefs to have no real business being in the kitchen, there are professional programmers who shouldn't be coding until they've polished up their skills or gained some more experience. The fact that there's so much badly written code out there seems to demonstrate that programming well is rather more difficult than many would like to admit.

    --
    Irony: Agile development has too much intertia to be abandoned now.
  8. Re:learning curve? by narcc · · Score: 2, Insightful

    That's delusional. I've been at this longer than a lot of users here have been alive, yet the only "complex" applications I've seen are either unnecessarily complex or complex for reasons completely unrelated to programming.

    It's not like cooking at all. That's just wishful thinking.

    Programming is easy. Ridiculously easy. You know this, I know this. Why hide it?

    Why not produce easy tools for non-programmers to use? We use programming languages to make writing software easier, after all. Why are modern languages and tools becoming increasingly more complex? Software isn't getting more complex in general, so why are our tools? What are we afraid will happen? That we'll lose our jobs? That people won't admire us for a skill easily attainable by young children?

    there's nothing wrong with making tuna casserole (using Hypercard to create a simple database application), but don't try to kid yourself it's basically the same thing as creating a full course meal at a four-star restaurant (writing low-level, high-performance code in C).

    But it is! The EXACT same skills and principles apply equally in both cases. (Note: This is not the case for cooking. Your analogy breaks immediately.) The only difference is that you need to know a few additional technical details to use C effectively. That's tangential to programming, no different than something like domain specific knowledge you'd need writing programs for use in different industries.

  9. SWIFT will be great for agile development ... by PPH · · Score: 2

    ... Tom said spryly.

    --
    Have gnu, will travel.
  10. Re:learning curve? by Dutch+Gun · · Score: 2

    I happen to have written large-scale commercial videogames in C++ for most of my career. I've worked with lots of people, many smarter than me, and I don't recall anyone talking about how their programming work was "ridiculously easy". I'm glad everything is so simple for you, but apparently we're not all so fortunate.

    --
    Irony: Agile development has too much intertia to be abandoned now.
  11. Re:learning curve? by narcc · · Score: 2

    it didn't sound like he was open to any sort of reasonable discussion

    Well, you're right about that. A "reasonable discussion" isn't possible here. Can you have a "reasonable discussion" with a creationist? Neither can I. All you can do is show them the facts. It's up to them to accept reality, just as it's up to you.

    Just look at the parent here:

    designing complex systems for reliability and maintainability is not

    Ah, but it is! (Hell, if it's actually complex, it's not maintainable.) See, most "complex systems" are only complex because of how their designed (poorly). Yes, some things are actually complex but that's generally completely unrelated to programming (see my earlier post).

    Personally, I blame the OOP craze for the dramatic increase in unnecessary complexity. We've got two generations, now, of programmers who know nothing about modularity, but believe (inexplicably) that OOP gives them modularity for free.

    This shouldn't be controversial. The only explanation I have for the need to believe that programming is difficult is fear.