5 ms·
What does "boring Java-like syntax" mean? Can anyone show some quick examples of a boring and a not boring syntax?
by iaskwhy 15y ago
What does "boring Java-like syntax" mean? Can anyone show some quick examples of a boring and a not boring syntax?
- nailer 15y agoRequiring a function for a simple print statement, perhaps? The demo breaks when you remove the surrounding main() loop.
- cubicle67 15y agosomeString.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
- dextorious 15y agoWell, 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"?
- nmcfarl 15y agoOf 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.
- jeltz 15y agoIndeed 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.
- d0mine 15y agoI didn't downvote, but see universal newline support in Python http://www.python.org/dev/peps/pep-0278/ http://www.python.org/dev/peps/pep-0278/
- highwind81 15y agoCircle my_circle = new Circle(); I have to type the word circle 3 times to define a circle. It gets boring. This gets worse if you are trying to do any kind of user input. BufferedReader my_reader = new BufferedReader(new InputStreamReader(System.in)); Had to type reader 4 times. :(
- seasoup 15y agoPeople can argue with "boring", call it redundant instead and you'll get less harsh feedback.
- iaskwhy 15y agoBut is it something people actually type? I haven't played with Java for almost ten years now but I do C# for a living which is pretty similar and I can't remember the last time I had to type something that long, Visual Studio does it for me. I can see the point if you say it's longer to read but it's also much clearer, isn't it?
- Peaker 15y agoRedundancy is noise.. How is it any clearer to read?
- iaskwhy 15y agoHow's that redundant? In C# you would just "var something = new object()", so there wouldn't be any redundancy at all.
- Peaker 15y agoI was replying to: "Visual Studio does it for me. I can see the point if you say it's longer to read but it's also much clearer," So he's saying that: Circle circle = new Circle() is typed by Visual Studio for you, and clearer to read. I don't think it's clearer to read.
- 15y ago