Sunday, November 8, 2015

OO Hello World - Silver



Hi-yo Silver! Away!

The Hello World in Silver is here! Silver is a free implementation of Apple's Swift programming language being actively developed by RemObjects, the company behind the exceptional language Oxygene.

As mentioned on their website: "Silver is a truly native Swift compiler for the .NET CLR, the Java/Android JVM and the Cocoa runtime. Built on over ten years of solid compiler knowledge and technology, Silver is a truly native Swift compiler for the .NET CLR, the Java/Android JVM and the Cocoa runtime." http://www.elementscompiler.com/elements/silver

By the way, you can see my previous post here: http://carlosqt.blogspot.com/2010/06/oo-hello-world.html where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
class Greet {
 var name: String

 init(name: String) {
        self.name = Char.ToUpper(name.0) + name.Substring(1)
    }

 func salute() {
  println("Hello \(name)!")
 }
}

let g = Greet(name: "world")
g.salute()

Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
import System
class Greet {
 private var name: String

 public init(name: String) {
        self.name = Char.ToUpper(name.0) + name.Substring(1)
    }

 public func salute() {
  println("Hello \(name)!")
 }
}

let g = Greet(name: "world")
g.salute()

The Program Output:









Swift (Silver) Info:
“Swift is a new programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun..” Taken from: https://itunes.apple.com/us/book/swift-programming-language/id881256329?mt=11

Appeared:
2014
Current Version:
Silver 8.2 beta, Swift 2.1 (latest version in "Languages" page
Developed by:
Silver by RemObjects, Swift by Apple Inc.
Creator:
Silver by RemObjects, Swift by Chris Lattner and Apple Inc.
Influenced by:
Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, D 
Predecessor Language

Predecessor Appeared

Predecessor Creator

Runtime Target:
CLR and JVM
Latest Framework Target:
CLR 4.x JDK 8
Mono Target:
No
Allows Unmanaged Code:
Yes
Source Code Extension:
“.swift”
Keywords:
Silver 89, Swift 80
Case Sensitive:
Yes
Free Version Available:
Yes
Open Source:
Swift Yes, Silver No.
Standard:
No
Latest IDE Support:
Visual Studio 2013
Language Reference:
More Info:


No comments:

Post a Comment