Live data from Hacker News

Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

elementscompiler.com

81–90 of 109 posts

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#81
post #13

Genuinely curious. Why Swift for multi-platform rather than C#, Clojure, JavaScript, or ?

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.

I understand that Apple built Swift to compile to native code, but I thought the allure of this product was running on the JVM and .NET runtimes.

I guess I should clarify that I get why using Swift for OSX and iOS might make sense. The question is about using it for other platforms.

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#82
post #38

Earlier quoted context omitted.

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.

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.

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

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

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

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#83

Earlier quoted context omitted.

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.

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.

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.

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#84
post #57

Earlier quoted context omitted.

From what I known, Kotlin or Xtend are better options than Scala, regarding execution speed of the current code generation and package size, even with ProGuard.

No, not really.

Any available benchmarks?

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#85
post #61

Earlier quoted context omitted.

When talking about AOT compilation, we generally tend to mean that the compiler produces a binary consisting of machine code at some unspecified time before the user attempts to run the application. In the context of that blog post, there are two compilation steps: First emscripten would be used to produce JS. Then Mozilla's JS engine would compile that JS down to machine code at runtime . They call the latter step w…

The point I was trying to get across is that by cross-compiling from C/C++ with Emscripten, static type information can be used to give native performance, that a program written directly in Javascript wouldn't. It's still AOT in that sense - it's not like JIT where only hot bits of code get converted to native to code, and only then when some heuristics have determined what actual types the code ends up dealing with…

But it isn't AOT in CS speak.

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#86

Earlier quoted context omitted.

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.

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.

This isn't strictly true, if you not the wording around this it is quite cautious, "written with swift". There are only 4 swift objects in the app.

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#87

Earlier quoted context omitted.

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.

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…

> 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/

[1] https://realworldocaml.org/

[2] http://ocsigen.org/

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

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#88
post #27

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.

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…

I don't think I'm doing anything too fancy, but who knows? I probably have too many conversions to Objective-C objects that I used to workaround beta compiler issues that are probably fixed by now, but I haven't found a lot of guidance on what to avoid (I'm declaring types pretty much everywhere) and since the compiler isn't crashing, the list of compiler crashes doesn't really help.

It's a shame because Swift is a neat language. But because Xcode doesn't support incremental compilation for Swift, a single character change causes the entire project to rebuild. Couple that with LLDB crashing because I'm including Objective-C frameworks (via Cocoapods), and the whole experience becomes absolutely terrible.

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#89

Earlier quoted context omitted.

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…

> 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…

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!

Re: Silver: A free implementation of Swift for .NET, Java, Android, and Cocoa

#90
post #13

Genuinely curious. Why Swift for multi-platform rather than C#, Clojure, JavaScript, or ?

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.

> Swift is statically typed, so it doesn't really compete with JS or Clojure.

This seems to imply that developers make a static vs. dynamic choice separately prior to and separate from evaluating other aspects of languages to choose between them. While some developers may do that all the time, and some may do that some of the time, I don't think its true as a generalization.

Certainly Go is statically-typed, and often portrayed as competing fairly directly with Ruby/Python, which are not.

Post reply on HN