
Rapidoid – No-Bullshit Web Framework for Java - nikolay
http://www.rapidoid.org/
======
MrBuddyCasino
Not 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=...](https://www.techempower.com/benchmarks/#section=data-r11&hw=peak&test=plaintext)):

    
    
      *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?

~~~
nikolche
Hi, I am the author of Rapidoid, thanks!

The performance optimization is based on: \- using off-heap input and output
buffers, \- minimizing the number of objects that are created when parsing the
input and generating the output, \- using object pools to reuse the objects
that must be created, \- using thread-local helper data structures on the I/O
threads to avoid synchronization and object instantiation.

~~~
betimsl
What happens when you have a long database query running? Is it async (which
is a bit impossible with JDBC) but does it block one of the threads in worker
pool?

------
kornakiewicz
Neat!

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/)

~~~
electrotype
Also :

[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
Which 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.

------
mark_l_watson
This 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

------
habitue
Ha, I read "Javascript" at first. I guess my brain has a pretty strong pattern
for "New web framework for X" at this point

------
sgt
On 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
Too bad it doesn't have swagger integration (yet).

Love the easy, clean API - it's great for a reasonably sized project.

~~~
nikolche
Thanks, I created an issue for Swagger integration:
[https://github.com/rapidoid/rapidoid/issues/39](https://github.com/rapidoid/rapidoid/issues/39)

------
djsumdog
Would be interesting to try it in Scala

------
alphadevx
Looks nice, reminds me of Jersey with the annotations but seems to offer more
functionality. Good work!

~~~
nikolche
Thanks! :)

------
betimsl
The 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
Hot 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)

------
fasouto
Interesting framework! looking for a side project just to try it.

Github link
[https://github.com/rapidoid/rapidoid](https://github.com/rapidoid/rapidoid)

~~~
nikolche
Thanks, Fabio! :)

------
bcg1
Excellent work. Author truly deserves a lot of credit.

~~~
nikolche
Thanks a lot!

------
skanga
Looks cool. But how do you execute one of those one-liners?

~~~
nikolche
Thanks! You can try adding the one-liners in your "main" method. (You will
need Java 8 and rapidoid-http-fast added as dependency).

~~~
skanga
Great - 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

~~~
nikolche
Many thanks for this detailed feedback and example.

I totally agree a tutorial like this is needed, and I am going to add such
documentation soon...

------
atemerev
An 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.

~~~
Kiro
Should you use WS even if you don't need to push data to the client in real-
time?

~~~
patates
I 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.

