9 ms·
Rapidoid – No-Bullshit Web Framework for Java
- habitue 11y agoHa, I read "Javascript" at first. I guess my brain has a pretty strong pattern for "New web framework for X" at this point
- atemerev 11y agoAn excellent piece. The only problem is that it is now 2015, and everybody's moving to Websocket-based backends. Without WS support, new web frameworks are quite doomed.
- chii 11y agoWeb sockets isn't the be all and end all tech. There's still a place for server rendered, simple pages. Not every web app needs to be a single page app.
- vdaniuk 11y agoThat's not what they said. Not every web app needs to be a single page app, that's true but it's a non sequitur. The point was that if a new framework aims to capture enough attention and traction to be a sustainable alternative to the incumbents it has to support websocket .
- mschuster91 11y agoWhere are websockets truly needed for functionality of any application? The only part I think where websockets enable truly new functionality is displaying of live data and push notifications.
- vdaniuk 11y agoThe subject of the discussion is required features of frameworks, not apps.
- mschuster91 11y agoWhy does a framework have to carry features only needed in edge cases? Feature bloat/mission creep sucks.
- vdaniuk 11y ago>Why does a framework have to carry features only needed in edge cases? Because most apps are being built in the conditions of uncertainty and the development team doesn't know if the edge case will become a business requirement. >Feature bloat/mission creep sucks. Unqualified, this statement is nothing more than a thought terminating cliche. Whatever constitutes "bloat" depends on the context and preferences of a decision maker.
- coldtea 11y ago>Whatever constitutes "bloat" depends on the context and preferences of a decision maker. Same goes for whatever constitutes a necessity. I seriously challenge the idea that "websockets" are a must have. Case in point, their lack haven't prevented tons of PHP, Ruby, Python, etc frameworks (all the tons of them that are not async/event based and can't handle websockets well if at all), from succeeding. Heck, 1/4 of the web is based on Wordpress (including players like CNN, Forbes, Sony, and NYT blogs) and that doesn't even touch websockets, not to mention not being a proper CMS/framework in lots of other ways.
- vdaniuk 11y ago>prevented tons of PHP, Ruby, Python,etc frameworks Django is adding websockets support using the $150K grant from Mozilla. Rails is adding websockets support in the next version with ActionCable. Phoenix and Play frameworks have great support for websockets. Websockets are an integral part of node ecosystem. Your websockets "challenge" is not based on facts.
- coldtea 11y ago>Django is adding websockets support using the $150K grant from Mozilla. Rails is adding websockets support in the next version with ActionCable. Note the future tense. By which time Rapidoid might or might not have them as well. >Your websockets "challenge" is not based on facts. No challenge at all. Just plain old reality. Most successful frameworks don't support websockets at the moment, and are still widely used. The fact that Node and some Java frameworks do (as does Python with Tornado and co) doesn't change that fact. Note also how I never said there don't exist frameworks that DO support websockets, so I don't get why you mention these to me.
- smt88 11y agoI wonder if websockets could be used to speed up non-live apps by decreasing overhead. Or, rather, would it be worthwhile?
- atemerev 11y agoFor me, it is. I get nearly instantaneous reaction times for UI events, even where round-trip to server is involved (WS session is already created, so no duplicated headers, etc.) Additionally, especially for mobile apps, if connection is dropped, it is immediately detectable and it can go to offline mode right away.
- smt88 11y agoTo clarify, are you talking about an app that does not have any real-time data? The part about knowing when the connection has dropped is actually really interesting...
- paulddraper 11y agonavigator.onLine
- creshal 11y agoThat sounds like a hammer in search of nails.
- smt88 11y agoThat's exactly what it is. The obvious nail for websockets is real-time data. I'm curious to know if there are other nails.
- Kiro 11y agoShould you use WS even if you don't need to push data to the client in real-time?
- atemerev 11y agoFor webapps, certainly. You'd get much responsive UI, as there is much less overhead in responding to events, which improves end-user experience. Public APIs should stay REST, perhaps.
- patates 11y agoI don't see any negative aspects of exposing the same REST API through WebSockets internally. Public API (if exists) doesn't need to change, private API loses the redundant transfer of headers and cookies.
- bcg1 11y agoSometimes it makes sense to ship in 2015 and add shiny features in 2016.
- atemerev 11y agoYes, of course.
- coldtea 11y ago>everybody's moving to Websocket-based backends You'd really be surprised. Not everybody moves or even has a use case for a websocket-based backend.
- alphadevx 11y agoLooks nice, reminds me of Jersey with the annotations but seems to offer more functionality. Good work!
- nikolche 11y agoThanks! :)
- MrBuddyCasino 11y agoNot that speed matters a lot, but it seems they managed to create a new server that is nearly as fast as the fastest C++ server on the techempower benchmarks (https://www.techempower.com/benchmarks/#section=data-r11&hw=peak&test=plaintext https://www.techempower.com/benchmarks/#section=data-r11&hw=...): *The low-level HTTP API provides access to the extremely fast Rapidoid HTTP server implemented from scratch on top of Java NIO.* Thats quite an achievement, considering that Netty is very well optimized. Maybe the off-heap output buffer gives it that edge?
- betimsl 11y agoHow the hell did they manage to do this?
- bottled_poe 11y agoBy not doing much else?
- betimsl 11y agoWhat do you mean by "not doing much else"? I take netty as benchmark when comes to Java and this is MUCH faster.
- coldtea 11y agoHow did they manage to write a fast optimized web server? Lots of people have done so, if you have the skills and determination. It also helps if you focus on that, instead of completeness, like Netty probably does.
- logicchains 11y ago>Maybe the off-heap output buffer gives it that edge? Is this because it allows the GC to be avoided, or because it allows value types to be emulated?
- zapov 11y agoToo bad they didnt use DSL JSON instead of Jackson for JSON test. They would probably edge top C ones then.
- kornakiewicz 11y agoNeat! Rapidoid reminds me a little bit the Spark Framework (not Apache Spark, very unlucky name, though) which I use for fast prototyping and services. http://sparkjava.com/ http://sparkjava.com/
- jermo 11y agoAnd there are others like Ratpack.io, Vert.x and JFry
- reactor 11y agohttp://pippo.ro http://pippo.ro as well.
- electrotype 11y agoAlso : http://jooby.org/ http://jooby.org/ http://www.ninjaframework.org/ http://www.ninjaframework.org/ But the leader of the recent Java web frameworks really seem to be Vert.x ( http://vertx.io/ http://vertx.io/ ) which I have started to use recently and like a lot so far.
- jermo 11y agoWhich is not that surprising since Vert.x is more than just a web framework. It also let's you build distributed applications and to scale your web app horizontally.
- sgt 11y agoOn another note, JAX-RS (a Java API for RESTful API's) is also fairly no-bullshit. It is also mature by now, and is supported by about a dozen implementations, including Jersey, WebLogic and JBoss.
- kehrlann 11y agoToo bad it doesn't have swagger integration (yet). Love the easy, clean API - it's great for a reasonably sized project.
- nikolche 11y agoThanks, I created an issue for Swagger integration: https://github.com/rapidoid/rapidoid/issues/39 https://github.com/rapidoid/rapidoid/issues/39
- djsumdog 11y agoWould be interesting to try it in Scala
- fasouto 11y agoInteresting framework! looking for a side project just to try it. Github link https://github.com/rapidoid/rapidoid https://github.com/rapidoid/rapidoid
- nikolche 11y agoThanks, Fabio! :)
- bcg1 11y agoExcellent work. Author truly deserves a lot of credit.
- nikolche 11y agoThanks a lot!
- deleted 11y ago[deleted]
- mark_l_watson 11y agoThis looks awesome! I used to use Spark for quick Java web apps, but I will (probably) try Rapidoid next time. That said, I have been using mostly Sinatra (Ruby) and Yesod (Haskell) recently but Rapidoid looks like a winner for Java-land. I am surprised that I hadn't heard of Rapidoid before. +1 to HN
- skanga 11y agoLooks cool. But how do you execute one of those one-liners?
- nikolche 11y agoThanks! You can try adding the one-liners in your "main" method. (You will need Java 8 and rapidoid-http-fast added as dependency).
- skanga 11y agoGreat - Got it to work. This should be documented on your site. You also forgot to mention what I need to import in order to have the "On" object. Maybe you can include something like this template on your getting started page. import org.rapidoid.http.fast.*; // wget https://repo.maven.apache.org/maven2/org/rapidoid/rapidoid-http-fast/5.0.7/rapidoid-http-fast-5.0.7.jar public class App { public static void main (String[] args) { On.get ("/size").json ("msg", msg -> msg.length ()); } } Also needed would be a sample pom.xml file. I had a problem with java compiler version being older and unable to complie lambdas. My sample pom.xml (feel free to use it if you like) is: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.microservices.app</groupId> <artifactId>rest-app</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>rest-app</name> <url>http://maven.apache.org</url> <properties> <java.version>1.8</java.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>assemble-all</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.rapidoid</groupId> <artifactId>rapidoid-web</artifactId> <version>5.0.5</version> </dependency> </dependencies> </project> Then I can run the test service using: java -cp target/rest-app-1.0-SNAPSHOT-jar-with-dependencies.jar App
- betimsl 11y agoThe performance and elegance of this is breathtaking but I couldn't find if it has hot reloading built in. If you have to recompile every time you change something, you're going to have a baaad time.
- nikolche 11y agoHot reloading is not currently available, but it is almost finished. I added https://github.com/rapidoid/rapidoid/issues/38 https://github.com/rapidoid/rapidoid/issues/38