[HN Gopher] Swift Playgrounds for macOS
       ___________________________________________________________________
        
       Swift Playgrounds for macOS
        
       Author : rock_artist
       Score  : 237 points
       Date   : 2020-02-11 19:19 UTC (3 hours ago)
        
 (HTM) web link (apps.apple.com)
 (TXT) w3m dump (apps.apple.com)
        
       | A4ET8a8uTh0 wrote:
       | 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 wrote:
         | 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.
        
           | [deleted]
        
       | jedieaston wrote:
       | 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?
        
         | nickhalfasleep wrote:
         | The day they provide this, is the day they are clearly
         | signalling the end of macos.
        
           | month13 wrote:
           | Doubtful, there's still a wide difference between MacOS and
           | iPadOS, if anything they've diverged more in recent years.
           | The multitasking workflow on iPadOS is flux, and has
           | complexity issues.
        
           | MR4D wrote:
           | I would argue that a phone, tablet, and computer can all have
           | the same OS, just with different UI.
           | 
           | So the "end of macos" is unlikely in my book.
        
             | dmitriid wrote:
             | The problem is that the "just" is an unsolvable problem.
             | 
             | Your phone and to some extent tablet are limited screen
             | estate with the finger as the primary method of
             | interaction.
             | 
             | Your desktop is nearly unlimited screen estate with high
             | precision input methods (mouse and keyboard).
             | 
             | The "just different UIs" mean "entirely different UIs
             | tailored to specific interactions and completely changing
             | behaviour of an app in all but the simplest cases"
        
               | jdminhbg wrote:
               | All of this is true, but with processing power and disk
               | space increasing, you could envision a world where a
               | phone simply has a copy of a desktop OS that it could
               | boot into for docking, like a Mac with a Windows
               | partition.
               | 
               | I'm sure you could do this with Linux now, it's just such
               | a niche use case nobody has mass produced it.
        
               | MR4D wrote:
               | If MSFT can make Excel run on my iPhone, then I have a
               | lot of hope.
               | 
               | When I can edit a freaking PowerPoint presentation on an
               | iPhone (in a pinch - I wouldn't want to do it all day),
               | then I have to think it's not only possible, but already
               | done.
               | 
               | Email is probably the best example. Every major email app
               | is on multiple platforms, and I'd be very surprised if
               | most of the code is not already the same among platforms
               | _except_ for the UI.
               | 
               | So I'd submit that it is a __solved __problem.
        
               | dizzy3gg wrote:
               | Microsoft seem to be heavily invested in react native
               | (and possibly election?) as their UI layer.
        
               | 1123581321 wrote:
               | I believe you misunderstood. The issue is not whether
               | software can be ported to a touch platform. It is that
               | keyboard/mouse-oriented UI and ergonomics and a touch-
               | oriented UI and ergonomics cannot successfully co-exist.
               | It's not a programming challenge.
        
             | scarface74 wrote:
             | Why?
             | 
             | iOS is still much lighter weight than MacOS, uses less
             | memory, doesn't have swap, optimized for battery use, and
             | optimized more for security than flexibility.
        
             | sharatvir wrote:
             | I'm waiting for the day we can "dock" a phone to a monitor
             | with a mouse/kb & have a full desktop OS experience.
        
               | pjmlp wrote:
               | Like Windows Phone Lumia, or many Windows tablets.
        
               | mark_l_watson wrote:
               | yes! Microsoft and Android products have sort of done
               | this in the past, but didn't do well in the market or the
               | user/dev experience was not great.
        
               | kovek wrote:
               | I want to see pen-on-tablet experience that allows
               | working without a keyboard.
               | 
               | Then, plug tablet to monitor and "type/write" on the
               | tablet.
        
               | MR4D wrote:
               | Current iPhone has the power to do so, and can connect
               | via ApplePlay and bluetooth. So the only holdup is
               | software.
               | 
               | Maybe this year's WWDC will show us something closer to
               | that.
               | 
               | I'm holding out hope for this, since they "added" mouse
               | support to iPadOS in 2019. There has to be a reason for
               | that plus Universal apps, plus SwiftUI, right?
        
               | ianai wrote:
               | Maybe they plan to support it for iPadOS devices and
               | either no support or stripped down for iPhone. It'd be
               | cool if we at one point had desktop power in our pockets
               | though. (Yes I know we do to some extent, but it's still
               | a bit of a stretch for a daily driver.)
        
               | runjake wrote:
               | 1. You mean AirPlay.
               | 
               | 2. You don't need AirPlay, you could drive a monitor and
               | keyboard/mouse directly, using an HDMI/USB dongle. But
               | yes, as you said, software is the hold up. The rest is
               | ready.
        
               | wvenable wrote:
               | Samsung Dex is this. I can dock my phone and get a
               | desktop experience. I have Visual Studio Code running now
               | (though code-server[1]) and Ubuntu userland (via
               | Termux/Andronix). Plus all other Android apps running in
               | detached windows.
               | 
               | It's unfortunately not even as useful as it sounds but it
               | is a start. I'm still at the early stages of setting it
               | up for real work.
               | 
               | [2] https://github.com/cdr/code-server
        
               | ianai wrote:
               | How responsive is it? Would you mind being limited to
               | your Dex without another desktop or laptop to use?
        
         | fmakunbound wrote:
         | WTF would you want that for? I'm pretty sure the iPad is not
         | designed for general purpose computing.
        
         | sillyquiet wrote:
         | Would be good for testing on device I suppose, but ooooh, I am
         | not too sure how pleasurable coding on a touch interface might
         | be, even with physical keyboard. Also, I would hate to de-
         | incentivize one of Apple's remaining motivations for paying
         | attention to their non-mobile hardware!
        
           | novok wrote:
           | Well good news you can use a mouse on the ipad now, along
           | with remaping capslock to esc in ios 13.4, all in a 1.5lbs
           | computer.
        
           | gadabout wrote:
           | I've used Pythonista on my iPad and I adore it. The physical
           | keyboard is a personal must-have, but the experience is great
           | otherwise.
        
         | qubex wrote:
         | The functions that needed to be removed have already been
         | removed. What remains is comes already pre-loaded on your iPad
         | with iOS/iPadOS. It's called 'Notes'.
         | 
         | The functionality removed was file management, version control,
         | compilation, building, and interface design. All the rest (text
         | editing) is still already there.
         | 
         | Ha ha, only serious.
         | 
         | Seriously, I doubt Apple is close to allowing a compiler to run
         | on an iPad.
         | 
         | EDIT: Apparently a sense of humour is not a common attribute
         | around here.
        
           | RandallBrown wrote:
           | They already have the Playgrounds app on the iPad.
        
             | qubex wrote:
             | You're right.
             | 
             | I'm curious to now whether it's compiled; and if so, what
             | the underlying architecture of the compiler and runtime is.
        
               | why_only_15 wrote:
               | It's basically JIT compiled with special entitlements
        
               | mayoff wrote:
               | https://stackoverflow.com/a/40597747/77567
               | 
               | The evidence is that iPad Swift Playgrounds compiles to
               | native code.
        
               | Nextgrid wrote:
               | Presumably the compiler itself was compiled for ARM. The
               | rest doesn't really have to change as the Swift compile
               | was already designed to compile for ARM for production
               | builds of apps.
        
         | lowdose wrote:
         | This is similar to asking Apple if you can summon Alexa instead
         | Siri on iOS. Not going to happen.
        
           | liamcardenas wrote:
           | How is that remotely similar?
        
             | lowdose wrote:
             | Inside the walled garden only Apple plays with the ball.
        
       | jacques_chester wrote:
       | 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.
        
       | polyomino wrote:
       | 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.
        
       | jedberg wrote:
       | 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 wrote:
         | > it's just arrow tiles and jump tiles
         | 
         | The obvious next step for her is Befunge.
        
       | adriansky wrote:
       | 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.
        
         | Grustaf wrote:
         | On the other hand there are quite a few ios devices out
         | there...
        
         | alexgaribay wrote:
         | Swift can be compiled and run on Linux. It's most prevalent on
         | Apple platforms. It's usefulness outside of the Apple platform
         | is a different topic though.
         | 
         | https://swift.org/about/#platform-support
        
           | derefr wrote:
           | I suppose Swift is like a CLR language (e.g. C#) in that
           | sense, then? The language itself will run in many places, but
           | most of the library bindings anyone might care about, or want
           | to use the language to get access to, are for platform-
           | specific libraries.
        
             | oldmanhorton wrote:
             | For what it's worth, C# is very usable on both Linux and
             | macos. Anything outside of UI is pretty much fully cross
             | platform at this point (there are even some cross platform
             | ui attempts, but they're not anywhere near as mature as
             | wpf, xaml, winforms, etc)
        
             | noodlesUK wrote:
             | These days there's been a _lot_ of movement towards cross
             | platform C#, with .NET core etc. Whilst there isn't any
             | desktop application support (other than Xamarin), there's a
             | good ecosystem for ASP.NET.
        
             | gumby wrote:
             | That's true of most languages, like C++, rust, etc.
        
         | xkemp wrote:
         | There's some momentum behind Swift-on-Server, I believe. And
         | Tensorflow Swift seems to be a rather serious project.
        
         | melling wrote:
         | 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
         | 
         | Trying to be more functional with my Swift:
         | 
         | https://github.com/melling/SwiftCookBook/blob/master/functio...
         | 
         | 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
         | 
         | Things I'm doing sitting on my couch with my iPad on the arm
         | and the book in my lap.
        
         | gumby wrote:
         | > The only thing is that it's used only on iOS systems.
         | 
         | It's also used on the macOS, which is kind of the point of this
         | HN posting.
         | 
         | In the magnitude of using a given platform, learning the
         | language is a small part; the APIs and tooling will be a larger
         | effort. If you already know those things for the iOS, the jump
         | to macOS will be less.
        
         | bound008 wrote:
         | You may just want to learn a touch of swift to experience nifty
         | language features such as optionals. (Unless you have worked
         | with languages that have all of swift's nifty features)
        
       | plg wrote:
       | 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?
        
       | inviromentalist wrote:
       | 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 wrote:
         | > 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 wrote:
           | 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 wrote:
             | They could buy a used Macbook.
        
           | rickdg wrote:
           | The web on iOS is deliberately gimped.
        
           | inviromentalist wrote:
           | >It's called a "web application", and you can write them in a
           | variety of languages, including compiled ones
           | 
           | Could you post a link on how to?
           | 
           | This sounds like it would solve my problem
        
       | slashblake wrote:
       | Real missed opportunity not calling this "Swifty Swift"?
        
       | technoplato wrote:
       | 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 wrote:
         | 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.
        
       | gigatexal wrote:
       | Finally! I've been waiting for them to do this.
        
       | donatj wrote:
       | QuartzComposer was the best playground. I really wish they'd give
       | it some love.
        
         | jawngee wrote:
         | 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
         | 
         | Unfortunately, life got in the way of finishing it.
        
           | umjames wrote:
           | 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.
        
       | tempodox wrote:
       | This is nice, to be sure, just too bad it's only for Catalina.
        
         | throwaway55554 wrote:
         | It is _really_ frustrating that Apple does stuff like this.
        
           | gumby wrote:
           | That they develop new products that show off the capability
           | of their new products? It would seem odd to me if they did
           | not.
        
           | dewey wrote:
           | 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 wrote:
             | Catalyst (nee Marzipan) apps first appeared in Mojave.
        
               | azinman2 wrote:
               | Likely didn't have the required apis then for this to
               | run.
        
               | dwaite wrote:
               | Catalyst != Marzipan, not even architecturally.
        
             | throwaway55554 wrote:
             | I stand corrected. I didn't read far enough to know that
             | this was Catalyst.
        
           | [deleted]
        
         | xenonite wrote:
         | I am still on El Capitan so I share your disappointment.
         | However iPadOS can be used for this app as well.
        
         | ihuman wrote:
         | You can still create swift playgrounds in Xcode, but it won't
         | have the coding lessons included in this app.
        
         | tomduncalf wrote:
         | It's built using Catalyst, their technology for running iOS
         | apps on MacOS, which was only launched with Catalina, so
         | there's a good reason for this.
         | 
         | I recently got a new Macbook and was dreading having to use
         | Catalina, having heard horror stories online, but actually my
         | experience has been fine. A few security popups to click
         | through when you first run a new app, but some of the screen
         | shots I saw online of hundreds of them must have been fake,
         | it's really not a problem. Having to right click and open
         | unidentified apps can be annoying, but I'd rather do that and
         | keep Gatekeeper on personally, rather than disabling Gatekeeper
         | entirely.
         | 
         | It actually feels really solid so far (granted its a clean
         | install on a new laptop) and I am really impressed with the
         | Sidecar feature in particular. Of course, if you depend on
         | 32-bit apps or drivers, or certain apps which are meant to be
         | buggy (e.g. Mail referenced in another comment), you may want
         | to hold off for a while!
        
           | bwilliams18 wrote:
           | The reason you didn't see the bevy of popups was because you
           | did a clean install. With an upgrade install all of your
           | existing apps have to go through the same security steps as a
           | new app, and they tend to do it all at once, especially if
           | you have a lot of apps that launch at startup. That said my
           | experience was not as extreme as some of the screenshots, and
           | I think it would be even less for the average user. And of
           | course this is only upon first upgrade, so while frustrating,
           | you quickly get over it.
        
             | wlesieutre wrote:
             | I upgraded last weekend and I think the only new security
             | prompt I had was from Bartender 3, which needed some new
             | "screen recording" permission to see what menuextras you
             | have installed. Had to go into the Security preferences and
             | turn that on manually rather than just having an "OK"
             | button, but it wasn't hard.
             | 
             | Oh, and Terminal had a popup for permission to access
             | ~/Desktop
        
             | tomduncalf wrote:
             | Ahh, that makes sense I guess!
        
         | oarsinsync wrote:
         | Damn! I really enjoyed Swift Playgrounds on the iPad, but found
         | the lack of real keyboard irritating. I was about to download
         | this until I saw your comment.
         | 
         | My email's too important to risk upgrading to Catalina still.
        
           | boardwaalk wrote:
           | I've heard there were data store migration problems and
           | haven't had any myself, but is this even an issue if you're
           | using IMAP? It's all stored on the server anyways. (I can't
           | imagine using POP in this age of multiple devices.)
        
       | haunter wrote:
       | 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
       | 
       | http://web.archive.org/web/20191017085801/http://store.steam...
       | 
       | 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...
       | 
       | I pretty much hate when they abandon things like that
        
         | mattnewton wrote:
         | 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 wrote:
           | 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..
        
         | SlowRobotAhead wrote:
         | It's not really the same as a learning tool, but Google has
         | FlutterPad [0] which is an online playground for Flutter app
         | development.
         | 
         | Which if you've never played with, it's extremely easy to see
         | how Flutter and Dart work. Most online tutorials can be
         | completed right in FlutterPad. So Google does know people want
         | this, just seem to care more about other things right now.
         | 
         | [0] http://flutterpad.com/
        
           | [deleted]
        
       | misiti3780 wrote:
       | Is the get button disabled for anyone else in the mac store?
        
         | mayoff wrote:
         | You are probably not running macOS 10.15 Catalina.
        
           | misiti3780 wrote:
           | nope,thanks.
        
       | skyfaller wrote:
       | 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 wrote:
         | Playgrounds isn't free software, and for that matter isn't even
         | source-available.
        
           | skyfaller wrote:
           | 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 wrote:
             | 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.
        
         | chrisbrandow wrote:
         | How will this limit people using it? Are there institutions
         | that won't allow it? I don't fully understand the complaint.
        
       | zelly wrote:
       | I really wish there were stuff like this for more advanced
       | topics. Where's the gamified "write a compiler" course?
        
         | favorited wrote:
         | There's the nand2tetris course, which isn't exactly gamified,
         | but it's a project-based course where you learn hardware
         | fundamentals and assembly as you build a Tetris clone.
         | 
         | https://www.nand2tetris.org/course
        
         | jedberg wrote:
         | 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?
        
         | [deleted]
        
       | city41 wrote:
       | Some larger screenshots (and more info):
       | https://developer.apple.com/swift-playgrounds/
        
       | dmix wrote:
       | 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.
        
       ___________________________________________________________________
       (page generated 2020-02-11 23:00 UTC)