
Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa - milen
http://elementscompiler.com/elements/silver/
======
martingordon
I'm curious to know how well it performs. I spent the better part of this
weekend rewriting 4k lines of Swift in Objective-C because I couldn't deal
with the 60-90 second compile times.

~~~
mythz
Swift has some land mine issues where the compiler can hit snags handling
certain snippets of code (e.g casting to/from Any/AnyObject, method
overloading based on constraints, etc) which if you have enough of them will
segfault the compiler with something along the lines of "expression too
complicated, break it down".

I've had to rewrite my approach a few times because of this to avoid certain
coding techniques, but once I've rewritten to avoid them, Swift can happily
compile my 7-8k LOC code-base in ~6s.

~~~
epaga
Is there a list somewhere of Swift compiler issues to avoid? Seems like
"avoiding certain coding techniques" is what is currently necessary until
Apple gets back on top of things...

One other example FWIW: having a largish array of Int arrays causes the
compiler to either go into an endless loop or simply take too long, UNLESS the
type of the array is specified.

var data = [[1,2,3],[4,5,6], ... ] // > 20 elements -> compiler hangs

as opposed to:

var data:[[Int]] = [[1,2,3],[4,5,6], ... ] // compiles quickly

~~~
mythz
Finding Swift really buggy atm - where XCode, Swift Compiler and SourceCode
service routinely crashes multiple times a day for me. A lot of my time is
spent sympathizing with the compiler and getting hit with hard fought lessons
on what things to avoid - basically don't step too far outside the Swift
Programming Guide. Apple's also glacially slow at responding to bug reports -
I'm keenly waiting on the next Q/A release of XCode/Swift.

There's a whole repo dedicated to Swift compiler crashes being maintained at:
[https://github.com/practicalswift/swift-compiler-
crashes](https://github.com/practicalswift/swift-compiler-crashes)

~~~
00098001918291
If only this had been a language that was dogfooded to the rest of the
company, we might not be dealing with these beta-like issues.

~~~
interpol_p
I think it was - the first app written in Swift was Apple's WWDC app. Released
before they announced Swift. Though it wasn't a hugely complex app.

~~~
brudgers
Dogfooding usually implies that the technology is used in mainline business
operations. It needs to be more than building a demo, it needs to provide
sustenance.

------
mukundmr
Reading through the details dampened my excitement. It has proprietary
extensions to the Swift language
([http://docs.elementscompiler.com/Silver/LanguageExtensions/](http://docs.elementscompiler.com/Silver/LanguageExtensions/))
and it has differences and limitations as well.
([http://docs.elementscompiler.com/Silver/DifferencesAndLimita...](http://docs.elementscompiler.com/Silver/DifferencesAndLimitations/)).

They do however state it is free for use.

~~~
failed_ideas
I don't have time to look, but when I signed up, I was given the option for a
free trial and the option to spend $500+ depending on the package. I'll have
to look closer, but I suspect this is xaraminesque.

~~~
ckok
The Swift part of it is free. The C# and Oxygene parts cost, which aren't
needed to develop in Swift.

------
capitalsigma
Looks pretty shady. Proprietary code through-and-through, and it's "cross
platform" because it compiles down to their own proprietary language. It's
unclear how you deal with native libraries, if at all.

I'll pass, thanks.

~~~
csharperer
Not only that, but good luck keeping up with Apple's developments once they
start buckling down and updating the language.

~~~
dwarfland
We have a long history of doing more than "keeping up" ;)

------
spiralganglion
Cool! But, is it possible that this violates Apple's TOS or any legal
limitation on use of the Swift language? I remember there being a lot of
heated discussion about making Swift officially open source back when it was
announced, but I don't recall ever hearing anyone suggest a community project
to make an OSS compiler for it. This is most interesting, but I'd love to know
that Apple would be okay with this, or would have no recourse to shut it down,
prior to putting in the time to pick it up.

~~~
djur
Programming languages cannot be copyrighted. It doesn't look like they've
reimplemented any Apple APIs, so there wouldn't appear to be any room for an
Oracle-style lawsuit claiming that standard library code was copied.

I don't know what the trademark situation might be, though.

~~~
mehrdada
> Programming languages cannot be copyrighted

Are you sure? I'm genuinely curious to see a reference/precedent. Also, does
that restrict patentability of programming language features? (I personally
can see PLs not being copyrightable, but being patentable.)

~~~
djur
For Europe, there's
[http://en.wikipedia.org/wiki/SAS_Institute_Inc_v_World_Progr...](http://en.wikipedia.org/wiki/SAS_Institute_Inc_v_World_Programming_Ltd).

There's not really any case law I'm aware of in the US, mostly because
nobody's ever tried. Copyright doesn't cover "facts, ideas, systems, or
methods of operation". You can trademark the name of a language, and its
documentation and any distributed software are under copyright, but the
process required to translate that language into machine code isn't eligible
for copyright.

Parts of the implementation might be patentable, but I don't know of any cases
of anyone successfully patenting a programming language.

The Oracle vs. Google lawsuit is still going back and forth in the courts.
It's worth noting that even Oracle isn't claiming that the parts of Android
that involve parsing and compiling Java code are infringing on their
copyright. The matter of controversy is that they claim copyright on the
design of the Java standard library.

Swift's standard library is pretty much Cocoa, which isn't being rewritten
here.

------
sergiotapia
They should make it 100% free for students. Once they graduate and enter the
workforce they will recommend this tool to employers.

~~~
dantle
I believe it's free for everyone.

> RemObjects Silver is absolutely free of charge to use, both during the
> current beta period, and once we release the shipping version.

~~~
azakai
Silver itself might be free, but I think only if you bought the compiler
already,

[http://elementscompiler.com/elements/pricing.aspx](http://elementscompiler.com/elements/pricing.aspx)

~~~
aikah
> Silver itself might be free, but I think only if you bought the compiler
> already,

so it isn't free software at all.

~~~
dwarfland
We make three compilers. Oxygene, C# and Swift. The Swift compiler is/will be
completely free use for everybody — no purchase required.

------
brudgers
Genuinely curious.

Why Swift for multi-platform rather than C#, Clojure, JavaScript, or <insert
other language here>?

~~~
djur
Swift is statically typed, so it doesn't really compete with JS or Clojure.
The company already has a C# implementation for sale.

Also, Swift was designed to compile to native code, unlike any of the other
three languages.

~~~
pjmlp
.NET has NGEN since 1.0.

~~~
djur
Sorry, I was imprecise.

Swift was designed for the iOS platform as a replacement for Apple's dialect
of Objective C. This is an unmanaged environment. There's no VM or garbage
collection, although both languages support automatic reference counting.

C# was designed for the CLR and has a large standard library that relies on
garbage collection. It also has features permitting calls into unmanaged code,
but the language was still designed for a VM.

~~~
pjmlp
Except there isn't any VM when the code is AOT compiled to native code with
NGEN, MDIL in Windows Phone 8, .NET Native, or in iOS.

The presence of garbage collection has nothing to do with being native or not.

Besides a language runtime and VM aren't the same thing.

Actually Swift makes use of Objective-C runtime to achieve interoperability
with Objective-C libraries.

Oberon, Oberon-2, Modula-3, Component Pascal, D, Spec#, Dafny are all examples
of languages that compile to native code, were used to write operating systems
and use garbage collection.

------
throwaway1xx2
Anyone interested in building open source parser API for Swift? Join me here

[http://compilerjobs.com/db/jobs_view.php?editid1=984](http://compilerjobs.com/db/jobs_view.php?editid1=984)

If parser API succeeds, we will also target making a compiler.

~~~
csharperer
What are the legalities?

~~~
throwaway1xx2
Swift is just a language specification. It cannot be patented or copyright-ed.
Anyone is free to make tools around the language specification. Just like
there are many compilers for C/C++ on different platforms, we intend to make
one for Swift on Linux/Windows.

------
mikeash
The fact that arrays and dictionaries are classes rather than structs is a
major problem with this. That's a massive semantic difference between their
implementation and Apple's, and it's one that won't show up as a compile-time
error. Taking code written for Apple's implementation and using it on Silver
is likely to result in a nightmare of crazy debugging trying to track down all
the cases where you're now sharing arrays/dictionaries rather than copying
them. This really needs to be fixed, and if it's truly impossible, IMO it's
bad enough that the thing should be scrapped.

------
lukeh
This looks interesting, although adding language extensions makes me a bit
nervous. What's the ABI compatibility story when targeting Cocoa? Can I mix
and match with native Swift classes? Is the native Swift runtime used?

~~~
ckok
The language extensions are there to support concepts that don't exist in
Swift, for example await and exception handling are pretty much a requirement
when targetting .NET and Java/Android.

It's ABI compatible with Cocoa, all classes end up usable from Cocoa.

It does not use the swift runtime.

------
Void_
I just want to write web apps in Swift. Any news on that front?

~~~
girvo
So much this. It'd be an excellent alternative to Go, with it's nice type
system and pretty advanced PL features: I'd love to write web services in
Swift, but that's contingent on being able to deploy it to Linux et al.

~~~
LeonidasXIV
Maybe you should check out OCaml then. It can be deployed to Linux/Windows/Mac
OS X without problems, ARM devices. Offers native compilation and can even be
compiled to JavaScript. The compiler is fast and freely available.

The type systems is even better and more advanced. Coming from Swift I was
kinda surprised that its pattern matching was a statement and not an
expression, as typical functional languages do.

~~~
eatonphil
The state of OCaml documentation is not great... I have had such a pain
finding documentation. Generally, the only source for it is the French
university that created/promotes it [0]. But even their pages are often almost
a decade old and I have frequently found errors in the documentation.

Overall, while OCaml is a truly beautiful language (and I do really enjoy
writing in it[1]), it is really tough to get work done efficiently because so
few resources seem to exist.

With that said, I discovered a mod_ocaml Apache module implementation[2] (that
is really outdated and not very efficient) and moved it to github. (I am not
the author, nor have I had time to work on it either.) But if there was any
interest in reviving this, I'd certainly give it a go. This seems to be a
potentially viable way to increase interest in server-side OCaml usage.

[0]
[http://caml.inria.fr/resources/doc/index.en.html](http://caml.inria.fr/resources/doc/index.en.html)

[1] [https://github.com/eatonphil/owebl](https://github.com/eatonphil/owebl)

[2]
[https://github.com/eatonphil/mod_ocaml](https://github.com/eatonphil/mod_ocaml)

~~~
LeonidasXIV
> The state of OCaml documentation is not great... I have had such a pain
> finding documentation. Generally, the only source for it is the French
> university that created/promotes it.

That might have been true 5 years ago, but the OCaml Community site [0] is
rather easy to find and links to many tutorials and books. Among these is the
excellent Real World OCaml [1] book which is pretty great for experienced
developers switching languages and available in print and freely online. Other
resources for more beginning programmers exist as well. The INRIA resources
are, indeed, rather poor and except fro the language reference, rather
outdated.

Directly programming for Apache hasn't been popular for years now in any
language I know (actually, only mod_php is popular, if at all, mod_python is
completely dead and no idea about mod_perl). Usually languages have their own
servers that get reverse-proxied by a frontend server like Apache or Nginx.
And for this purpose Ocsigen [2] has been available (allowing an front-and-
backend OCaml approach). If something simpler is desired, CoHTTP [3] exists,
which is both a HTTP client and server. Reviving mod_ocaml is, in my opinion a
waste of time and effort.

[0] [http://ocaml.org/](http://ocaml.org/)

[1] [https://realworldocaml.org/](https://realworldocaml.org/)

[2] [http://ocsigen.org/](http://ocsigen.org/)

[3] [https://github.com/mirage/ocaml-cohttp](https://github.com/mirage/ocaml-
cohttp)

~~~
eatonphil
Great points. I was being too vague. My biggest gripe was that I could only
learn more of the syntax from the INRIA documentation. The books and OCaml
websites definitely covered a lot of general programming recipes and more
common paradigms. Ultimately since there were still so few examples I always
ended up having to look at the actual language reference for useful
information. As we're aware though, it is outdated. In particular, I found
really getting a handle on object-oriented OCaml was tough. Probably just
because other aspects of OCaml could be guessed/inferred from SML/*ML
documentation.

My comments on mod_ocaml were also a little vague. When I began server-side
programming I loved mod_php because of how simple it was. I only brought up
mod_ocaml because (if it worked) it is probably the single easiest way to
start writing ocaml web pages. Given, it is absolutely not performant
whatsoever. I just kinda saw it as a gateway from hobbyist-level interest.

Thanks for all your resources though!

------
niutech
So does it mean I can finally develop apps in Swift language on Windows? Very
cool!

------
mintplant
I hope this doesn't come across as rude, but I can't tell from the site: will
this be "free" as in open source or "free" as in freeware?

~~~
djur
This appears to be another language frontend for their existing proprietary
compiler.

------
WhitneyLand
"Anyways" is not standard, might want to change that on the landing page.

I would have just pinged privately but I don't see any contact link on the
page.

------
orik
Why not create a Swift Compiler and Toolchain for LLVM?

~~~
azakai
Actually it's possible this compiler uses LLVM under the hood - many compilers
do these days.

This particular one appears to not be open source, though.

------
nsxwolf
So, is the Java version now a JVM language, like Scala and Groovy? Can I use
it in IntelliJ or do I have to use this IDE they made?

~~~
vorg
> is the Java version now a JVM language, like Scala and Groovy

I guess so, ditto with .net and android -- that's what happens when a
programming language creator, here Apple, specs out a language at the same
time they implement it. Could be why Swift is getting many implementations
whereas a language only paying lip service to the idea of a spec, say Groovy
after Dec 1995, is still stuck on one impl.

------
seivan
Make a cross plattform game framework to this - as good as SpriteKit and I'm
set. :)

Otherwise I have to go with HaXe

~~~
register
Actually I am really of the opposite opinion! Since I am not interested in
developing games but rather in cross-platform support I think that Silver is
what Haxe should have been!

~~~
seivan
We're not of the opposite opinion then ;-) I think Silver is also what HaXe
should have been!

------
jimmcslim
These folks started out with a product to integrate Delphi with .Net.

------
anonbanker
A closed-source compiler? In 2015?

~~~
dwarfland
People who want to make a living writing software? in 2015? I know, the idea
seems quaint.

------
solomatov
It's not open source.

------
pistle
Apple needs to buy this company in 3, 2, 1... This is an ideal start to
countering the concepts from Xamarin out of the .net camp and I would love to
see them build up some form of XAML-like UI tech and tooling for x-plat UI dev
so you could push the envelope on code-reuse. That would take a big dump of
capital.

It would also make for a push in the market for this style of x-plat dev. If
you can get to the major and minor platforms with one code-base and a single-
stack dev team, oh what a smooth world it could be.

Windows 10 on all devices, written in Swift to a universal in visual studio.
Wonder if I'd get to see a macbook running windows with a dev writing swift in
VS.

~~~
eridius
What possible reason would Apple have to buy this company?

~~~
p0nce
Indeed, Swift is their way to keep developers building non-portable apps.

