I think we have profoundly different aesthetics as programmers. Languages have 
tons of features that one shouldn’t use: the ability to write buggy code being 
one trivially obvious example. Style guidelines exist precisely to tell people 
what code they shouldn’t write _even though it’s supported by the compiler__.

To my knowledge, Julia has for x = 1:10 exactly because it tries to seem 
similar to Matlab. Originally, it only had that, but the for x in y idiom was 
created at some point without removing the Matlabism to maintain Matlab 
compatibility.

 — John

On Dec 31, 2013, at 11:19 AM, Daniel Carrera <[email protected]> wrote:

> I think I mostly use commas as you do ---f(x,y) vs endswith(str, substr)---. 
> I do use parenthenis to not rely on precedence rules though.
> 
> On the topic of "for x in" vs "for x =", I would argue that it does not make 
> sense to have Julia support a feature and then have a style guide saying not 
> to use it. It's not as if Julia is trying to be compatible with another 
> language's syntax.
> 
> 
> 
> On Tuesday, 31 December 2013 10:54:58 UTC-5, Stefan Karpinski wrote:
> I would mention that the vast majority of Base Julia, although it's fairly 
> internally consistent, does not follow a lot of these rules. In particular, 
> the whitespace rules and some of the type annotation rules, and "for x in" vs 
> "for x =". I tend to follow rules that require a bit of judgement, but 
> therefore convey some subtle information about the code.
> 
> Whitespace. I don't use spaces when calling functions that are mathy: f(x,y). 
> I do, on the other hand, tend to use spaces when calling non-mathy functions: 
> endswith(str, substr). I think that math expressions should be spaced so that 
> they're readable and I'm not sure that a fixed set of rules does that, 
> although no spaces for tighter operations and spaces for looser operations is 
> the trend. I rely heavily on Matlab precedence of arithmetic versus ":".
> 
> For loops. When the right-hand-side is a range like 1:n then I use =. When 
> the r-h-s is an opaque object that we're iterating over, then I use in. 
> Examples:
> 
> for i = 1:n
>   # blah, blah
> end
> 
> for obj in collection
>   # blah, blah, blah
> end
> 
> 
> 
> On Tue, Dec 31, 2013 at 10:01 AM, John Myles White <[email protected]> 
> wrote:
> One of the things that I really like about working with the Facebook codebase 
> is that all of the code was written to comply with a very thorough internal 
> style guideline. This prevents a lot of useless disagreement about code 
> stylistics and discourages the creation of unreadable code before anything 
> reaches the review stage.
> 
> In an attempt to emulate that level of thoroughness, I decided to extend the 
> main Julia manual’s style guide by writing my own personal style guideline, 
> which can be found at https://github.com/johnmyleswhite/Style.jl
> 
> I’d be really interested to know what others think of these rules and what 
> they think is missing. Right now, my guidelines leave a lot of wiggle room.
> 
>  — John
> 
> 

Reply via email to