5 ms·
Um, I don't hate Factories, Dependency Injection and Decorators. I hate that Java makes it very cumbersome to use them, typically via xml configuration files (s
by Tichy 17y ago
Um, I don't hate Factories, Dependency Injection and Decorators. I hate that Java makes it very cumbersome to use them, typically via xml configuration files (so that it can be dynamic) and adding complex syntax (generics, annotations). And I hate that I can not pass functions as parameters. As he says in the article: "function composition is a degenerate case of the Decorator pattern." (not sure why "degenerate") - so instead of just composing functions, in Java I have to write countless classes and interfaces. That's what I hate.
- jbooth 17y agoThat's not Java. That's EJB. Or JPA. Or JBOSS. Or RMI. Or any other bad idea that's come out in the last 15 years. Java's been out and big for 15 years -- every bad idea has had a big push for it in Java. But the language? Something like a dozen keywords. With some really nice libraries like java.util.concurrent and the Collections API. Just because lousy designs have been written in Java doesn't mean it's a lousy language. It may be starting to get a little dated, but that's a different matter. It's basically becoming the C of the JVM at this point, with higher level languages like JRuby and Clojure to run in application space and Java as your platform space.
- Tichy 17y agoNot quite - to be able to use factories and dependency injection, you have to use interfaces. And not being able to use functions as parameters (or write them on the fly) is annoying in all kinds of software development, not just enterprise software. Also, all the nice libraries have been updated to use the new language features like generics and annotations.
- jbooth 17y agoYou don't have to use interfaces in order to do dependency injection, you just probably should, depending on the task. I wrote something last week which injected dependencies directly to a class. Interfaces are actually one of the best ideas in Java, IMO, if you're using them appropriately. Generics and annotations are pretty useful. What's the matter with them? Have you spent time developing with them? They're certainly better than having to cast all over the place. RE: functions as parameters.. yeah that's kinda annoying. You can always do new Runnable() { void run() { doSomeStuff; }} but that's ridiculous. So you have a point there. Aside from that though, the language is suitable for most tasks, and requiring a little extra syntax when you want to pass functions around isn't the end of the world. Anyways, I'm sure I'm arguing against the trendy masses here, and I have a clojure book too, just trying to set up the opportunity to use it for something real.. but there's a reason why most "real" back-end stuff that has to be performant, stable and reliable winds up getting written in Java these days. That includes Hadoop, Lucene and half of the NoSQL key-value stores that you're excited about :)
- nostrademons 17y agoA lot of the "real" performant/stable/reliable backends seem to be written in Scala and Erlang these days. People use whatever languages are production-ready state-of-the-art at the time they begin their systems. C++ was state-of-the-art when Google started in 1995; Java was state-of-the-art when Lucene/Hadoop started in the early 2000s; now people are building things in Scala and Erlang. Anyway, be careful when using "big and accepted" projects to indicate ideal platforms. It takes 5-10 years for a project to become big and accepted. In the process, its technology platform has probably become obsolete, but continues on because of inertia. Your goal should be to shoot for what your role models would do now, with the benefit of 10 years of additional technical development, and not where they were 10 years ago.
- Retric 17y agoYou might want to double check your dates on Erlang. The first version was developed by Joe Armstrong in 1986.[1] It supports hot swapping thus code can be changed without stopping a system.[2] Erlang was originally a proprietary language within Ericsson, but was released as open source in 1998. http://en.wikipedia.org/wiki/Erlang_%28programming_language%29 http://en.wikipedia.org/wiki/Erlang_%28programming_language%...
- nostrademons 17y agoI know how old Erlang is. My point is that the computing environment has changed in the meantime, such that it's now a viable alternative for servers.
- Retric 17y agoOk, my point was I recall some Erlang hype back in 90's. What specifically in your opinion made that 20+ year old language "production ready"?
- nostrademons 17y ago
- viraptor 17y agoI do hate Factories and DI. They are just buzzwords really. As someone mentioned in other comment - all those things he lists can be done in a dynamic language and some of them will be much easier. Factories == constructors meet partial application and functions passing. They seem to be objects only because Java lacks nice support for bare functions... DI / IoC == ... well ... good design. You're simply limiting the amount of state and coupling. Decorators, proxies, etc. - duck-typing and metaclasses are a bit more flexible here. And the first example is just passing a function to a threadpool - there's nothing very tricky about it either... It seems to me that author never used a dynamic language properly :(
- sedachv 17y agoThe problem dependency injection attempts to solve disappears when you have dynamic scoping. I've said this before - DI is probably the dumbest fad (no small feat) in object-oriented programming.
- Tichy 17y agoCould you remind me what dynamic scoping is? Thanks!
- viraptor 17y agof() { return x; } g() { x=1; return f(); } f() returns x it inherits from g(). A spectacular way to shoot yourself in the foot.
- Tichy 17y agoThat looks like no scoping at all? I think JavaScript is a bit like that? But most languages would prevent that kind of thing?
- regularfry 17y agoIt's not no scoping - it's specifically scoped to where the call to f() was made, rather than where it was defined. It basically makes everything in scope in g() available to f() as a hidden parameter. Pre-CL Lisps had this by default. defvar is, as far as I can tell (still learning!) how you get at it now.
- axod 17y agoWhat the hell has XML got to do with Java? You're confusing frameworks with languages. Most Java frameworks suck. Agreed.
- Tichy 17y agoNo, it is not a coincidence that Java and XML go hand in hand. Heavy XML usage was introduced into common Java practice to compensate for the lack of dynamic features in Java. So dynamic features were introduced (badly) through the XML backdoor. Also often XML is used as a poor mans DSL. It could have been something similar to XML (like JSON or YAML), but that is not the point. Also, the verbosity of XML aligns itself well with the Java mindset.
- axod 17y agoUtter BS. I've been doing Java programming for 10 years and have never touched XML thank god. "the Java mindset" - more utter BS. There isn't a 'Java mindset' unless you're a bad programmer who is ruled by his language instead of using languages as tools. The "mindset" you have depends on how good a coder you are. Which is the same regardless of which language you decide to use to solve a particular problem.
- Tichy 17y agoFine, then you are the exception to the rule. As for the mindset, it seems to me that at least SUN was very busy churning out cookbooks for a lot of things. Mostly Enterprise Java - if you managed to avoid that, more power to you. But I think most people tried to do things the "official" way.
- axod 17y agoTotally @ Enterprise. Horrible horrible stuff that, but really, there's some great technology in the JVM, and built in libs. And the Java language is a pretty sane general purpose language. It's fairly easy to spot all the crap and avoid it.
- 17y ago