3 ms·
Swift Playgrounds is essentially an interactive Swift REPL that ALSO ships with some prebuilt learning material, some of which is "fancy logo".
by madeofpalk 7y ago
Swift 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.)