News for hackers. Stuff that matters.
Re:Dart language by cubicle67 on Monday October 10, 2011 @08:48AM (#3093519)

    someString.append(System.getProperty("line.separator"));
vs

    some_string += "\n"

Edit: Someone's in disagreement with me, so I'll try and clarify. I'd classify boring code as code where the intent gets lost in the syntax/language or other constructs the maintainer of the code doesn't care about but are required anyway.

Trying to open and read a file in Java is probably a better example as the intent (open this file and read the contents) is buried in about 6 lines of boilerplate code

I use Java as an example because in a previous life I used to write it and see this as perfectly acceptable

Re:Dart language by dextorious on Monday October 10, 2011 @10:17AM (#3093832)
Well, for one you can probably make your own "+=" for strings, if not available, since Dart has operator overloading.

Also, System.getProperty("line.separator") does not translate to n"\n".

The first makes your program more portable. Of course it could be made accesible easier, eg as a constant System.NEWLINE or something.

[UPDATE] Downvote? Really? Because someone thinks "\n" is the same as "line.separator"?

Re:Dart language by jeltz on Monday October 10, 2011 @11:41AM (#3094233)
Indeed they do not translate into the same thing. But neither makes your program more or less portable in itself. It all depends on what you want to use it for. Some files and protocols should always have \n some always \r\n while in some cases it should be the system line separator. I think Python, Perl, C, and Ruby have fixed that quite well by making the IO library do the conversions. I do not remember if it is the same in Java.
Re:Dart language by d0mine on Monday October 10, 2011 @08:53PM (#3096579)
I didn't downvote, but see universal newline support in Python http://www.python.org/dev/peps/pep-0278/
Re:Dart language by nmcfarl on Monday October 10, 2011 @10:50AM (#3093992)
Of course they could have taken perl's tact and defined "\n" to mean System.NEWLINE not 0x0A.

That would have been an improvement right there.