5 ms·
Feels like they looked at a bunch of programming languages, took all their favorite features, and then put them into one which still sits on top of the ObjC run
by arasmussen 12y ago
Feels like they looked at a bunch of programming languages, took all their favorite features, and then put them into one which still sits on top of the ObjC runtime. And then added some Apple syntactic craziness.
For example:
var apples = 3; // mutable
let oranges = 5; // immutable
let summary = "I have \(apples) apples and \(oranges) oranges";
- lexy0202 12y agoDo you need the semicolons?
- deleted 12y ago[deleted]
- krilnon 12y agoNope. "you don’t even need to type semi-colons." [1] [1]: https://developer.apple.com/swift/ https://developer.apple.com/swift/
- arasmussen 12y agobut you should probably use them anyway :P
- supercoder 12y agono
- deleted 12y ago[deleted]
- twic 12y agoI don't get what you don't get. What's strange here?
- pshc 12y agoUsing the backslash+parens for interpolation is really clever! No more ambiguity like when using % or {}. Is that a Swift original syntax?
- stephenitis 12y agoI think it makes it harder to read interpolated strings, I'm just so used to seeing % and {}.
- cannam 12y agoYeti (http://mth.github.io/yeti/ http://mth.github.io/yeti/) uses that syntax. One of my favourite languages.
- munificent 12y agoYou say "Apple syntactic craziness", but "var" is identical to JS, et. al. and "let" is identical to ML, et. al. The string interpolation syntax is unique, but kind of makes since given then \ is the escape character in C strings.
- arcatek 12y agoAnd "let" will have a totally different meaning in ES6. It's a bit weird to use a keyword from some language with the same meaning, and another keyword from the same language but with a totally different meaning.
- arasmussen 12y agovar and let were referring to ripping off other languages and the syntax you pointed out as unique is the syntactic craziness.
- billyhoffman 12y ago"let" is JavaScript as well. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- seanalltogether 12y agothe typing system seems to be from ecmascript as well var distance:Double = 70.0
- munificent 12y agoThis type annotation syntax comes from ML in the 70s (60s?).
- Sami_Lehtinen 12y agoProgrammers here? But they haven't ever heard of BASIC? LET has been used for variables least since 1968.
- sanderjd 12y agoAlternative viewpoint based purely on your three lines (I can't seem to get to the reference manual...) - all of those seem like pretty good design decisions. To me, "var" sounds like it makes something that is variable and "let" sounds like it is creating an equivalence. The "\(foo)" syntax actually looks really clean to me, though I can't recall having seen anyone use it for that before.
- shortsightedsid 12y agoThe language itself isn't radically different from most mainstream Algol style languages. That's good because it makes it pretty easy to pick up. In addition to what you mention on variables vs constants, the only feature which is nice seems to switch-cases. a. No fall through. This is a plus in avoiding bugs. This is minus if you really know what you are doing and want fall throughs b. Pattern Matching in case statements. This is bit interesting and should take care of the previous case. Other than that my first impression is it's a mishmash of various programming languages. Everything else that they demo'ed seem to be features of XCode (rewinds, variable lifetype analysis etc..) rather than the language itself.
- wnissen 12y agoFrom the manual: “Execution doesn’t continue to the next case, so there is no need to explicitly break out of the switch at the end of each case’s code.” I bet I know when that became a priority!
- griotspeak 12y agoThat should actually be 'no implicit fallthrough'. You get fallthrough with the fallthrough keyword.
- stock_toaster 12y agoA quick scan of the ebook has a pretty nice looking collection of stuff: option type, generics, protocols, etc. A bit of python looking stuff and some ruby looking stuff in there too. I am intrigued enough to give it a try when it is available.
- deleted 12y ago[deleted]