
Swift Playgrounds for macOS - rock_artist
https://apps.apple.com/us/app/swift-playgrounds/id1496833156?mt=12%22
======
jedieaston
Now, Apple, can we please have the opposite? XCode on the iPad (even if some
features had to be removed, like VS Code is to VS), with a containerized shell
to run code we write in?

Please?

~~~
neurobashing
I've argued for a while that they need to do, as part of their services push,
is a "cloud compile" service. I know they want to sell hordes of Mac Pro boxes
to devs, but what a cool way to open up development (like, on the iPad). Write
code, save in iCloud Drive, tap "compile my app". It handles all the signing
and so on, and then boom, it's on my home screen. You limit distribution to
your devices at first - maybe you still need a Mac to sign it for everywhere
distribution, but you let any device you own run it. You can share source via
the usual open-source methods, since everyone just needs to get the code onto
their iCloud Drive to build it.

There's a huge number of moving parts to get an MVP and we mustn't cannibalize
desktop and laptop sales, but it seems like an obvious part of their services
push AND "make the iPad a 'real' computer".

~~~
skohan
How do you imagine the coding UI would work? It strikes me that coding is
extremely keyboard dependent, and also a case where screen space is important,
so it's like a worst case scenario for a soft keyboard.

~~~
nl
There are plenty of (fairly reasonable) hard keyboards for iPads.

And of course there are alternate paradigms for programming that rely on a lot
less typing.

~~~
swiley
> there are alternate paradigms for programming that rely on a lot less
> typing.

Sure, but I have yet to see one that beats a shell in a VT for ergonomics,
discoverability (most GUIs are just the opposite here,) or documentation.

------
haunter
Ofc Google had a similar project (with Javascript) but they scrapped it back
in November... It was even available on Steam

[https://github.com/googlearchive/gamebuilder](https://github.com/googlearchive/gamebuilder)

[http://web.archive.org/web/20191017085801/http://store.steam...](http://web.archive.org/web/20191017085801/http://store.steampowered.com/app/929860)

You can still download the last full build (easier than compiling on your own)
and it's actually really fun
[https://github.com/googlearchive/gamebuilder/tree/master/bui...](https://github.com/googlearchive/gamebuilder/tree/master/builds)

I pretty much hate when they abandon things like that

~~~
mattnewton
As a counterpoint, it’s labeled as “This is not an officially supported Google
product.” Maybe this isn’t enough to stave off brand association?

Would you rather they never allow engineers to release it at all? When I
worked at Apple, that was the fate of any internal effort or pet project that
did not receive full executive buy in, and as an engineer I badly prefer the
ability to open source projects in whatever state they were left, to be useful
to anyone who wants to pick the bones or start something similar.

Disclaimer: I work for Google, but my opinions are my own.

~~~
slimsag
It really bothers me that people so closely associate these "Not Google"
projects with Google. I've seen repositories with not even a README, any
documentation, or so much as an explanation of _what the project even is_ end
up on the front page of /r/programming just because "Wow it's a Google
project!! so interesting I wonder what it does???"

Google is a _huge_ company, not everybody that creates something there is
showing some internal direction of the company..

~~~
sjwright
But it doesn't say "Not Google", it says "This is not an officially supported
Google product." I read that as saying "Google totally made this, but please
don't call tech support if it breaks."

~~~
google234123
Or maybe it just means that someone spent 10% of their time at Google trying
to make something cool and it's not a serious project.

------
technoplato
I’ve been a developer for about 8 years now and have even already learned a
decent amount of Swift.

I still had a blast getting the adorable character (Byte-) to navigate around
the puzzles.

They even get into some simple yet cool path traversal algorithms that I’m
sure grow in complexity if you keep going.

I’m going to download these and have a lot of fun with them.

Would love to see this kind of paradigm evolve into more complex domains.

~~~
3fe9a03ccd14ca5
These types of things really are gateways into computer science. I’d like to
see it grow too, because early adoption really does set students apart.

I wonder how many top students in compsci programs used to do things like
install and tweak Minecraft plugins when they were younger.

------
donatj
QuartzComposer was the best playground. I really wish they'd give it some
love.

~~~
jawngee
Really, QC was one of the cooler things Apple has done since HyperCard.

I wrote a video editor that allowed you to use it to build plugins with it:
[https://vimeo.com/121663242](https://vimeo.com/121663242)

Unfortunately, life got in the way of finishing it.

~~~
umjames
I think Apple bought it and renamed it to Quartz Composer. I remember you
could use it to make screen savers and could even write your own patches for
it in Xcode.

------
jedberg
My daughter has the Osmo, which has a coding challenge. It's very similar to
this, except it's just arrow tiles and jump tiles that you lay out in front of
the iPad and then the character moves the same way.

I'm going to have her try this (she's five) and see if it's too hard since it
requires reading (or perhaps it will force her to improve her reading
skills!).

~~~
hombre_fatal
> it's just arrow tiles and jump tiles

The obvious next step for her is Befunge.

------
jacques_chester
Apple have been hiring a number of developer relations and community relations
folks from Kubernetes-land lately; my suspicion was that they were planning to
create some kind of public platform or runtime service and wanted well-
positioned ambassadors.

Maybe this is it.

~~~
ztjio
No. This is just a macOS port of an app that has been on iOS for years now.

------
tempodox
This is nice, to be sure, just too bad it's only for Catalina.

~~~
throwaway55554
It is _really_ frustrating that Apple does stuff like this.

~~~
dewey
Being built with the Catalyst framework which is only available in Catalina
seems like a pretty good reason to only have this available in Catalina.

~~~
bangonkeyboard
Catalyst (née Marzipan) apps first appeared in Mojave.

~~~
azinman2
Likely didn’t have the required apis then for this to run.

------
city41
Some larger screenshots (and more info): [https://developer.apple.com/swift-
playgrounds/](https://developer.apple.com/swift-playgrounds/)

------
zelly
I really wish there were stuff like this for more advanced topics. Where's the
gamified "write a compiler" course?

~~~
jedberg
[http://www-inst.eecs.berkeley.edu/~cs164/](http://www-
inst.eecs.berkeley.edu/~cs164/)

They have a game called "midterm" every few weeks where you can earn points
towards a final score. :)

But more seriously, would gamification really help you at that point?

------
A4ET8a8uTh0
I visited Apple store to get wife an Apple watch ( I tried to dissauade her,
but it was what she wants ) and played with the Playground toys.

Neither my brother's nor my cousin's kids are ready age-wise, but it seemed
like a ton of fun. I would love to be a kid today.

~~~
m0zg
They'd probably be watching YouTube nonstop, like all the rest of the kids
though. There are downsides to being a kid today, ones that kids don't even
realize are downsides.

------
adriansky
Looks very nice! It almost made me want to learn Swift.

The only thing is that it's used only on iOS systems. If I'm going to spend
the time to learn a new programming language, I'd like to use it everywhere
like I do with JS.

~~~
melling
The Mac app "syncs" with the iPad app. That's useful!

I'm writing a Swift Cookbook on Github for anyone who's trying to come up to
speed on Swift:

[https://github.com/melling/SwiftCookBook](https://github.com/melling/SwiftCookBook)

Trying to be more functional with my Swift:

[https://github.com/melling/SwiftCookBook/blob/master/functio...](https://github.com/melling/SwiftCookBook/blob/master/functional.md)

I'm also working through Joel Grus' Data Science from Scratch book, but trying
to rewrite the examples in Swift. I'm only a few chapters in:

[https://github.com/melling/data-science-from-scratch-
swift](https://github.com/melling/data-science-from-scratch-swift)

Things I'm doing sitting on my couch with my iPad on the arm and the book in
my lap.

~~~
jayrhynas
Quick note about your functional examples - there's already a built-in version
of `take` called `prefix` available on all Sequence types.

~~~
melling
Thanks. There’s also a prefix(while:) that appears to be takeWhile(), which I
also needed.

[https://developer.apple.com/documentation/swift/sequence/312...](https://developer.apple.com/documentation/swift/sequence/3128810-prefix)

------
dmix
Is there a good age to start introducing stuff like this to kids? My niece is
7 and seems to have the personality that would be perfect for a programmer.

But I don't want to rush her into stuff like this when she's still a kid who
should be having fun.

I was thinking around ~10 would be the ideal time. But I'm not a parent and
know little about kids and childhood development.

~~~
GordonS
> My niece is 7 and seems to have the personality that would be perfect for a
> programmer

I've worked with all sorts of good programmers, but now that I think about it,
I don't think there is a "type"?

Curious what you meant about this?

~~~
s_y_n_t_a_x
Some kids like puzzles more than others. Programming is like solving a puzzle.

------
plg
Honest question: to what extent is this a fancier-graphics version of Logo
from the 1960s? (you know, the little turtle with which you can draw shapes,
by using commands like pen down, pen up, move, turn, etc).

Does swift playgrounds teach one other stuff, in particular stuff relevant to
the MacOS or iOS API?

~~~
madeofpalk
Swift Playgrounds is essentially an interactive Swift REPL that ALSO ships
with some prebuilt learning material, some of which is "fancy logo".

~~~
hhas01
Swift Playgrounds is not a real REPL though as it re-evaluates the entire
program after every code change†. While it nicely annotates the code with per-
line results, program state is not persisted between edits and side-effectful
operations are repeated each time. That seriously limits its real-world
usefulness to little more than a cute toy.

Ironically, Swift _does_ have a true REPL which you can invoke in Terminal
(`swift`, unsurprisingly enough). That does persist state over the entire
session while showing the output of each line, albeit with old-school CLI line
editor. The Print bit really sucks though as it ignores `description` methods
and does a full debug dump of complex structures every time.

(Plus, of course, users need to be comfortable finding their way around a
1970s shell, which Playgrounds’ audience won’t be.)

Two partial “REPL” implementations that could’ve been a single knock-it-out-
the-park REPL had they bothered to consolidate and refine. Swift may be many
things, but great at joined-up thinking it is not.

\--

(†Unless they’ve changed that behavior since I last tried it. Probably not.)

------
gigatexal
Finally! I’ve been waiting for them to do this.

------
skyfaller
Has anyone read through the "Swift Playgrounds 3.2 License Agreement"? It's
kinda long.

Would it have killed them to use a standard open source license like MIT or
Apache 2.0? Don't they want as many people as possible to learn their pet
language?

~~~
kick
Playgrounds isn't free software, and for that matter isn't even source-
available.

~~~
skyfaller
That's what I'm saying, if they want as many people to learn Swift as
possible, why not open source this learning software? The Swift language is
open source under Apache 2.0, clearly the license is not alien to Apple.

~~~
kick
I don't disagree with you, but your comment was worded in a way that implied
you thought it was source-available.

Frankly, Apple probably doesn't care how many people learn Swift. Playgrounds
is aimed at children, who don't yet care about software licensing.

------
misiti3780
Is the get button disabled for anyone else in the mac store?

~~~
mayoff
You are probably not running macOS 10.15 Catalina.

~~~
misiti3780
nope,thanks.

------
elpakal
yea but is it written in Swift is what i wanna know

~~~
favorited
If you download it and run `nm
/Applications/Playgrounds.app/Contents/MacOS/Playgrounds | grep "_\$s"` from
Terminal, you can see there is lots of Swift in there.

------
inviromentalist
Any chance Apple would make it possible to compile an iOS app without giving
Apple any money?

I want to support my customers, but I don't want to support anti competitive
FAANG

~~~
darklion
> Any chance Apple would make it possible to compile an iOS app without giving
> Apple any money?

Absolutely! It's called a "web application", and you can write them in a
variety of languages, including compiled ones.

> I want to support my customers, but I don't want to support anti competitive
> FAANG

It's weird, because English is my first language, but I have no idea what that
sentence means. Perhaps you could elaborate?

FWIW, here's the closest I could come to translating it: "I want to write
applications that natively run on hundreds of millions of devices, which
development for, and use of, directly supports and props up [an anti-
competitive FAANG], but somehow as long as I'm exempt from paying them a small
annual fee, I'm morally and ethically OK with that."

~~~
city41
FWIW I would expect the OP's real objection is having to buy a Mac to develop
iOS apps, not the annual fee.

~~~
hombre_fatal
They could buy a used Macbook.

------
Angostura
Yuck - needs 10.15

------
slashblake
Real missed opportunity not calling this "Swifty Swift"?

------
polyomino

      Animations introduce each new coding concept at a high level before you dive into the puzzles
    

This sentence says the opposite of what is meant to most non-technical people.

------
mime3329
Wasn't it released in 2016 ? Why is it top of hacker news today?

~~~
jayrhynas
They recently released it on macOS (via a Catalyst port of the iPad app)

~~~
mime3329
All right! Thanks a lot. I was confused with their home page
[https://www.apple.com/swift/playgrounds/](https://www.apple.com/swift/playgrounds/)
"Learn serious code on your iPad." I guess it's just not up to date.

------
elevenoh
Anyone else here unpopularly wish they could write typescript/js & compile
directly to native iOS machine lang?

I love prototypal inheritance & JS' syntax.

I don't enjoy the swift I'm doing now nearly as much as JS/TS.

~~~
hombre_fatal
Swift and JS/TS are practically interchangeable compared to the high learning
curve of actually using UIKit/Cocoa/CoreData/Xcode/etc and building
applications with it.

I don't think language syntax is very consequential, especially Swift vs JS
which really aren't all that far apart. What I yearn for when I build mobile
clients is the ability to bring my own abstraction like I can on the web.
Instead we're stuck with old-school overly-OOP abstractions on mobile without
any truly compelling alternatives.

Like, the whole ViewController + delegation abstraction feels like using
Backbone.js in 2020. SwiftUI is one step in the right direction, at least.

~~~
elevenoh
>we're stuck with old-school overly-OOP abstractions on mobile without any
truly compelling alternatives.

Agree. It's odd.

------
matthewhartmans
I'm still waiting for Apple to update Xcode to not include every single SDK
for iPhone so the updates can reduce to 700mb instead of 6GB.

Xcode should have an SDK download manager so you get to choose which iOS
version you want to install, rather than ship them all in Xcode.

~~~
DagAgren
They ship like one or two? If you want older ones, you need to go to the
download manager to get them.

If you already had them installed, they remain available. You're probably
getting confused by that.

