Live data from Hacker News

Flappy Bird in Swift

github.com

121–126 of 126 posts

Re: Flappy Bird in Swift

#121
post #108

Earlier quoted context omitted.

Heh. Reminds me of when I correct people for if var == true {...} or (and I have actually seen this) if ( == true) { return true; } else { return false; } I sometimes think that simply giving those 5 lines to a person and observing if they make a face like you've handed them a bucket full of day-old fish is a better test for programming aptitude than anything.

I'd argue the second is clearer in many cases. Readability trumps conciseness any day.

I agree that readability trumps shortness of code. I want not for APL nor code run through a javascript minifier.

But the branch and explicit boolean comparison are additional structural complexity (not just "verbosity") and invariably harms readability to me. Care give a poster child example for where it helps readability? Unless it's unclear results in a boolean - a problem better solved through better naming - code like this forces me to perform the equivalent simplification in my head to understand and reason about the code, a process fraught with error and distraction from my actual task.

Re: Flappy Bird in Swift

#122
post #48

Earlier quoted context omitted.

Good luck compiling Objective-C on Windows :)

Here you go: http://www.gnustep.org/experience/Windows.html

Ye-es, except:

  "Apple has recently added new functionality to their runtime, including built-in exception handling, etc. Hopefully these will be ported to the GNU runtime in the future."
My general point is that programming languages don't have to be cross platform to be useful. Certainly handy from a developer's point of view, but just a convenience.

Re: Flappy Bird in Swift

#123
post #108

Earlier quoted context omitted.

Heh. Reminds me of when I correct people for if var == true {...} or (and I have actually seen this) if ( == true) { return true; } else { return false; } I sometimes think that simply giving those 5 lines to a person and observing if they make a face like you've handed them a bucket full of day-old fish is a better test for programming aptitude than anything.

if var == true {...} In some languages var might be truthy but not equal to true. The falsy values may be more of a problem at times. However in the strongly typed swift I don't think it will be a problem as I suspect (but haven't read/tested enough yet to confirm) that only false and nil will be falsy and that comparison with true will throw errors if var isn't of bool type.

Just tried it. In Swift:

  3 == true    // Give an error (operator overload doesn't cover this)
  true == 3    // Returns false
  nil == false // Returns false
You can't use nil or integers directly in an if statement without a function to return a logic value.

Re: Flappy Bird in Swift

#124

Earlier quoted context omitted.

This is awesome and I didn't know this. Thanks for posting it - I don't have much swift experience so I assume there are several things in the code that will be shown to be non-standard.

> I don't have much swift experience… Considering the language has only been public for <36 hours, I would imagine effectively no one outside of Apple (and its Alpha partners) does.

Which will not stop recruiters from seeking candidates with 5 years experience in Swift.

Re: Flappy Bird in Swift

#125
post #42
post #38

Earlier quoted context omitted.

> PS: next time you design a new language just make a random unique combination of the above. That's my impression whenever I see a new programming language too. Why would someone switch to your language if the syntax is just the same boring old syntax they've been using in another language?

It would be pretty weird to base language switching decision on syntax similarity.

Do you see the amount of people that complain about Pythons white space? Plenty of people avoid it for that reason alone.

Re: Flappy Bird in Swift

#126
post #108

Earlier quoted context omitted.

Heh. Reminds me of when I correct people for if var == true {...} or (and I have actually seen this) if ( == true) { return true; } else { return false; } I sometimes think that simply giving those 5 lines to a person and observing if they make a face like you've handed them a bucket full of day-old fish is a better test for programming aptitude than anything.

if var == true {...} In some languages var might be truthy but not equal to true. The falsy values may be more of a problem at times. However in the strongly typed swift I don't think it will be a problem as I suspect (but haven't read/tested enough yet to confirm) that only false and nil will be falsy and that comparison with true will throw errors if var isn't of bool type.

Yes, such languages exist, and even in C++ if (x == true) is different from if (x), given that x is any number kind other than boolean, but my comment was only for the case when the two would be equivalent.
Post reply on HN