Earlier quoted context omitted.
Looks really slick. Thanks!
Welcome but the guy who invented it, Per Wendel and those who help him maintain it are the ones who deserve the credit. If you're into Lambda's (I'm not yet but trying to bend my mind to want to use them), he's working on adding them for version 2 which should make it even simpler.
An Opinionated Guide to Modern Java, Part 3: Web Development
111–120 of 168 posts
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#112Earlier quoted context omitted.
As opposed to?
Well… checkout Flask, for instance: from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello World!' if __name__ == '__main__': app.run() Of course, you still need to know how Python Does Things, and The Thousand Ways To Deploy An App, and Package Management and so on, but for this trivial example it's a lot more conceptually lean than the semi-equivalent offered above. I don't n…
You import some stuff... check. You create an instance... check. You define a route... check. You define a method to implement the route... check. You return a String... well the example returns a map, and converts it to JSON. You start the app in a main method... check.
Sure the java is a little more wordy and there are some extra params which are not used (the IDE would fill those in automatically when you implement the interface), but the complexity is the just same as far as I can see.
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#113How does asynchronous futures end up being more complicated or in any way worse than the blocking threaded approach? for { user
Yep, that's very nice code, except: user = getUser(1) company = getCompany(user.companyId) longresult = process(company.getSomething) is a) simpler (because that's what your normal code looks like), b) performs exactly the same (as fibers basically do the same thing, only transparently), and c) retains context (like ThreadLocal variables). So if that was the only way, I'd say, fine. But once you have lightweight thre…
Actually, no. My code will always look like the for comprehension be it async or not, because my 'get' methods will always return an Either, Option or some other monadic context to represent the computation succeeding or not.
> performs exactly the same (as fibers basically do the same thing, only transparently),
Yes, I agree.
> c) retains context (like ThreadLocal variables).
Threadlocal variables are almost always code smell. If you find yourself using them, there is almost certainly a better way of accomplishing the same thing.
I don't see how having a Fork/Join threadpool that 'powers' the futures would be any slower than lightweight threads either.
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#114Earlier quoted context omitted.
You should read the end of the post, then. The asynchronous, non-blocking approach, is always wrong. Regardless of your hardware architecture.
"The asynchronous, non-blocking approach, is always wrong." http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Comput... If you have a method that relies upon a DNS query, and your DNS server starts to respond to requests very slowly, your blocking application will run out of threads very quickly, and you'll be spending time poring over thread dumps trying desperately to see why all of your threads are waiting whe…
If you have a sufficiently slow DNS you will chew through all the memory available to your non-blocking application in an amount of time that isn't functionally different from how long it will take you to exhaust your threadpool.
The whole point of the lightweight thread approach with shrinking stacks is that you will use the same amount of memory for both and they will fail at roughly the same point.
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#115Earlier quoted context omitted.
You should read the end of the post, then. The asynchronous, non-blocking approach, is always wrong. Regardless of your hardware architecture.
"The asynchronous, non-blocking approach, is always wrong." http://en.wikipedia.org/wiki/Fallacies_of_Distributed_Comput... If you have a method that relies upon a DNS query, and your DNS server starts to respond to requests very slowly, your blocking application will run out of threads very quickly, and you'll be spending time poring over thread dumps trying desperately to see why all of your threads are waiting whe…
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#116You had me until you said Asynchronous I/O is faster than Synchronous I/O in Java. http://www.mailinator.com/tymaPaulMultithreaded.pdf
I'd argue that a well written NIO (and virtually there are no good open source NIO impl) will beat flat out any blocking. NIO is both faster and offers better/predictable latency under load.
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#117As a modern java developer I was surprised to find no mention of Vert.X which to me seems like one of the most modern and forward-thinking java web frameworks. Not only does it support scaling your app out-of-the-box but also provides a simple way to deal with concurrency.
I've been stuck using Vert.x for a year and half. I recommend using something else. It's a questionable framework mashed together with a poorly though out messaging system. I would rather use Spring Integration, Quasar, or Akka.
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#118Earlier quoted context omitted.
I put my money on Spring, Hibernate, JBoss lasting longer than Scala, Akka etc. Those technologies have stayed on, while other trends have come and and go.
Actually, it is basically Pivotal versus TypeSafe, not just Spring versus Akka or anything like that. I put my money on TypeSafe. Pivotal still (05/2014) doesn't have Java8 support for some of it's frameworks (grails https://jira.grails.org/browse/GRAILS-11063 ) . TypeSafe pre-released versions of Play that take full advantage of Java8 features. Given that if you need to run a Java 1.4.2 app on top of JBoss (or Glass…
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#119Man, am I ever fascinated with the complexity Java devs have to put up with. Maybe it's just been a long time since I had to deal with Java-land, but you need to know about so many different things just to get off the ground. Granted, this may be easier with newer frameworks, but still.
That's because, after getting into the air you will be bought and then you will find out that you wish you had started with solid technologies and architectures.
Re: An Opinionated Guide to Modern Java, Part 3: Web Development
#120Earlier quoted context omitted.
(I'm guessing that was "So why separate ...", and you've just had root canal) They're separated in the sense that the app server is something you download that exposes an API, and the app is something you write on top of the API. It's much the same as the way the JVM and the class files are separated, or the way the OS and the JVM are separated. It's a fairly straightforward, pragmatic application of layering.
Maybe we mean different things by "separated". I want the app server bundled into the app, not an assumed dependency that the app has on the target environment. Rack in the ruby world exposes an API that ruby web apps build on top of, but you never install an app server then install your app into the server.
My preferred solution would be to package the app and the app server as operating system packages, and have the app depend on the app server. That makes the dependency explicit, but doesn't leave you with a gigantic deployable.