20 ms·
Swift Playgrounds for macOS
- adriansky 7y agoLooks 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.
- alexgaribay 7y agoSwift 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 https://swift.org/about/#platform-support
- derefr 7y agoI 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 7y agoFor 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 7y agoThese 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 7y agoThat's true of most languages, like C++, rust, etc.
- gumby 7y ago> 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 7y agoYou 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)
- xkemp 7y agoThere's some momentum behind Swift-on-Server, I believe. And Tensorflow Swift seems to be a rather serious project.
- melling 7y agoThe 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/functional.md 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 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.
- odysseus 7y agoDoes the app sync between different macOS computers though? My experience has been: no. Both computers are signed into the same Apple ID ...
- melling 7y agoIt’s using iCloud. Basically, they work in the same directory. Before I had to copy and paste into Xcode Playgrounds.
- odysseus 7y agoThanks. So, for this to work, I have to enable iCloud Drive on both machines? Looks like it takes quite a long time to upload 375MB playground files to iCloud too.
- jayrhynas 7y agoQuick note about your functional examples - there's already a built-in version of `take` called `prefix` available on all Sequence types.
- melling 7y agoThanks. There’s also a prefix(while:) that appears to be takeWhile(), which I also needed. https://developer.apple.com/documentation/swift/sequence/3128810-prefix https://developer.apple.com/documentation/swift/sequence/312...
- Grustaf 7y agoOn the other hand there are quite a few ios devices out there...
- secretsatan 7y agoMore than a few, it's quite ridiculous so many devs are sniffy about it. If you can handle cpp, you can handle swift, one of my biggest gripes right now is having to deal with a cross platform cpp solution that just seems to throw out 10 years of progress so they can implement code like they're used too and reimplement built in solutions slower and harder to work with.
- technoplato 7y agoI’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 7y agoThese 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 7y agoFinally! I’ve been waiting for them to do this.
- donatj 7y agoQuartzComposer was the best playground. I really wish they'd give it some love.
- jawngee 7y agoReally, 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 7y agoI 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 7y agoThis is nice, to be sure, just too bad it's only for Catalina.
- oarsinsync 7y agoDamn! 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 7y agoI'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.)
- oarsinsync 7y agoYep, definitely an issue with IMAP mailboxes. It's not a storm-in-a-teacup-because-it's-Apple situation, it's an Apple-really-done-fucked-up situation. https://tidbits.com/2019/10/11/beware-mail-data-loss-in-catalina/ https://tidbits.com/2019/10/11/beware-mail-data-loss-in-cata...
- throwaway55554 7y agoIt is really frustrating that Apple does stuff like this.
- dewey 7y agoBeing 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 7y agoCatalyst (née Marzipan) apps first appeared in Mojave.
- haunter 7y agoOfc 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.steampowered.com/app/929860 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/builds https://github.com/googlearchive/gamebuilder/tree/master/bui... I pretty much hate when they abandon things like that
- blondin 7y agothey are conceptually different things. i started exploring swift a few weeks ago and these playgrounds are quite handy. for python programmers: it's like a jupyter notebook but with outputs on the right & auto evaluation. it's a generic instant feedback tool for swift but deeply integrated with xcode. i think, what apple did here is simply decoupling it from xcode. this is huge because swift is quite powerful and a complex language already. i am curious what direction they take this.
- mattnewton 7y agoAs 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 7y agoIt 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..
- zelly 7y agoI really wish there were stuff like this for more advanced topics. Where's the gamified "write a compiler" course?
- jedberg 7y agohttp://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?
- favorited 7y agoThere'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 https://www.nand2tetris.org/course
- deleted 7y ago[deleted]
- jedberg 7y agoMy 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 7y ago> it's just arrow tiles and jump tiles The obvious next step for her is Befunge.
- city41 7y agoSome larger screenshots (and more info): https://developer.apple.com/swift-playgrounds/ https://developer.apple.com/swift-playgrounds/
- slashblake 7y agoReal missed opportunity not calling this "Swifty Swift"?
- skyfaller 7y agoHas 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 7y agoPlaygrounds isn't free software, and for that matter isn't even source-available.
- skyfaller 7y agoThat'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 7y agoI 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 7y agoHow will this limit people using it? Are there institutions that won’t allow it? I don’t fully understand the complaint.
- jedieaston 7y agoNow, 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?
- sillyquiet 7y agoWould 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 7y agoWell 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.
- modwest 7y agoOh shit I didn’t know about remapping. My iPad Pro is my main personal computer now but I’m constantly toggling capslock. Next up, assignable hotkeys for switching between apps??
- deleted 7y ago[deleted]
- sneak 7y agoI’m most excited about remapping the “globe” (switch keyboards) key which I always hit when I mean to hit Control.
- mark_l_watson 7y agoI have got used to control-[ for escape on the iPad Pro keyboard. I use Prompt for SSH (I am used to it, should probably try other options) and I find opening Emacs and using control-x 3 to split the screen vertically works well. I then esc-shell in one window and edit in the other, or just have two files open for editing. If you have a high resolution USB-C interfaced monitor, plugging in the iPad Pro works fine also, but is I am in my home office I just use my laptop. A big external monitor is great though for watching HBO Now, Netflicks, and Prime.
- inviromentalist 7y agoAny 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 7y ago> 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 7y agoFWIW I would expect the OP's real objection is having to buy a Mac to develop iOS apps, not the annual fee.
- hombre_fatal 7y agoThey could buy a used Macbook.
- inviromentalist 7y ago>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
- rickdg 7y agoThe web on iOS is deliberately gimped.
- 7y ago
- misiti3780 7y agoIs the get button disabled for anyone else in the mac store?
- mayoff 7y agoYou are probably not running macOS 10.15 Catalina.
- misiti3780 7y agonope,thanks.
- A4ET8a8uTh0 7y agoI 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 7y agoThey'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 7y ago[deleted]
- mark_l_watson 7y agoYou might change your mind about the Apple Watch, especially with a data plan so you don’t have to carry your iPhone when going out and about. Your wife will need AirPods to squeeze all the functionality out of her new Apple Watch; required for playing music, pod casts, audio books, and more pleasant phone conversations using the watch. My wife and I have a ton of Apple gear and we agree that the Apple Watch is a game changing product. It is so convenient for a lot of supported things to not have to get your iPhone.
- plg 7y agoHonest 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 7y agoSwift Playgrounds is essentially an interactive Swift REPL that ALSO ships with some prebuilt learning material, some of which is "fancy logo".
- hhas01 7y agoSwift 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.)
- hhas01 7y agoLogo’s a Lisp. Swift’s an Algol. The latter are much more complex, and also much less expressive and customizable; alas, thanks to C they’re also firmly entrenched as the status quo. Logo emphasises compositional thinking; Swift Playgrounds algorithmic hoop-jumping. Ironically, Apple did do a Lisp[-in-Algol-clothing] back in the 90s—Dylan—but abandoned it when NeXT took over. Shame. Closest thing since then was the “Objective” part in Objective-C, but that was always a bit smoke-n-mirrors (since it’s still C at the bottom) and is slowing going away now in any case. I do not think Swift is a good K12 teaching language (it’s a nicer C++, roughly on-par with Java in complexity), but Apple’s goal here is to create lots of new (and preferably locked-in) iApp developers, not raise talented independent CS students†, so that’s not a problem for them. Real-world Swift App development also gets varying degrees of ugly/tedious/painful when dealing with BSD/Foundation/AppKit/UIKit idioms and APIs due to the impedance mismatch between Swift and Obj-C worlds, so the sooner it has its own native APIs for everything the better. I don’t think SP can really prepare anyone for that tangled mess, though if/when SwiftUI is fully ready for primetime I can see SP boosting that. (Whether SwiftUI itself is particularly good remains to be seen.) -- († Mind, most K12 and college “computing science” courses nowadays are really “software engineering” and not really CS either; and even SE can be a stretch considering how much software today is garbage.)
- dmix 7y agoIs 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.
- Jtsummers 7y agoThe main thing is exposure + motivation. I learned to program about age 8 (not well, mind you, but that's when I started) with BASIC. We had a Tandy 1000 at home, and math textbooks had BASIC listings at the end of sections/chapters at the time (late 80s, early 90s). I was motivated to try the things out, my dad provided me access to the computer (showed me how to get to the command prompt, launch BASIC, open, save, and edit files, and run programs). He didn't do much beyond that (he hadn't programmed in 10 years or more, in college), but giving me access was the critical element. If she's not interested in the motivating examples, like I was with the math-based examples, then she likely won't stay interested or engaged. So find something that she's interested in and can write her own programs (or program extensions) for. It could be more game-like stuff (controlling a character or bot on screen and having it do something), simulations, drawing (think Logo's Turtle Graphics or fractals), or something more physical (arduino + LEDs or servos controlling something). And don't pressure her. Once she has access, and knows she can ask for help, if she's interested she'll pursue it. If she shows some interest but has little self-motivation, maybe keep providing little widgets or gizmos or games and inviting her to help out, but only occasionally.
- GordonS 7y ago> 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 7y agoSome kids like puzzles more than others. Programming is like solving a puzzle.
- jacques_chester 7y agoApple 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 7y agoNo. This is just a macOS port of an app that has been on iOS for years now.
- polyomino 7y agoAnimations 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.
- elpakal 7y agoyea but is it written in Swift is what i wanna know
- favorited 7y agoIf 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.
- matthewhartmans 7y agoI'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 7y agoThey 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.
- elevenoh 7y agoAnyone 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.
- Macha 7y agoJavascript (and probably by extension Typescript) are too dynamic to really compile down to machine code while still retaining all features. The best you could do would be something Cythonish where every second line gets converted to a call to PyObject_blah. It's not clear that that would actually perform better than a modern JIT engine In which case you've just invented a less portable way of doing electron type apps.
- s_y_n_t_a_x 7y agoThere's AssemblyScript (a strict subset of TS that compiles to WASM)
- hombre_fatal 7y agoSwift 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 7y ago>we're stuck with old-school overly-OOP abstractions on mobile without any truly compelling alternatives. Agree. It's odd.
- Angostura 7y agoYuck - needs 10.15
- mime3329 7y agoWasn't it released in 2016 ? Why is it top of hacker news today?
- jayrhynas 7y agoThey recently released it on macOS (via a Catalyst port of the iPad app)
- mime3329 7y agoAll 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.