8 ms·
Swift vs. Go
- jorgecastillo 11y ago>I hope they take a look at Swift as it matures in the next few years. Maybe when binary packages are available for non Ubuntu Linuxes?
- lovelettr 11y agoI think that is a valid concern. It is something that is being worked on [1] by the community. When those things get reasonably stable I think then it will be time to get those packages accepted by their respective distros. Though as pointed out in SR-116 without ABI stability (which will not appear until Swift 3) packages do not necessarily provide a silver bullet of portability. I for one have been maintaining a PKGBUILD script for Arch Linux that allows for a native package to be created. It's currently not working due to some issues with binutils [2]. [1] https://bugs.swift.org/browse/SR-116 https://bugs.swift.org/browse/SR-116 [2] https://bugs.swift.org/browse/SR-1023 https://bugs.swift.org/browse/SR-1023
- ebbv 11y agoI'm sure this is in progress, but yes it's a definite roadblock. Maybe I should help on getting it onto RHEL/CentOS since that's what I usually use for servers and I really like Swift.
- sdegutis 11y agoOff topic rant about Svbtle: While browsing the article, I hovered my mouse over something, which told me to hold still, and then suddenly it gave the article an irreversible upvote, which I certainly never intended to give. Now that poor author thinks another person liked the article. Who knows, maybe all previous 12 upvotes were the same situation? Can we go back to Web 1.0 please? Everything was simple, everything worked, everything was fast. Or at least can we compromise and have a few reasonable design choices from Web 2.0 and Web 3.0 merged back in with Web 1.0, and just go with that? The current Web is just too broken, but there's nowhere to file a bug report.
- dpark 11y agoDCurtis undoubtedly thinks this is extremely clever. There was criticism over this the instance Svbtle was announced, but it's persisted. https://news.ycombinator.com/item?id=3742654 https://news.ycombinator.com/item?id=3742654 I believe if you hover over it again it reverses the behavior, but I'm not certain. Regardless, it's not a good interaction paradigm. Edit: It's not reversible. I thought I'd managed to undo one before, but I guess not.
- ebbv 11y agoWeb 1.0 had lots of badly designed UX as well. Just because something's bad doesn't mean it's because of "Web 3.0". People are always going to make bad UX regardless of the paradigm they're working in.
- meddlepal 11y agoI just want simple text, plain backgrounds and links. I'm tired of web designers and there clever snowflake styling and javascript.
- ebbv 11y agoWell the reality is that's never going to happen. The web isn't going to go backwards any more than cars are going to go backwards (however much I'd like that). So the best you can do is strip away the stuff you don't like: http://lynx.browser.org http://lynx.browser.org
- stcredzero 11y agoActually, we should encourage programmer hubris. We need something to be the moral equivalent of "shovelware" so the next batch of startups can be a "breath of fresh air" by getting rid of it.
- talles 11y agoMaybe triggering an action just by hovering was a bad idea (what about who's on mobile by the way?), but don't you think that you're overreacting a bit?
- halosghost 11y ago> inferred strong static typing “strong” compared to what? Go's duck-typing actually makes it weaker than a lot more type systems than you might expect, and compared to something like Haskell or Rust, both of these type systems are incredibly weak. If you're comparing to C, then sure, but “strong” and “weak” typing mean nothing without reference to another language.
- stcredzero 11y agoGo's duck-typing actually makes it weaker than a lot of type systems you might expect For me, it's strong enough and very versatile. It's stronger than what you effectively get in, say, Smalltalk. (Which, technically is strongly typed, having only 1 type of Object.) Having Interfaces explicitly documented in 1 place, but usable through duck typing is genius language design, in my view.
- halosghost 11y ago“Strong enough for what I want” is fine. But the author's point is unclear. Strong compared to what? Did the author mean “strong compared to Smalltalk”? Did the author mean “Go and Swift are Equally Strong”? “Strong” and “Weak” don't mean anything in discussions of typing without a reference-point.
- catnaroek 11y ago“Strong” vs. “weak” doesn't mean anything at all. Let's stick to distinctions that actually make sense: (0) Statically typed [e.g., Java] vs. not statically typed [e.g., Python]. (1) Dynamically typed [e.g., Java] vs. not dynamically typed [e.g., Haskell]. Yes, Java is both statically and dynamically typed. (2) Safe for arbitrary resources [e.g., Rust] vs. only memory-safe [e.g., Python] vs. totally unsafe [e.g., Objective-C]. (3) Typeful [e.g., Haskell] vs. not typeful [e.g., Objective-C]. (4) Global [e.g., Standard ML] vs. local [e.g., Scala] vs. no type inference at all [e.g., Java]. (5) Reflective [e.g., Common Lisp] vs. not reflective [e.g. Rust]. (6) Fixed [e.g., Standard ML] vs. extensible on top of a fixed core [e.g., C++] vs. extensible and modifiable [e.g., Common Lisp].
- r0fls 11y agoIs Swift a general purpose language? I thought it was for iOS and Mac development. I understand it is open source, but so is C#, and I don't see a lot of people using that outside of Windows (I could be wrong though).
- supster 11y agoIt definitely started off for only iOS & Mac. But I believe the larger aim is to have it be general purpose. For example they have binaries for Ubuntu Linux (this will likely encourage server side development).
- mikeash 11y agoI think C# is pretty a pretty common cross-platform language for games due to Unity's support for it. It's not common for other apps, though. I don't think there's much cross-platform work being done in Swift yet. Give it a little time, though, it's only been open sourced for a few months. One nice thing about it compared to many other languages is that it can use C APIs with almost no work. There's no need to screw around with annoying FFI systems, you just point the compiler at your C headers and the calls become available in Swift. They may not be very idiomatic Swift, but they're at least no more difficult to use in Swift than they are in C. That means that you don't necessarily need a bunch of Swift libraries to be built before you can start getting stuff done.
- mcphage 11y agoC# is the native language for the Unity game engine, which is very cross-platform. Now you can use several languages, but I think originally it was C# only.
- JonathonW 11y agoIf you're looking for stable code with an actual complete, working standard library, it's restricted to iOS and Mac development right now. Support for other platforms is an area of active development right now, though. The language itself is pretty much already there (for Linux, at least), with an official release for Ubuntu (and it's buildable on other distros), but the supporting frameworks around it are still a work in progress.
- pkaler 11y agoThe list doesn't mention optionals in Swift. Optionals are a substitute for nil/NULL and handle the absence of a value in a type-safe manner. It is similar to the Maybe type in Haskell. (BTW, if you're interested in Swift, I send a weekly newsletter at http://swiftnews.co http://swiftnews.co)
- deleted 11y ago[deleted]
- supster 11y agoGood catch, I added it to the list
- catnaroek 11y agoOptionals aren't a “functional concept”, whatever that means. They're just another data type, like tuples, lists, trees, etc.
- whitegrape 11y agoIt should be implied by generics. But it looks like Swift has some special sugar for it, neat.
- melling 11y agoI also maintain a collection of list resources. I have daily and weekly views as well, as the ability to search: http://www.h4labs.com/dev/ios/swift.html?week=0 http://www.h4labs.com/dev/ios/swift.html?week=0 http://www.h4labs.com/dev/ios/swift.html?date=0 http://www.h4labs.com/dev/ios/swift.html?date=0 http://www.h4labs.com/dev/ios/swift.html http://www.h4labs.com/dev/ios/swift.html My server is written in Go and runs on AppEngine. I like both Swift and Go. It's more convenient to work with one language but Swift probably needs a couple more years to bake on Linux. Go is fast enough that my AppEngine server never has performance issues. I highly recommend it.
- Apocryphon 11y agoWould Kotlin be a better comparison to Swift, given they've both got huge potential for writing mobile apps?
- gman83 11y agoKotlin doesn't have a big backer though. I could see Google adopting Kotlin for Android officially in which case it could really take off.
- pbnjay 11y agoI'd argue optionals are just a variation of Go's interfaces (e.g. io.Reader versus io.ReadCloser)... and enums are basically typed constants in Go (you just don't see the name "enum" anywhere).
- ntonozzi 11y agoOptionals are a way of returning either result or an error, and are not similar to interfaces. Go works around this by providing multiple return values, but because it lacks generics, it is very common to manually check for errors. I'm not sure about Swift, but in some languages you can statically check case statements to make sure that every enum has a case, which is not possible with Go.
- francescu 11y agoEnum in Swift are very powerful. They can have associated values, pattern matching, implement interfaces (conform to protocol), have functions etc. Actually it is my favorite Swift feature.
- TheHydroImpulse 11y agoOptionals can't be expressed safely in Go. They have a type of `Option<T>` or `Maybe<T>`. Swift just has this notion built as an operator. Traditional enums aren't particularly interesting. What languages like Rust and Swift have are tagged unions. They let you associate data with each variant. Moreover, pattern matching is needed to use tagged unions effectively. Constants are not "basically" tagged unions or even enums. They are not grouped into a parent type. For example, if you have a `Foo` enum with `A` and `B` variants; while matching or accepting this, you can accept a `Foo` which is guaranteed to be either `A` or `B`. How would Go typed constants achieve this?
- niccaluim 11y agoIt's impossible to implement optionals without parameterized types, which Go does not have except for some built-in types. And optionals without language support for generic functions are about as useful as an exploding hammer.
- pcwalton 11y agoIt's important to not only take compilation speed but also code quality into account. Swift and Go made very different tradeoffs here with SIL+LLVM compared to Plan 9.
- oofabz 11y agoI think Go hoped GCC would be their high-performance compiler, but it never got the attention it needed. GCC has better micro-optimization in gccgo, but the compiler lacks important features like escape analysis and an up-to-date runtime so it's slower on real-world code.
- pcwalton 11y agoYeah, it goes to show that you really want a mid-level language-specific IR (which is what the Plan 9-based compilers have) if your language is at all high level. I think the ideal for best performance of generated code is 3 IRs: a mid-level language-specific IR for high-level optimizations (especially around memory management and devirtualization), a low-level IR for lower-level optimizations (e.g. algebraic simplifications), and a codegen IR (for instruction selection and scheduling). This is what Swift is doing, as far as I can tell.
- stcredzero 11y agoI just got out of a work presentation on new features in C++11 and C++14. The two presenters went into what's apparently the standard debate about noexcept. This makes me appreciate Go's pragmatic decision not to have exceptions! When you start getting into the nitty-gritty and epiphenomena around implementing APIs, multiple return values with error codes looks pretty darn good. Error codes are explicit and devoid of implicit automagic. You're not going to break a lot of contracts and alter semantics by adding a keyword. The error codes are explicitly part of your function signature, in the most stupidly straightforward way possible. If you're going to be a bad developer and ignore error codes, this is going to appear explicitly in your code. (As opposed to being rewarded with "cleaner" code when you sweep exceptions under the rug.)
- catnaroek 11y ago> Go's pragmatic decision not to have exceptions Um, what problems do exceptions introduce that panics don't?
- stcredzero 11y agoNone, but here's the thing about pragmatic design: You just have to make something that's less problematic the common case.
- catnaroek 11y agoExceptions are meant to be used for exceptional situations too. (Heck, the intended use is in the name!) Using them for normal control flow is bad programming style. (I'm looking at you, Python!) In any case, the argument in favor of using return values for handling error conditions would be stronger if Go had proper tagged unions. With tagged unions, you can guarantee that exactly one of an OK result of an error object will be returned. Right now, Go has the very confusing situation that a function might return two `nil`s (the operation neither succeeded nor failed) or two non-`nil`s (the operation both succeeded and failed), neither of which makes any sense.
- dllthomas 11y ago
- ngrilly 11y agoWhat do you mean by "scripting mode"?
- vram22 11y agoOnly looked at Swift a little so far, but liked something about the syntax. Seems clean. Going to check it out more over time. Hope the Linux support improves.