Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Whitespace and perl developers

by redhotpenguin (Deacon)
on Feb 15, 2008 at 18:06 UTC ( [id://668206]=perlquestion: print w/replies, xml ) Need Help??

redhotpenguin has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

One of the advantages I think Perl has over Pyt^W^W^W other comparable languages is that whitespace is insignificant. Perl takes away the thought barriers to creating code, allowing you to solve problems without the language getting in your way.

Although whitespace is insignificant to perl itself, whitespace can be significant to Perl programmers. Take the following example:

# print out 4 print 2+2;

vs.

# print out 4 print 2+2;

vs.

# print out 4 print 2 + 2;

What do you do if you have engineers on a project who each prefer a different style? My solution has been to just go with the flow and not change anything, so that development time is spent writing code, and not on whitespace semantics. But I know that isn't always the case, some developers can have strong opinions.

What approaches have you found work well here?

UPDATE - just got downmodded 1, I guess some people do have strong opinions! :)

UPDATE - we are using all sorts of code control mechanisms, including perltidy, this is more of a question regarding how do you handle differing opinions the issues that aren't caught by the code control mechanisms.

Replies are listed 'Best First'.
Re: Whitespace and perl developers
by olus (Curate) on Feb 15, 2008 at 19:03 UTC
Re: Whitespace and perl developers
by Joost (Canon) on Feb 15, 2008 at 19:32 UTC
    What do you do if you have engineers on a project who each prefer a different style?
    Fight it out decide on a common style and stick to it. And also decide which issues are worth enforcing. In other words; (much of) the spacing issues you describe above are clearly very minor, and for minor issues the rule should probably be: don't change what's there unless you're doing actual work on the code involved. That should at least keep people from committing thousands of lines of irrelevant changes back and forth.

Re: Whitespace and perl developers
by Akoya (Scribe) on Feb 15, 2008 at 18:56 UTC
    Perltidy is a great tool for someone who is anal picky about code formatting.

      We are using perltidy, and a number of other code quality mechanisms, but these particular cases aren't being handled. We've tweaked perltidy et al ad naseum, but it isn't covering these cases. This is more of a question on how to handle the social dilemmas in the edge cases, apologies if I wasn't more specific in my original post.

Re: Whitespace and perl developers
by j1n3l0 (Friar) on Feb 15, 2008 at 19:09 UTC
    Yes, I would say Perl::Tidy would be the way to go (Keep it consistent). You'd still have to decide on what should be done. In your examples above, I prefer the print 2 + 2 version ... There are some places where the whitespaces help with readability.

    Perhaps you should take a look at Perl Best Practice for further discussions on this topic =)


    Smoothie, smoothie, hundre prosent naturlig!
Re: Whitespace and perl developers
by pc88mxer (Vicar) on Feb 15, 2008 at 23:16 UTC
    Sounds like this is more of a technical management issue. I would try to impress upon those developers that the company cares more about meeting deadlines and writing bug-free code than how many blank lines a script has. Find opportunities (i.e. performance reviews) to reward those who show more maturity and don't contribute to these kinds of petty arguments. Finally, you might try reminding them that there are several factors, including the growth of the global economy, which are rapidly driving the cost of software development to zero, and if they want to continue to be perl developers they have to show that perl can be a cost effective means for developing software.
Re: Whitespace and perl developers
by Erez (Priest) on Feb 15, 2008 at 20:38 UTC

    I try to follow the code-as-text practice and place whitespace between "paragraphs" of code, which ease up readability (after all, no one likes to read huge chunks of text) and help me convey my meaning.

    My understanding of whitespace in Python is that it enforces bracing style, rather than split the code into logical parts. And brace style tends to be more of a Holy-Wars issue than "Best-Practices" one.

    What do you do if you have engineers on a project who each prefer a different style?

    That's why we have project leader/administrator/head for. Style is irrelevant as long as its consistent, and part of a project admin's job is to force consistency

    Software speaks in tongues of man.
    Stop saying 'script'. Stop saying 'line-noise'.
    We have nothing to lose but our metaphores.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://668206]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-25 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found