Hi, I’m John Petitto, one of IBM’s Swift developers located at IBM’s Mobile Innovation Lab in Austin. We love Swift here and thought you would too so we are making our IBM Swift Sandbox available to developers on developerWorks.

The IBM Swift Sandbox is an interactive website that lets you write Swift code and execute it in a server environment – on top of Linux! Each sandbox runs on IBM Cloud in a Docker container. In addition, both the latest versions of Swift and its standard library are available for you to use.

IBM Swift Sandbox

We know you’re as excited as we are to start using this tool, so please bear with us during the initial launch of the sandbox. With that in mind, let’s get started!

Hello Swift!

To begin, let’s write a simple Swift program together. In the left window labeled source code, enter the following line of code:

print("Hello Swift!")

New to Swift? Check out the official language guide.

Hit the blue run button located at the top to execute the program. If everything was entered correctly, “Hello Swift!” should appear under output in the results window.

If we edit the previous example and omit the closing parenthesis at the end of the line, an error should get flagged by the editor. Hover over the red marker that appears next to the line number to examine the error message. Error messages are also listed in the output.

Screen Shot 2015-12-01 at 4.59.52 PM

Swift Meets Linux

We’ve provided a collection of sample programs for you to experiment with. Click Source Samples in the upper left corner to see the list of available sample programs. For instance, select filestat.swift and run the program. The output generated should be similar to what’s seen below:

/bin/bash is 1037464 bytes

If we try changing the value of filename on line 12 from “/bin/bash” to “/tmp”, we should see a different number of bytes printed.

You may have noticed that this program is calling stat from glibc (The GNU C Library). Since the sandbox runs on top of Linux, we can write Swift code that interacts directly with the system. Take a look at some of the other samples for more examples of using glibc.

What’s Next

With the movement of Swift to open source, we’re opening the doors on what we are working on at IBM with Swift. The IBM Swift Sandbox barely scratches the surface of what’s possible. To stay up to date with the open source efforts around Swift, head on over to Swift @ IBM.

18 Comments on "Introducing the IBM Swift Sandbox"

  1. […] has today unveiled their first public effort towards Swift, with the introduction of the IBM Swift Sandbox website. You can type lines of Swift code into the text editor on the left and then run the code on a […]

  2. […] Big Blue expelled a IBM Swift Sandbox that runs your Swift code on a Linux server regulating a Docker container. […]

  3. Daniel Bromberg March 13, 2016

    This is very awesome and great for my students. Thank you. Especially since swiftstub.com no longer works.

  4. I want to know brief about why swift?

    • We believe that Swift matches a lot of paradigms that JavaScript and Java programmers use, and you can mix the functional and object oriented paradigms with compiled code with robust type systems.

  5. […] cloud investments, but IBM is working on less orthodox cloud initiatives, too. In December, it introduced a SaaS offering for developers to build and test applications using Swift, a programming language […]

  6. Kandice Burdine May 09, 2016

    Very good write-up. I certainly appreciate this website. Thanks!

  7. Name *Peter Parsonage May 15, 2016

    Thank you for your article.
    I look forward to using SWIFT and learning more about it.
    Cheers – Pete
    New Zealand

  8. Suraj Pawar May 23, 2016

    Hi John,
    I used your sandbox for swift it’s nice.

  9. Any chance to have it as a local tool (not online)?
    Maybe running in a local web server.


  10. Great tool !, I’ve been using it to learn Swift….Thanks !

  11. Doug Ninomiya February 20, 2017

    Thank you IBM! Now I can use my iPhone to learn Swift. 🎉

Join The Discussion

Your email address will not be published. Required fields are marked *