• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Full stack framework based on Spring: why not?

 
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
INTRODUCTION (skip to the Spring section if you are not willing to read about my past experience)
The web offers dozens of full stack web application frameworks for any language. In the last 10 years, after Ruby on Rails came out, all of them evolved into something which greatly boosts developer productivity, like Symfony and Laravel for the PHP community, Play and Grails for the JVM community, and so on.

Most of them are based on interpreted languages, dynamically typed. In the last decade software the typical web developer shifted to languages like Ruby, Python and JavaScript, feeling that he has a huge productivity boost since the bad days, when old programming languages like Java and C were used and web frameworks took hours to configure just to get up and running.

But what I've learned in the past two years is that the initial productivity gain NEVER pays off on the long term. Whatever I and my team did in dynamically typed languages, like PHP, quickly turned into a nightmare, in which we spent more time debugging and writing tests than adding functionality to the system. We had this big project which had to be completed in a short time, we decided to use Symfony because we knew it well enough, and had many years of experience on PHP. We thought it was the right choice... at first we were incredibly happy because it already had bundles for everything we needed: a whole bundle for managing user accounts, with hashed and salted password, token via mail, password reset, etc, a very nice bundle for paypal payments, many javascript bundles, excellent support for PHPUnit and so on. After the few weeks, we realized that we were loosing enormous amounts of time just waiting for the ridiculous response times for Symfony to handle requests in dev mode, or with errors that could be found ad compile time if it wasn't a dynamic language, and debugging. Even functional running tests was a tremendous pain, since the response times were so slow. On the long term, we lost money on the project, because we thought it could be done in 3 months and it took 6!

The same thing happened to me when using Grails: I was up and running in no time. In a few hours, I had my entities, my database structure automatically generated, scaffolded pages. But after a few days of development, I found myself losing precious time in horrendous stack traces and bugs which required me to reboot Grails, which takes an exaggerate amount of time, really.

On the other side, I had a project done in Java with raw servlets and jdbc, and on top a component-based MVC framework. I always thought I was improductive: building a form, validating data, making database queries was such a long (and verbose) task to accomplish! But on the long run, this was the most succesful project for my company. Only 30% of the app is tested, nonetheless we never found more than a few bugs a month. There is absolutely no javascript, the whole view rending and interaction is compiled in Java. All the communication between the view and the backend is compiled. Database performance is AMAZING, we put dozens of deployments of the same app for different clients on just one cloud server, which also holds the mysql database and costs just 60 € / month (approx 70$).

Spring time!
After learning this lesson, I decided that I would do all my development in Java. So I started learning the Spring framework. At that point, I started to understand why everybody escaped from the Java world. It took me days just to know how the framework worked, and how to configure it. It took me hours of doc-reading to find how to do my stuff with annotations instead of XML. It took me hours to decide which templating system to use, and after trying to figure out how to use Json in my controllers, I just said "oh f*** you" and manually used the Jackson library. When I tried Spring Boot and Spring Data it seemed so cool, but again, you get up and running in 5 minutes but then you have spend even more hours on documentation and learning, to be able to configure and customize what you need, or to get Spring Data up and running with anything which isn't the default in memory db entity manager.

I was a pain. It's not difficult, and I appreciated how powerful and customizable Spring is. But it's so unproductive when you have to learn how to use it! I was never able to start a project with Spring, because I couldn't afford losing so much time just to start the project. I had to start sacrificing my free time.

So I thought to myself: why has nobody ever done a full-stack framework based on Spring? Sure, we have Grails, but when a software takes 20+ seconds just to start, and requires 640+ M of memory, trust me, this is a pretty bad sign. It's not only about performance: it's just that complexity is dangerous: what is under the hood is so complex that it's very likely to be difficult to maintain, to understand, to customize and to debug. Same goes for the Play! Framework: when I ran it for the first time I was shocked by how many dependencies it was loading. When I say the memory footprint, again, I said: "f*** you" (it was 700M).

So, again, why is there no fullstack framework based on Spring? Take the example of the Symfony PHP framework: let's forget for a moment the bad performance in dev mode and the dynamically typed language... it's INCREDIBLE. It has dependency injection, it's highly customizable, very easy yml or annotation or php configuration, and the ORM and templating engines chosen as default are the best of the best for PHP environments. It has bundles for EVERYTHING. You never have to re-implement something already done by somebody else in the PHP community.

Wouldn't it be great to have a full stack framework based on Spring? Something which ships Spring pre-configured for Hibernate and, let's say, Freemarker or Thymeleaf, with pre-configured environments like test, dev and prod, out of the box support for Json in controllers, out of the box support for externalized configuration, mailing, user account and session management, in-database sesssions, helpers for Jquery/ajax, Form components with CSRF, Scaffolding, CLI for cache management and database schema upgrade and entity creation, and so on. And most importantly, the possibility of easily creating reusable bundles or plugins, which is quite easy when a standard Data layer and templating engine is chosen.

Sure, you can customize Spring as you wish, use Spring Boot or Roo, whatever. But that's another story. What I dream of is a real, fullstack, standardized Spring distribution. A beautiful, lightweight, productive framework with a small and easy documentation, based on the best Java technologies and best practices, 100% Java with our beloved compile-time safety, autocomplete in IDE, and not too much reflection / runtime magic. What do you think about it? Yes, such frameworks already exist (take a look at Ninja, it's very cute), but having something Spring-based would make it enterprise-ready from top to bottom.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spring is a fullstack framework. However it chooses flexibility over simplicity. It is designed to provide a layer of abstraction over various Java technologies. Since you can do the same thing in Java many different ways, Spring allows you to choose the underlying tech and switch it if needed.

It's really meant for big companies. Usually the way big companies are laid out is that you have this bunch of fancy pants architects. Then you have an army of devs, some of whom are sharp, but most are average. the architects are asked to pick a technology. Their concerns are, find technology that supports the current needs, integerates with tech that is already purchased, is flexible enough for future needs, has community support, has enough training resources. Spring checks all those boxes. Also, it allows them to create a template that shows the approach that they want to take, and the devs can replicate what they have done 100 times over.
Since spring abstracts out the underlying technology, and is extensible to support new technology, the architects have the peace of mind that going from hibernate to eclipselink won't be a pain.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you seen http://start.spring.io/ ? It makes it very easy to start a Spring Boot project, and you can include what you need by selecting the right check boxes. Spring Data makes it very easy to add database connectivity. You can include Thymeleaf or one of the other supported templating engines. With Spring CLI you can write your controllers in Groovy which makes it easy to quickly build prototypes.

Ofcourse you'll have to learn how to use Java and Spring, and you'll have to understand at least the concepts of Spring Web MVC, but that's the same as with any other framework. Someday you also had to learn PHP and the concepts of the Symphony framework.
 
Martin Bechtle
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:Have you seen http://start.spring.io/ ? It makes it very easy to start a Spring Boot project, and you can include what you need by selecting the right check boxes. Spring Data makes it very easy to add database connectivity. You can include Thymeleaf or one of the other supported templating engines. With Spring CLI you can write your controllers in Groovy which makes it easy to quickly build prototypes.

Ofcourse you'll have to learn how to use Java and Spring, and you'll have to understand at least the concepts of Spring Web MVC, but that's the same as with any other framework. Someday you also had to learn PHP and the concepts of the Symphony framework.



Yes, it's true. But it's not only about the quick start of a project. It's about standardization: when you have a full stack framework, you typically have just one ORM, one tempating engine, one logging system etc. Everything is standardized: thus the documentation is clearer, and it's possible to create plugins and extensions easily. Think of Grails: there are plugins for almost anything. The same isn't true for Spring, even if it exists since much more time and is more widely used.
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you have a framework that gives you one option for everything, then it will naturally be well suited for a narrow class of applications, and if you try to do anything different, you will be fighting against the framework. You have already experienced this with other frameworks. You have loss in productivity wheN you step outside the norm.

Spring avoids this pitfall by supporting literally everything under the sun in the Java ecosystem. The drawback is that you have a bigger learning curve.

Perhaps you might want to look at ADF. Its pretty neat and easy to learn. The drawback is your UI will look like Oracle wants it to.
 
Martin Bechtle
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:if you have a framework that gives you one option for everything, then it will naturally be well suited for a narrow class of applications, and if you try to do anything different, you will be fighting against the framework. You have already experienced this with other frameworks. You have loss in productivity wheN you step outside the norm.



Yes, that's exactly the point. Having a Spring distribution with a narrower target! But not that narrow... Let's suppose that somebody builds a maven archetype like this:
1- Spring Framework
2- Preconfigured data layer with Hibernate and a configuration file in which you pass db address, user and password for three different environments: prod, test, dev
3- Mailing system, also configurable for prod, test and dev
4- Logging system configurable for prod, test and dev
5- Spring security included
6- Entities, services and controllers with base functionality for user and session management (password hashing, salting, account activation via token, password recovery), integrated with Spring Security
7- Out of the box support for json in Controller params
8- Form helper
9- Ajax helper

Then you only have to plug your favourite templating engine or use the standard jsp. This kind of standard setup would satisfy, in my opinion, the needs of at least 80% of all new projects. And that's exactly why full stack frameworks exist! The only difference would be that this is Spring, so you are basically free to do anything, and you have plenty of documentation to dig into the core of the system. Want to use jdbc instead of Hibernate? No prob. Want to plug in your favourite tempating engine? Go on! Want to use multiple data sources? Why not. You can do everything you wish, without fighting against the framework.

But for most of the cases, this standard setup would be more than enough and can get you up and running in no time. Especially who has a solid background with JPA and JSP, could virtually use the framework productively after just 15 minutes of doc-reading.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Bechtle wrote:Yes, it's true. But it's not only about the quick start of a project. It's about standardization: when you have a full stack framework, you typically have just one ORM, one tempating engine, one logging system etc. Everything is standardized: thus the documentation is clearer, and it's possible to create plugins and extensions easily. Think of Grails: there are plugins for almost anything. The same isn't true for Spring, even if it exists since much more time and is more widely used.


What's wrong with having choices? And there are de-facto standards and defaults.

ORM: You'll use JPA as the API, and then it doesn't matter what implementation you use. Most people will use Hibernate, which is the default choice for Spring Boot.
Templating engine: Choose whatever you like. Thymeleaf seems to become more and more popular.
Logging system: Use the standard SLF4J API, then you can plug-in whatever implementation you want.
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Bechtle wrote:
. This kind of standard setup would satisfy, in my opinion, the needs of at least 80% of all new projects.



That setup might satisfy 80% of your projects, but it barely satisfies 20% of my projects. There's nothing stopping you from creating your own stack from Spring's offerings and training your developers on your choices. The advantage in picking Spring is that when the needs of your stack change, you will have so,etching else in Spring that you could borrow or extend to fit your needs.
 
Martin Bechtle
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:What's wrong with having choices? And there are de-facto standards and defaults.



Well, there are some side effects... For example each time I read about a feature on the Spring documentation, by default it always explains how to do it in XML config. I happen to love JavaConfig. And I must say that it's not always easy to find good documentation on how do to things this way.

Jayesh A Lalwani wrote:

Martin Bechtle wrote:
. This kind of standard setup would satisfy, in my opinion, the needs of at least 80% of all new projects.



That setup might satisfy 80% of your projects, but it barely satisfies 20% of my projects. There's nothing stopping you from creating your own stack from Spring's offerings and training your developers on your choices. The advantage in picking Spring is that when the needs of your stack change, you will have so,etching else in Spring that you could borrow or extend to fit your needs.



Every framework in the world satifies a small percentage of our needs. Be it Rails, Grails, Symfony, Zend, Django, Play or nodeJs. So, again, it's strange that nobody distributes an opinionated stack of the Spring framework. But basically you are right... if a developer is doing repetitive projects which all need the same kind of Spring setup, it's quite easy to create your own stack and make it quickly reusable.
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Martin,

You might want to look at Spring Boot. It's Spring's attempt at getting projects up and running with minimum fuss. I don't know if it's ready for prime time yet. However, it is interesting
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Bechtle wrote:Every framework in the world satifies a small percentage of our needs. Be it Rails, Grails, Symfony, Zend, Django, Play or nodeJs. So, again, it's strange that nobody distributes an opinionated stack of the Spring framework.


But that's exactly what Spring Boot is:

Spring Boot homepage wrote:Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.


 
Martin Bechtle
Ranch Hand
Posts: 46
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, and no... Spring Boot gives you opinionated, sensible defaults to quickly bootstrap your Spring stack with technologies of your choice. And it's great! I'm using it since a few days and I love it!
But on the other side, frameworks like Grails give you a standardized, opinionated full-stack framework, with only one technology for each layer. This makes it possible for the community to write plugins for almost anything, which usually makes you very productive in certain situations. When using Ruby on Rails or Symfony for example, you hardly ever face something which isn't already solved in some plugin. In my last symfony project I had pre-made bundles for anything, which avoided me to do such stuff from scratch: a CMS bundle, a paypal bundle, a bundle for easy integration of php code with js modal confirmation windows, a bundle for supporting i18n of entities in the database, and so on. My team just had to glue everything together. But still, it was so unefficient to program on a slow and dynamic language. Would be wonderful to have all these bundles in the Java or Spring community.
 
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic