News for hackers. Stuff that matters.
Re:Rust is surprisingly expressive by Camillo on Saturday December 28, 2013 @10:30PM (#6978166)

    if post.created_at < 5.minutes.ago
That reads like "if post was created less than five minutes ago", i.e. if the post is more recent than five minutes. However, if "5.minutes.ago" gives you a timestamp, as is reasonable, then that actually means "if post was created more than five minutes ago", i.e. the very opposite of what it would mean in English. Whoops!

A more sensible syntax might be:

    if post.creation_date < now - 5*minutes
"ago", "from_now", "since_now" etc. are especially despicable in a language where you can just use + and -.
Re:Rust is surprisingly expressive by mattgreenrocks on Sunday December 29, 2013 @11:45AM (#6980118)
I'd prefer:

    if post.editable?
to everything I've seen. There's a concept behind the if statement that should go in the model. I realize this is sort of off-topic, but it kind of negates the whole discussion since you can wrap up the cute/ugly and test it alone. :)
Re:Rust is surprisingly expressive by klodolph on Monday December 30, 2013 @03:20AM (#6983668)
And what would the definition of `editable?` look like?

    fn editable(&self) -> bool {
        self.created_at < 5.minutes().ago()
    }
Yes, it's wrong. No amount of unit testing or isolation is going to change the fact that whenever you read code like that, your brain will come up with two conflicting meanings, because these cutesy methods make it look too much like English, and English has different rules.

English parse tree is: ((less than (five minutes)) ago), whereas code parse tree is (less than ((five minutes) ago)).

Re:Rust is surprisingly expressive by Camillo on Sunday December 29, 2013 @05:51PM (#6981861)
A capital idea, my friend! But I'll do you one better: why not just wrap up the entire program inside a function called "main"? Clearly that would make all syntax discussions moot, now and forever.