Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
For the out-of-band Slashdot experience (mostly headlines), follow us on Twitter, or Facebook. ×

Comment: Re:Why? (Score 1) 355 355

Yeah, I see it screwed up my Java code too, bleh. Anyway, you shouldn't have issues with Java and generics WRT that sort of type safety. There's never a need to explicitly cast, unless of course for whatever oddball reason you create something like List<? Extends Foo> and I frankly have never found a reason to do that.

Comment: Re:Why? (Score 1) 355 355

You've been able to supply a comparator to a sort, or to a collection with a concept of order, forever. I mean if I were to paste in an example it would seem a little clunky by comparison to Ruby, since it would require a bit of extra declaration, but its the same basic thing. I've got an entire order matching engine core class that utilizes this concept to implement multiple different selection criteria for orders. And nobody uses a loop for this sort of thing, you use currying, even in Java. Or at least you simply call a method that returns a list of results that match your criteria in some preferred order.

I don't do a lot of anonymous class boilerplate, but then I don't write a ton of UIs in Java either. Outside of that particular use-case its not all that common. When I do have inner classes they are generally non-trivial, at which point a couple extra lines of boilerplate is a wash really.

There's nothing wrong with Lambdas, but they're overhyped, and they can lead to some very unclear code.

I don't think your example of type erasure is even relevant.


ArrayList myStrings = new ArrayList(); ...
String tmp = (String)myStrings.get(0);

Isn't even good Java, the compiler WILL issue a warning about it. Your IDE should flag it as non-typesafe code too.


List mystrings = new ArrayList();
String tmp = myStrings.get(0);

This would be the proper way to code this. There's no issue with type erasure here, although you CAN devise some dubious uses of a generic collection where C# or C++ would throw an error EARLIER during execution than Java will. Its hardly a huge big issue. If you use unsafe constructs or reflection to invoke generic methods, well, you may get what you deserved!

What cracks me up are Java accessors and mutators that don't do any thing other than store and retrieve a value.

public void setIdiocy(SomeType idiot) {
this.idiot=idiot;
}

Just make the fields public, it is the same thing.

No it isn't, and your failure to understand the difference betrays your lack of experience with maintaining large code bases over time in the face of constant refactoring. A public field exposes the implementation of the class, a public getter/setter does not. Maybe it doesn't matter to you today, but I code with a decade from now in mind, and the trivial overhead of small extra abstractions is worth it. Now, C#'s "it looks like a field but its really an accessor" is OK, but it can confuse the uninitiated. I prefer overall a lack of these sorts of features, it doesn't take being burned twice to eat up all the benefits such a thing will ever produce.

Comment: Re:Shawshank Redemption (Score 0) 80 80

People are being imprisoned for essentially 'made up' reasons, yes. For instance you might be one of a certain unfortunate minority who is constantly pulled over by the cops basically for every conceivable excuse. Now if you were me (a WASP) you might get a warning for your tail light being burned out (as I did a while back by a cop who was very polite). If you're not so fortunate you're getting tossed against the fender of your car, beat up side the head, and when you object you're tossed in jail for 'resisting arrest' or some variation thereof. Now, after a couple weeks, when your job is good and set sail, etc. You will come up before a judge, who will not only give you 30 days, but charge you about $1000 for "court system costs" and when you obviously can't pay them, you'll spend literally an unlimited amount of time in prison until you're so lucky as to have someone cough up the money (Oh, and on top of that a prison housing fee, meanwhile you get to do prison labor for $1 a day which some business profits off of).

If you doubt me, do a little research, this is literally the standard operating procedure in most of the US today. Even black children are incarcerated like this and put in debt bondage to the state, though the charges will be school-related (delinquency, assault for talking back to a teacher, etc). Welcome to Prison World!

Comment: Re:Desktops vs Mobile (Score 1) 250 250

Eh, no simple correspondence here. I mean, sure there are a couple of forms that correspond pretty closely to some entities in the management UI that we use, but there's a lot of rather complex logic and many of these entities are used in a number of different processes. Its just that Java, and certainly JavaEE, heavily encourages the 'DTO' or 'Bean' model where entities are generally containers and if they have logic its purely related to things like interrelated properties, consistency, etc.

I don't find your characterization of Java to be that accurate, but what you find 'irritating' may be far different from what bothers me. I want simple regular syntax that doesn't offer a ton of alternatives. That leads to consistent maintainable code. Making things explicit also leads to more thorough and comprehensive testing and documentation. I have LOADS of 500 line class files that implement complex business logic. I need them to be intelligible to anyone that looks at them, not models of clever syntax that manage to get trimmed down to 425 lines, but are less clear. I am happy with conciseness, its good, but its not always the primary goal.

Comment: Re:Desktops vs Mobile (Score 1) 250 250

Well, at any rate, I think the notion that .NET is 'in decline' is probably dubious at best. I don't know where its going, but it hardly seems likely that MS is about to abandon the whole technology. I WOULD say however that MS's hold on the 'back room' is pretty tenuous these days. They never really won the argument as to overall value proposition of Windows in the server room over *nix. They have virtually no penetration in the OSS server space, and Mono really went no place there either. Its a pretty hard sell to suggest a .NET/IIS based line-of-business solution to larger IT organizations these days. The more sophisticated shops just stick with Java and the smaller ones tend to either utilize some tool specific to their vertical or built PHP apps or something.

I think that pretty well explains MS's push with open sourcing a lot of stuff, and getting behind .NET both on every client device and on every server platform. The dream of the total end-to-end dominance of Windows was a LONG time dying, but its finally dead. Its an interesting situation. Java hasn't exactly penetrated the client side space in a consistent way either, so there's plenty of room for each toolset to try to differentiate itself.

The bigger question might be whether Oracle really cares enough about Java to keep playing this game. They've done a lot, but OTOH they're basically selling database server licenses, with OAS as a sideline that supports the consulting side of the company. Even if they stopped supporting Java it wouldn't really impact their core business that much, at least in the near-term. MS OTOH is in a more ambiguous position. Its not even clear what their core business is going forward. MS Office? SQL Server? MSVS/dev tools? I don't think they know...

Comment: beats me! (Score 1) 355 355

I wouldn't say Java is utterly consistent. Its pretty generic though, and I like that. If you know C you can pretty well understand the flow of code in a Java method, and if you have a general understanding of OOP then you will pretty much understand Java. I think the same can be said for C#.

Frankly I was considering using a scripting language to write some test driver code. I figured it would be a little less tedious and easier, but what I found was that with a modern IDE it just wasn't worth the bother. Yeah, I could make my test harness a little simpler, and in theory I could even edit it without recompiling, but it was just plain easier to write the stuff in Java, its just not that hard to code in.

I mean there are very definite use cases for scripting, but its not like the old days where it was much easier than coding in a compiled language.

Comment: Interesting (Score 2) 250 250

I think the problem is that you can make a higher quality product using Qt, but it IS more expensive. Writing C# code, or Java line-of-business stuff is just more cost-effective when the use cases are very specific. I mean I wouldn't write some one-off program to manage some tiddly business process somewhere in C++/Qt because nobody cares if it has to run on a Windows box, and nobody cares if it is fast, small, or even all that reliable. So a vast array of stuff exists in these environments.

Then there's super high-reliability stuff, like most of the code I write. It has to handle 400 million transactions in a week and never crash, never miss one, etc. It certainly COULD be written in C++, but the hunt for stupid programming errors you can't make in Java just makes it more costly. Its also easier to train a Java/C# guy to a level where he can do decent work.

Comment: Re:Desktops vs Mobile (Score 1) 250 250

Removing getters and setters matters? pfff, right. If you have logic in your value entities in general its a bad thing, so why do you even look at these files? Mine were all generated automagically 10+ years ago by some Hibernate tool. Once in a while I add a constructor, tweak an .equals() method, etc. A few have get/set methods that include some logic (caching some expensive to calculate value or somesuch) but I could care less. I mean, really, if you want to avoid getters and setters in Java, just declare your fields to be public, it works fine, except of course for the lack of information hiding, which is of course ALSO the problem with C#'s set/get notation. If I make something a calculated value, it changes the consumer's syntax, potentially. Its also a bit unclear to people when you start mixing pure value fields with calculated ones and using the same syntax that they expect to be reserved for one of those.

I don't think C# is BAD, I just think its much vaunted 'advances' over Java are at best minor tweaks, and Java does some things better than C# too. It would be great if we had the best of both in one, but it isn't happening, so really its 6 of one and half-dozen of the other.

Comment: Re:Desktops vs Mobile (Score 1) 250 250

Personally I think QT beats the pants off any other UI toolkit on any platform, but that's just me. I'd kill to have something that good in Java (IBM reputedly built QT bindings for SWT, but they were never released for whatever reason, assuming they really even existed).

Comment: Re:Why? (Score 1) 355 355

What happens if you need to store a date before 1970? What if you need a date with more resolution than a millisecond?

But I never ever ever will. I know my problem domain. If I was writing code that was going to be used to measure picoseconds, then by gosh I'd use a different scaling. Since nobody will ever give a crud to more than a millisecond in my problem domain you would be asking me to carry a large amount of crap baggage around my code for some non-existing fairytale use case. Same for dates prior to 1970, I'm not doing archaeology here, I'm doing financial transactions. I will never see any date prior to NOW() ever again...

Also, perhaps operator overloading can be misused, but it comes in really handy when you have a class that actually represents a number. You probably don't want to start overriding the plus operator for objects that store XML documents or twitter messages, but that doesn't mean the feature shouldn't exist at all.

Eh, in my quite large amount of programming experience I've seen lots of quite ugly misuses of operator overloads. It MIGHT make some decimal arithmetic slightly cleaner, but I'd most likely have to surround the '+' with extra guards, check rounding and possible precision issues anyway, etc, so it wouldn't gain me very much. Maybe there are cases, in a math package or something, where it might be handy. I'm perfectly happy with the decision to not support it, as I benefit from that everyday in knowing what exactly '+' does and not having to worry about it. Again, its the real gain vs the hypothetical gain. IMHO KISS is the best policy.

And perhaps you should do some reading about the .Net decimal data type. It has 28 significant digits. That means that even if you need 8 decimal places (like for bitcoin) you still have enough digits left over to represent extremely large numbers. Basically it has enough range to cover just about every financial transaction most coders are likely to deal with. Most databases (all) have a decimal data type for storing binary coded decimal information. The programming language you're using should also support them.

And it does, with individually settable precision, rounding, and scaling. Its really quite good. Yes, you must perforce use the object method call notation to do your math, but you'd have to do that anyway for anything very complex, and its not like stopPx.add(orderMarkdown).setScale(inst.get("PRICEDIGITS") is that horrendous, or appears 1000's of times in code. So everything I need to do IS supported in a way that's usually reasonably clear and concise. If I generate an SQL query with a DECIMAL(M,N) valued column I get the corresponding BigDecimal representation, all nice and neat!

Comment: Re:Desktops vs Mobile (Score 1) 250 250

I don't understand the fetish with LOC. All that crap that you bemoan is just crap that's generated by the IDE, or often not really needed at all if you know what you're doing. Nor is it true that C# is free of all that jazz either. You still have to define your classes and for any specific design pattern it is going to be pretty much the same classes, subclasses, etc.

If you are constantly implementing generics then you're doing it wrong IMHO. Implementation of generics should be VERY rare. I wrote and continue to extend and maintain a very complex and large Java code-base. There are maybe at most 6 generic classes in there, and I'd say 3 of them were probably mistakes that you'll only encounter if you dig deep into some very specific code. The others work fine.

While I don't have any beef against list comprehensions or whatnot they're just loops. There's nothing special about them, or lambda's either really. Its a perfectly valid stylistic choice to avoid the implicit nature of such things and simply write for(String value : props.values()) { ... } or whatever.

Comment: Re:Desktops vs Mobile (Score 1) 250 250

AWT and Swing are both obsolete and aimed at the same niche as JavaFX (though in all fairness you will use a number of Swing APIs in pretty much any UI project). AWT and Swing were never intended to be 'run anywhere' UIs, they were just intended to be 'if you have Java you have this API' UIs. The whole reason Oracle sued Google over Android is that they've been breaking that. As for SWT (IBM's Eclipse GUI toolkit) it can in principle work anywhere there are bindings to the underlying UI toolkit (it is a thin wrapper), but it hasn't proven to be super popular aside from corporate applications built on top of the Eclipse core (RCP). I think Google's motivation was to simply have the best and most convenient UI toolkit for the Android platform. Swing was built to work with desktops, it would have had to be totally reworked ANYWAY to adapt to the modern age.

So, in essence, Java is in no worse a pickle than .NET, who's existing UI toolkits were also poorly adapted to mobile devices, fractured (GTK+ vs WFC/WinForms), etc. Xamarin hopes to unify that, good luck to them. It could be as well done in Java as .NET frankly.

Comment: Re:Desktops vs Mobile (Score 1) 250 250

Well, considering that iOS is only supported through a 'compile to binary' option, that's not quite as clean and easy as you make it out to be. You can also compile Java to binary BTW, and presumably execute it on an iOS device. Eclipse and GIT will give you all the tooling you need to push your code around between various platforms. Its really pretty much a tossup. I think Java has focused more on back-end and Xamarin is making a play for strictly the user-facing app side of things, but they're both broadly capable of doing the same things.

Simplicity does not precede complexity, but follows it.

Working...