Monday, December 14, 2015

HelloWorld in SWIFT

My first program in SWIFT

There's a lot to be excited about this open source project. For the moment this may look like more imbecile version. With time this may be a big player to develop first-class applications for LINUX and Mac alike. Perhaps, APPLE's way of informing developer community that it wants a piece in server side market.

What you'll see in this version of SWIFT?

Glad you asked. This is a minimal version of SWIFT for the moment. Not much to speculate, except for enjoying the beauty of this language. It does not have support for UIKit, nor or there any mention about IDE's. For the moment treat it like building a command line C application. I am sure APPLE will bring in some version of XCode for LINUX or have partnership with leading IDE's like Webstorm/Sublime/Atom for application development. All of which depends on APPLE's direction and thought process.

For this post, I used sublime text  (my choice of editor).

Head on to sublime text or any other editor of your choice. Put in the following code

print("Hello world!!!")

Save your file, name it helloworld.swift

Open terminal
browse to the location helloworld.swift
type in the following command

swift helloworld.swift

If you get any compilation errors, apart from code related issues, do the following

sudo apt-get install clang-3.6
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100

Re-compile your code
swift helloworld.swift

You should not see any errors.

Do ls -l
You'll see 2 files
helloworld.swift
helloworld

One is the code you wrote and the other is compiled version of your code.

Execute helloworld
./helloworld

Output
Hello world!!!

1 comment:

  1. Music helps us in getting refreshed, feeling relaxed and it sometimes gives an energy too.
    As a career option too, there is a wide scope. Many youngsters are looking to build a career in the same field and continuously doing hard work for the same.
    Developers have developed many applications and Apps for the music, with the help of these applications, users can access to music at anytime and anywhere. The best part is that, they are very easy to access. Access requires just a good speed internet, which is a very common thing at present.Google Play Music Customer Support

    ReplyDelete