Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment operator #34

Closed
richelbilderbeek opened this issue May 4, 2016 · 5 comments
Closed

Assignment operator #34

richelbilderbeek opened this issue May 4, 2016 · 5 comments

Comments

@richelbilderbeek
Copy link
Contributor

I find it peculiar to prefer = over <- as an assignment operator. Sure, Yihui Xie his personal preference is mentioned, but AFAIK no coding standard recommends this.

I copied my collected references about this topic from here to the references section below. Next to this, lintr (of course, that is Hadley's coding standard as well) will complain by default at this. Why not teach beginners (or pro's) the (AFAICS) golden standard, developing their own personal style later?

Just my two cents, I think the idea of your book is awesome!

Reference

  • [1] Google's R Style Guide: Use <-, not =, for assignment
  • [2] 'R Style. An Rchaeological Commentary.' by Paul E. Johnson, February 13, 2015, 3.2 (SEA .95). Use "<-" not "=" for assignments
  • [3] 'R packages' by Hadley Wickham, O'Reilly Media, Inc., 2015, Chapter 3, paragraph 'Assignment': Use <-, not =, for assignments
  • [4] Martin Maechler, Keynote Speech at useR!, 2014, 'Good Practices in R Programming', YouTube, Rule 2: Keep R source well-readable and maintainable
@csgillespie
Copy link
Owner

Thanks for the feedback. I realise that "<-" is typically prefered to "=", but my preference has come from teaching. AFAIK, there isn't another language that uses "<-". Many people program in another language, C, python, Java, Scala, Javascript, Stan; and switching operator is a pain.

I was teaching R to a bunch of C# programmers a few weeks ago. Their number 1 irritation was "<-"; when I mentioned that "=" did the same job, they loved it.

We'll keep the issue under review before the final version.

@csgillespie
Copy link
Owner

BTW, thanks for the link to your site. Very nice.

@richelbilderbeek
Copy link
Contributor Author

I don't teach my students how to do a proper coding style myself. I teach them about lintr and then expect them to have clean lints. Also @lintr-bot is well known to all of them.

I interpret the = for an assignment as a hint that I am looking at beginner code, even though I know some experts use it.

As a C++ programmer, I have no problems using different assignment operators at all, like I also don't have a problem with different bracket placements. Also, Hadley Wickham is a C++ programmer, who hasn't suffered at all.

But, hey, feel free to ignore. It's just a minor detail of a possibly awesome book!

@Robinlovelace
Copy link
Collaborator

Here's my take from a teaching perspective: people get really muddled about the assignment issue and it's clear that <- is a relic to old code. I recently made the switch (following the lead from Colin and discussion for this book) and I can honestly say it's made my life better. Not much. But I save maybe 1/4 a second and finger dexterity each time I assign an object now. + it's WAY easier for teaching.

From a philosophical perspective: be the change you want to see in the world. I want fast-to-type, easy to read code, the style of which adapts over time in the same way that human languages do.

@richelbilderbeek
Copy link
Contributor Author

Thanks for this friendly addition! Well, in the end we do not have to agree about every single thing, which is fine. I then just hope you like my other suggestions better :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants