DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • A Developer’s Guide to Multithreading and Swift Concurrency
  • Automate Developer Routine With Swift in iOS Development
  • How to Make a Picture-in-Picture Feature in iOS App Using AVFoundation
  • Why You Might Need To Know Algorithms as a Mobile Developer: Emoji Example

Trending

  • Medallion Architecture: Efficient Batch and Stream Processing Data Pipelines With Azure Databricks and Delta Lake
  • Teradata Performance and Skew Prevention Tips
  • The Role of Functional Programming in Modern Software Development
  • Apache Doris vs Elasticsearch: An In-Depth Comparative Analysis
  1. DZone
  2. Coding
  3. Frameworks
  4. Learning to Code With Swift Playgrounds

Learning to Code With Swift Playgrounds

Swift Playgrounds from Apple is a slick integrated coding education tool — how far does go it to teach one of the hottest languages of the past 5 years?

By 
Chris Ward user avatar
Chris Ward
DZone Core CORE ·
Apr. 02, 20 · Review
Likes (4)
Comment
Save
Tweet
Share
7.5K Views

Join the DZone community and get the full member experience.

Join For Free

Many years back (well, five or so, but that's an eternity in technical worlds), I used to be the editor of the mobile channel of a developer website. This was when app-building was the hottest thing in town, and well, Objective-C, the default language for building iOS apps, was looking ancient.

Then in 2014, Apple announced, Swift, a new modern option for building apps in the Apple ecosystem, and with an increasing amount of cross-platform, server-side support, it was always a language I had a lot of hope for and kept a keen eye on.

But that was then, and I haven't touched Swift ever since, as I did not need to. When Apple announced Swift playgrounds for iPad, I was intrigued, especially at the promise of a tablet app for (learning) development. Still, it took the announcement of the macOS version for me to sit up and notice.

The entire application is an integrated tutorial and playground (forgive the pun) that walks you through each step in abstract concepts to begin with, and gradually increasing complexity.

The Playgrounds interface

Like other playground type learning tools, it encourages you to only progress to the next lesson until you provide a correct solution.

I tried the beginner lessons, and they consist of issuing simple functions to meet a goal, for example, moving a character called "Byte" to collect a gem with abstract functions such as:

Swift
x
 
1
moveForward()
2
moveForward()
3
moveForward()
4
collectGem()


These cause Byte to walk forward three times and collect a gem, but don't flesh out what the function does in detail.

If you make mistakes as you go, then Byte reacts comically, and you can restart the lesson. Some of the lessons feel more like lessons in spatial awareness and game theory than coding (figuring out which way Byte should face, for example). There is also a debugger of sorts that allows you to step through your code slowly, and as lessons progress, it teaches you about fixing bugs by walking through existing code to see what commands are incorrect and moving them.

As the lessons progress, Playgrounds teaches using functions as a way to identify and create repeatable code that you can call from other parts of your code, and nest inside other functions.

Playgrounds teach repetition, first by introducing for loops for performing a fixed number of steps, and then after teaching conditional code, and logic introduces while loops, and even nested loops.

In the final lesson of the first official playground, Playgrounds combines everything learned so far to introduce algorithms and trying to not only find a way to achieve a task, but the most efficient way to achieve a task.

Taking Learning Further

Playgrounds let you go surprisingly far, with templates set up for moderately advanced learning for creating games, graphing, media, interaction with sensors on the iPad, and the ability to connect to and control other devices. It also introduces you to basic IDE features such as code completion, inline-documentation, a limited syntax library for those who want to experiment as they go. The depth and quality of some of the lessons vary, with the ones made by Apple by far the best quality and most user friendly to use.

Snippets library

One of the main concepts Playgrounds doesn't (or can't) teach us things like dependencies and using external libraries. Apple claims that you can open Playgrounds in XCode, but I could not figure out how. It's also confusing, as XCode already has a feature called playgrounds, which are slightly similar, but not the same thing.

One thing you can definitely do with XCode is to create content for Swift Playgrounds using starting templates.

Swift (programming language)

Opinions expressed by DZone contributors are their own.

Related

  • A Developer’s Guide to Multithreading and Swift Concurrency
  • Automate Developer Routine With Swift in iOS Development
  • How to Make a Picture-in-Picture Feature in iOS App Using AVFoundation
  • Why You Might Need To Know Algorithms as a Mobile Developer: Emoji Example

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!