News for hackers. Stuff that matters.
Re:C-style vs. Python-style syntax: which one would you pref... by carterschonwald on Sunday December 14, 2008 @12:45PM (#397468)
how about take a page from haskell style syntax, which allows both inferring the block structure from indentation, but also always it to be explicitly denoted at well?
Re:C-style vs. Python-style syntax: which one would you pref... by lincolnq on Sunday December 14, 2008 @02:53PM (#397589)
I've found that I really don't like this, aesthetically (mixing nesting styles in code looks bad)

Also, whitespace based indentation works in Python because Python statements tend to be fairly short. (The python indentation rules are easily understood.) Haskell layout has been somewhat more difficult to understand (at least for me). I have been writing Haskell code and usually it works, but there have been problems due to failure to indent when I should'v, which were incredibly confusing to debug.

In python, it's hard to fuck it up: after a colon, you always newline and indent.

Re:C-style vs. Python-style syntax: which one would you pref... by nuclear_eclipse on Sunday December 14, 2008 @03:21PM (#397605)
> In python, it's hard to fuck it up: after a colon, you always newline and indent.

But what about:

    if True: print "Yep"
;)
Re:C-style vs. Python-style syntax: which one would you pref... by whatusername on Sunday December 14, 2008 @06:06PM (#397743)
Get with the program:

if True: print("Yep")

Re:C-style vs. Python-style syntax: which one would you pref... by ljlolel on Sunday December 14, 2008 @06:07PM (#397744)
Don't do that: http://www.python.org/dev/peps/pep-0008/

Some features of Python are only really meant to be used at interactive prompts, like import STAR ( I can't write star?)

Re:C-style vs. Python-style syntax: which one would you pref... by nuclear_eclipse on Sunday December 14, 2008 @06:20PM (#397752)
Completely agreed; I was just pointing it out.
Re:C-style vs. Python-style syntax: which one would you pref... by FalconNL on Sunday December 14, 2008 @01:40PM (#397520)
Completely agree. The main reason for my preference is that one of the things I hate most in C-style languages is that one-line functions take up three or four lines (depending on whether or not you use K&R style). This greatly increases the amount of scrolling you have to do.
Re:C-style vs. Python-style syntax: which one would you pref... by mdakin on Sunday December 14, 2008 @04:18PM (#397665)
Put it all on one line then! :) I just grepped some of my C/C++ code and my one-liners consistently look like this:

virtual const std::string& getCommand() const throw() { return m_command ; }

Re:C-style vs. Python-style syntax: which one would you pref... by FalconNL on Sunday December 14, 2008 @05:01PM (#397693)
Yeah, that works for really short methods, but for anything even a little more complex you're just replacing vertical scrolling with horizontal scrolling.
Re:C-style vs. Python-style syntax: which one would you pref... by mdakin on Sunday December 14, 2008 @06:56PM (#397780)
That's true for one-liners in any language.
Re:C-style vs. Python-style syntax: which one would you pref... by FalconNL on Monday December 15, 2008 @02:18AM (#398136)
Not necessarily. In Haskell the oneliners are frequently short enough to fit on one screen.

For example, I recently needed to do some Run-Length Encoding:

    import Control.Arrow
    import Data.List
    
    encodeRLE :: (Eq a) => [a] -> [(Int, a)]
    encodeRLE = map (length &&& head) . group
    
    decodeRLE :: [(Int, a)] -> [a]
    decodeRLE = concatMap (uncurry replicate)