Swift Playgrounds

Apple just announced this:

http://www.apple.com/swift/playgrounds/

There were a lot of rumours swirling beforehand of “Xcode for iPad”. This is somewhat different, in that it appears to be much more education geared.

I think this is good for Codea. I’m seeing lots of tweets from people saying “who knew you could CODE on an iPad??” Anything that raises awareness of the iPad as a creative/ productive device is good news.

Curious as to how it works under the hood, and what the performance will be like. Swift Playgrounds on the Mac have somewhat disappointing performance IMO, because they’re a full version of the language that is compiled and run as you type, so after you enter some new code, there’s significant lag before the results show up. This must be something different.

The demo starts about 107 minute into the keynote video if you want to see it in action.

http://www.apple.com/apple-events/june-2016/

Or if you have a dev account and you’re feeling brave, you can try out with the iOS 10 dev preview, right now. Anyone pushed the button yet? Is Codea working OK in iOS 10? (as we all know that’s the only “mission-critical” app)

Watching the video, this is clearly not a compiled version of the language, the physics demo plays instantly, and looks like good performance (quite apart from Apple’s rule about not allowing iOS apps to compile code. Though Apple is of course allowed to break its own rules)

Their coding keyboard looks pretty good.

There’s also a store, where people can create lessons and tutorials for others.

I quite like the draggable “for” loop too. And being able to have the app run at various sizes, next to your code, or full-screen, is very cool.

Again, anything that makes coding/ coding on an iPad go mainstream is good for Codea, I think.

The swift playground reminds me of cargo-bot. You’re writing simple code to solve different puzzles. In swift, you’re using what looks like actual code, in cargo-bot, pseudo code.

It looks like there’s quite a range of things available to the end user, from very guided programming games, to much more open, sandbox-y environments. The physics demo seemed very Codea-like! The idea of having an in-app Store is innovative. I haven’t looked into it too much, but devs can use Xcode to create content for the Store, lesson packs etc. That could be huge.

According to one early adopter, “Swift playgrounds includes full iOS libraries AWESOME!”… Really? If that’s true, then that’s… quite a bit closer to “Xcode for iPad” then I first thought. Hmmmm… I might have to bite the bullet…

I mean, look at the screenshot of the spirograph code. You’ve got UIColor there, do you have the rest of UIKit?

I was thrilled when I saw Tim Cook reveals the Swift Playgrounds at WWDC 2016. This is what I’ve been waiting for from Apple and Swift. Since the first time I was playing around with Swift on XCode’s Playgrounds on my Mac, I knew it would come to iPad (iOS) eventually.

Current Swift Playgrounds is just the beginning, as it’s the main theme of this year WWDC. It will be getting better and more advance along the time. It’s just a matter of time before it will evolve into a true XCode for iOS. I predict the next step it would become something like Dringend which you can write and run code on your iPad and use your Mac as a remote build server.

Even at today state, Swift Playground is able to export a project you write on iPad onto XCode on Mac and build it into a real iOS app. It’s surprisingly pretty similar to Codea. I think Apple really observes Codea and other great coding apps on iOS and learn much from them.

I can’t wait to try this new Swift Playgrounds app. Now I have a reason to buy a new iPad. After 5 years using the original iPad. :#

The swift playgrounds looks really exciting and show’s Apple’s commitment to helping foster the next gen of dev’s - hopefully they’ll relax the rules around the “downloading” of executable code and allow Codea to have it’s code sharing functionality added back in again #FingersCrossed :slight_smile:

Yeah Apple’s flip-flopping, inconsistency, and breaking of its own rules must be really annoying for developers of IDEs like Codea. I notice that the new Pythonista 3 (Python 3 based) has “run script in Pythonista” as an option in the share pane of other apps, so perhaps Apple is relaxing the rules a little. The API of Codea is now super-solid, I think where it most needs work to meet the challenge of these new competitors (Swift Playgrounds and Pythonista 3) is better file organisation (folders) and file sharing. Currently it’s too painful trying to share a project with assets, and that hampers our ability to create tutorials and newcomers’ ability to get to grips with the Codea platform.

Apple isn’t flip-flopping nor inconsistent. It’s just the process of the platform getting mature. Something that was thought as bad things on the platform earlier, can be reconsidered as good things after the platform getting better and advance. Remember the lack of copy-paste feature on the early versions of iOS? :smile:

Codea will always has its own market on graphics programming. However, I heard from a few fellow Codea users I know, the main problem with Codea are:

  1. the LUA language isn’t really popular in other programming field so learning it isn’t really rewarding, and
  2. the lack of built-in UI controls and widgets that expectedly be similar to the native iOS components.

These are the two advantages of Pythonista over Codea. More or less, I agree with them. Though I’d open Codea anytime I need to play around with graphics, but most of the time I open Pythonista for quick app prototyping.

I’ve been expecting Codea would provide a built-in UI controls and widgets since like ages ago. Something that I believe would eventually be added into Swift Playgrounds as well. :wink:

I just watched the “Introducing Swift Playgrounds” video from WWDC 2016. I must admit, this Swift Playgrounds for iPad is really really awesome!

To answer some of the previous questions…

  1. It’s not as simple as it looks from the opening WWDC video. It’s a LOT more than that. It also has Minecraft-like world ready to use!
  2. It’s the same compiled version of Swift on Mac/Linux. It’s just there’s something called Live View API that is able to run some (hidden) additional code independently but still could interact with the user’s code.
  3. It looks like it has access to all iOS SDKs. You can even control a remote robot through Bluetooth using CoreBluetooth SDK right from the Playgrounds on the iPad!
  4. It even has some kind of visual debugger like the one available in the Playgrounds in XCode.
  5. And some more… just take a look at the video above.

I would say this Swift Playgrounds app is indeed the first version of XCode for iOS. This app completely blows any other coding apps currently available on iOS out of the water.

Can’t wait to try it! :smiley:

Apple isn’t flip-flopping nor inconsistent. It’s just the process of the platform getting mature. Something that was thought as bad things on the platform earlier, can be reconsidered as good things after the platform getting better and advance. Remember the lack of copy-paste feature on the early versions of iOS? :smile:

Tell that to developers who have been told to remove functionality or else their app will be taken down. The rule used to be “no code sharing”. That seems to have been relaxed (in that Pythonista has been “allowed” to get away with it for a while), but how these rules are applied is opaque and inconsistent.

  1. the LUA language isn’t really popular in other programming field so learning it isn’t really rewarding, and
  2. the lack of built-in UI controls and widgets that expectedly be similar to the native iOS components.

Horses for courses. It’s true that Lua doesn’t trouble the top-ranking languages on GitHub or StackOverflow or whatever, but that’s not an issue. Lua is the most popular scripting language for game modding, because it’s so light and fast, bridges well to C etc. There are lots of Lua-based Game IDEs, such as Corona, or Defold (the engine that King use for Candy Crush).

Lua is easy to learn, powerful, and is close enough to other scripting languages (Javascript) or script-like languages (Swift) that it serves as a good introductory language I feel.

Codea is (currently) the app that gets you closest to the metal. It’s the best for GPU-related stuff.

Pythonista, with all its libraries, is always going to be better for plugging you into the wider iOS ecosystem (contacts, camera roll, dropbox, whatever).

Now if Swift Playgrounds does indeed give access to the full SDK, including SpriteKit, SceneKit, Metal, UIKit etc, then Codea and Pythonista now have some heavyweight competition. Exciting times ahead.

@bee I think that @yojimbo2000 is referring to how Apple tends to copy features in apps that third-party developers come up with and then banning the original from using said features (Camera+ and Flux come to mind). Usually this is due to things like the use of private APIs which is understandable, but their inconsistency with the terms of service with regards to downloadable code is a bit annoying.

Pythonista has featured downloadable code in the past while Apple has been very strict with Codea (to the point of threatening to ban us from the App Store). They have tightened these restrictions over time, even going as far to ban us from enabling iTunes file sharing (even when it’s only usable for backing-up projects, not uploading them). The recent release of Pythonista 3 with the ability to use app sharing to download and run executable code may be promising for Codea, but I wouldn’t count on Apple applying the rule fairly or consistently.

@bee As for UI controls I agree this is something Codea has lacked for a long time and I would like to integrate at some point in the near future.

It’s the same compiled version of Swift on Mac/Linux.

I’ve not seen that full video yet, but yeah I was starting to get the impression it is. Apparently Swift 3 compiles faster than Swift 2.2. Still, someone on Twitter was saying that the performance of Swift Playgrounds wasn’t great on an iPad Air 1. Presumably they meant the compile-time, once the code is running it’ll be fast. I’ve always found the compile time of Swift Playgrounds on Mac to be a little disappointing. Hopefully Swift 3 speeds things up a little.

This also confirms that Apple is breaking one of its rules, “no code compilation on iOS”. Whether 3rd party devs will be allowed to do this is anyone’s guess. I think it’s very sad that Apple feels the need to ring fence certain features for itself.

On the subject of code sharing, the current beta of Working Copy already has file sharing with Swift Playgrounds! Swift Playgrounds hasn’t been in beta for more than a few days and it’s already acquired full Git support

@bee thanks for posting that video. You’re right, that is amazing. Basically anything you can do on a Mac Xcode playground, you can do on iOS. So, yeah, it is basically Xcode on iPad (or, all the fun bits of Xcode on iPad. Not the tedious code signing, archive building stuff). It’s certainly enough to do some serious prototyping. The spherio demo at the end where he drives the robot over bluetooth is pretty amazing. Also, with the minecraft world-building exercise, although he kind of “cheated” by plugging his noise generating code into the pre-existing minecraft book, he could have implemented the 3D world himself in the playground with SceneKit (though SceneKit startup times in playgrounds aren’t great).

I think it’s fascinating that Apple have focussed on the teaching/ learning side of things (the new playground book format) as much as on the actual coding side (the playground itself). That’s a genius idea.

This also confirms that Apple is breaking one of its rules, “no code compilation on iOS”. Whether 3rd party devs will be allowed to do this is anyone’s guess. I think it’s very sad that Apple feels the need to ring fence certain features for itself.

Apple has the privilege to break its own rules. They own the platform and the rule maker, after all. :smile: About the inconsistency of the rules implementation to 3rd party devs, I see it as more of human error instead of true Apple policy. Imagine you have hundreds (maybe thousands) of curators to evaluate tens of millions of apps. Some inconsistency here and there are expected. If you face such problem, maybe it’s just a bad luck.

Thanks for posting that video. You’re right, that is amazing.

I know, right?! :smiley: It’s also interesting to see how Playgrounds offers solutions for touch-based interaction for code editing. Surely Codea could copy some of its techniques.

As for UI controls I agree this is something Codea has lacked for a long time and I would like to integrate at some point in the near future.

I also have been suggesting this since long time ago. Nobody seems to listen though. :smile:

+1 For the UI / Widget integration :slight_smile: