|
|
Subscribe / Log in / New account

Security of Java takes a dangerous turn for the worse, experts say (ars technica)

Security of Java takes a dangerous turn for the worse, experts say (ars technica)

Posted Sep 16, 2013 22:51 UTC (Mon) by HelloWorld (guest, #56129)
In reply to: Security of Java takes a dangerous turn for the worse, experts say (ars technica) by ThinkRob
Parent article: Security of Java takes a dangerous turn for the worse, experts say (ars technica)

I'm sorry, you Java fanboys are just pathetic. Here's the C# source code to do the same thing:

public static IEnumerator<T> foo<T>(T[] bar) {
  foreach(var x in bar)
    yield return bar;
}
And of course it's easy to write this if all you're doing is iterating over an array. But things become much harder if you actually write an iterator that does something interesting. The C# (or Python) compiler actually helps you to get the control flow right, while Java is just in the way.


to post comments

Security of Java takes a dangerous turn for the worse, experts say (ars technica)

Posted Sep 17, 2013 8:40 UTC (Tue) by jezuch (subscriber, #52988) [Link]

> I'm sorry, you Java fanboys are just pathetic. Here's the C# source code to do the same thing:

Giving an example that is easier does not mean that the original example is not easy.

Now, the *real* problem with the original example is that it's a simple adapter. If the iterator is supposed to do some filtering, then it becomes significantly less easy. That's when I long for yield in Java :) But the upcoming lambda support in Java 8 is supposed to make this much, much easier and effectively eliminate the need for implementing iterators thus making yield insignificant.

Security of Java takes a dangerous turn for the worse, experts say (ars technica)

Posted Sep 19, 2013 15:27 UTC (Thu) by ThinkRob (guest, #64513) [Link]

Apparently simply writing in a language makes me a fanboy. Who knew?

Yes, C# requires fewer lines. I wasn't playing code golf though; I was responding to the claim that it was hard to write an iterator. It's not. It may not be as few lines as you'd like, but it's not hard -- or at least it shouldn't be for anyone who knows the language well enough to be writing more than Hello World in it.

It's worth noting that C# isn't burdened by the same backwards-compatibility requirements that Java is. There's a *lot* of parts of Java that could be better if they were allowed to introduce breaking changes (the Collections API comes to mind), but that's the curse of being first I suppose.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds