I'm looking for some advice/feedback about using different languages in a layered architecture. Right now the architecture in question is an all java stack (db, middle tier, and web tier) using Spring to tie everything together. We've been tossing around the idea of using Ruby on Rails for the web tier, but I'd like to know if anyone has done this before (maybe with different languages/technologies). The idea behind switching to RoR is to increase development speed in the web tier, however my initial analysis is that it will also decrease development speed in the middle tier.
Some of the questions I'm trying to get data points on are:
Have any small development teams actually used a hybrid language approach in a similar architecture?
Why did you use that approach? What worked well and what didn't?
How would you handle interfaces and models (maybe use something like Google protocol buffers or Apache Thrift)?
Are there any other benefits or pitfalls to using an approach like this?
While I have no experience of RoR, we have taken a similar approach with Django as a front end layer, where we would use java based services for high volume transaction processing back ends.
We define the DB in a django model, develop the web front end with django views/ jquery and obviously get a for free admin site.
On the java side we run a hibernate reverse engineering task to generate DB access classes for the java code. Where required we use home crafted JSON over AMQP RPC mechanism to communicate between python and java components.
There are ups and downs to this approach. For us as we were not using any big java frameworks, it gave us access to quick / lightweight web front end to our solution as well as the ease of modelling our database using the Django model format (which I like a lot).
On the down side we did encounter some tricky stuff with hibernate reverse engineering configuration (which is complex if you are doing anything that is not bog-standard - especially in relation to some Django ManyToMany relations).
I notice you mention that you already have a Spring based architecture with a web tier. I'm no expert here but that may present you with opportunities worth exploring such as groovy/grails or the SpringMVC which in version 3 claims to be much simplified and faster to develop against. This may give you the wins you need.
A compromise might be to look at some RoR inspired Java tools like Rife.
Bottom line is that you will have to make the call in light of what your own application requirements and team capabilities are. It worked for us and was I think the correct decision for us but if your team is already tooled up with Java & Spring skills then Spring 3 might be the way to go (but ask a Spring expert about that :-) )
Rob
This presentation will probably be interesting to you: Rails on Spring - Using JRuby as the Secret Sauce
Related
I have got an architecture to be chosen based on my requirement assignment.
So, the requirement is to build a web application for the common man , similar to book my show application.
Also, the application should be available via intranet for admin users to manage requests.
Also, it is necessary that i use open source technologies to reduce cost, unless absolutely necessary.
Keeping all these points in mind, i would say i would need the following
a) I would go for a n tier architecture.
b) For presentation tier:- can go with JSP/servlets+JSTL or should i go with JSF
c) For business tier:- Spring MVC or EJB3.0?
d) DAO:- Hibernate/JDBC as DAO layer.
e) Database:- SQL server or Oracle 10g.
Could you please pore in your points so that it can guide me further to go with the right technology and architecture?
Thanks for your expert help in advance.
I am not going to tell you what to choose, but give you some advices how.
First of all, Just want to slightly change your considerations:
b) You should include Spring MVC into this point, because it is abstraction layer on top of servlets and can be easily combined with JSP. BTW Spring guys nowadays prefer Thymeleaf templating engine, so maybe something to consider also. You also definitely want to go for security framework like Spring Security (not sure how it cooperates with a Java EE stack)
c) You probably want to consider Spring IoC (Spring Core) vs EJB3.0. There is also Google Guice framework.
I would suggest you to build your decisions on these factors
What is your and your team expertise with certain technologies
What is your OPs team experience with (Full Java EE app servers or lightweight servlet containers like Tomcat or Jetty)
Is your project going to be bigger monolith (look at advantages of full Java EE app servers) or set of micro-services (look at Spring Boot and it's advantages, also look at Microservices architecture pattern advantages and also PITFALLS -> because it is very popular architectural pattern nowadays, but can lead to various problems like performance problems or production environment complexity)
Are you planning to use Spring related projects (e.g. Spring Data family for connection to different Social networks)
Do you think you'll need to use cashing on app server (consider Hibernate with second level cache)
JDBC vs Hibernate is huge architectural decision, so better read about pros and cons deeply. If you choose JDBC, you probably want to go for Spring JDBC and most importantly some querying framework like JOOQ or QueryDSL.
If you'll go for Hibernate / JOOQ / QueryDsl, you should be safe to choose any SQL DB. Because these frameworks abstracts differences if you avoid using custom features of certain vendor. Said that it is also crucial to take a look at your OPs and admins expertise when choosing DB. If you want to save money on licenses you probably want to take a look at PostgreSQL (enterprise grade open-source DB)
Do you have some enterprise level architects around to consult these decisions with. Clarify early if your app needs to be integrated with some wider enterprise environment. In this case you probably want to take a look at Spring Integration or Apache Camel.
Are you going to have some background regular processing that is not triggered by user requests? Take a look at Spring Batch / Java EE 7 Batch spec.
MOST IMPORTANTLY DO SPEAK WITH YOUR TEAM ABOUT THESE DECISIONS TO INVOLVE SENIOR AND PASSIONATE TEAMMATES. You don't want to hear complaints later.
Don't be afraid to make final decisions. Lack of decision is MUCH WORSE than bad decision.
(I am Spring guy, so I apologize if this sound like your direction should be Spring stack. The Java EE stack definitely has alternatives for most Spring modules, so do your own deep research).
My first post here so request your indulgence. Let me try and answer your questions point by point:
n-tiers architecture - definitely - a UI / REST services / Data store
Presentation tier - I would recommend using an open source Javascript library like Prime NG. Gives you the ability to create great UIs coupled with the fact that they can cleanly call the REST services
Business tier - either Spring boot REST services or JEE 7 REST services. I would stay away from EJBs. Using REST will give you the ability to move to micro services tomorrow
DAO - Hands down JDBC or a very thin wrapper over JDBC for me. Hibernate in my opinion will only complicate things and ability to scale. A well designed JDBC implementation will outperform Hibernate plus will also provide you with an ability to separate optimization concerns
Database - if cost is not a concern Oracle 10G. No comparison to Oracle when it comes to RDBMSs. Note that these are not open source. If you want to go open source Postgresql / MySQL could also be considered. Here I would also recommend you to look at noSQL options like MongoDB / Couchbase
The things I would stay away from are too much of annotation based configuration (do what is really required but not just for the heck of it) or a straight jump into micro services carried to the extreme which may lead to a very difficult production environment to run and manage. Do do make sure that your code reads like a story and tells the business logic rather than only looking like a technology specification. All the best.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm planning on writing a simple web application that will be used by lots of users (as complicated as a simple bookmarking app) and I'm trying to decide which framework/language to use.
I'm very experienced with Spring/Hibernate and Java in general but new to both Grails and RoR (and Spring ROO).
The only reason I'm considering RoR is because Java hosting is MUCH more expensive than RoR hosting (which is supported by almost any hosting vendor for 5$ per month).
Assuming the price wasn't an issue, which one of the frameworks/languages mentioned above would you recommend for a Java developer (who knows how to configure Spring/Hibernate etc.)?
I'm afraid that by using RoR I won't be able to easily support many users who are using the website at the same time.
thanks
First you can have a look to these related questions :
Rails or Grails?
Learning Ruby on Rails any good for Grails?
https://stackoverflow.com/questions/1283935/what-technology-asp-php-joomla-rails-grails-for-a-website-from-scratch
Is Grails worth it?
Is Grails (now) worth it?
Now, I will try to answer you according to your requirements you have communicated and the information I have gathered from the internet and my own experience.
Ruby on Rails
I do not advice you to start with RoR because you are a Java developer and you will have to learn a new language (Ruby) and a new environment (Rails). The hosting issue is not a real issue. You can have a VPS hosting plan for $10 (www.enjoyvps.com) perfectly suited for small grails app. If you application needs more memory, you might need to add another 10 Bucks.
If you hosting is really THE critical factor, go with Python/Django or PHP/Kohanna (a very good MVC framework). Otherwise, according to your background, Grails is more suited for you than Rails.
Grails
Few months ago, I had the same dilemma as yours and I decided to have my way with Grails. Why?
Because it's cool !! I mean, community is very helpful and dynamic, Groovy is a pleasure to develop with (be careful : thereafter , there are good chances that you will loath Java). Also, it is a state-of-the-art framework based on very-well established technologies (Hibernate, Spring, Java) and hence, it can improve considerably your market value as a developer. Grails is my favorite
Spring Roo
Roo is Grails for Java. So if you don't want to learn Groovy and if you need pure Java application (that will always run faster than a Groovy-based app), go with it. The community is smaller than Grails but the project is supported by SpringSource who is quite active in the community. I think that if you want to go as fast as possible, this is the solution for you.
Spring Application
You should choose this option only if you don't like Spring Roo integrated technologies (Hibernate, JSP, Maven...) and you want Java absolutely. Otherwise, there is no interest (except for educational purposes) of spending hours of configuration and tuning when you can build sophisticated enterprise applications in a best-practice manner within minutes (with Rails, Roo or Grails).
Each of the options above will provide you enough performance for the application you want to build. A lot depends on best practices for website applications like good architecture design, correct usage of caching strategies and requests optimization...
My Bottom Line
If you have some time to spend for learning new concepts (Groovy, RAD...), go with Grails. If not, go with Roo. Forget about Spring App and Rails.
If hosting is THE issue, so go with Python/Django. You can deploy on GAE, it's free scalable, performant and you will deal with the same concepts as Rails or Grails.
I don't understand the obsession with runtime performance. Given your scenario your primary focus should be on your performance, as in your ability to get things done with the chosen technology.
You will get more done in a given period of time with Groovy than with Java any day. Often one line of Groovy code will equate to 10 lines of Java code etc etc
Very rarely will byte code execution time be your performance issue, most often its...
Bad algorithm implementation or design.
Bad DB design and / or queries
Taking to long to get things done and then having all sorts of commercial relationship issues because of it.
With web applications you are usually not performing lots of long running CPU bound operations. Most of your request / response time is spent in the wire (internet routing etc) and in the DB (executing queries).
Choose a technology that takes a load off your mind and one that frees you from writing mountains of boiler plate code, so that you can rather concentrate on designing and implementing good algorithms, DB's and queries etc etc
Id personally choose Grails.
I chose Roo over Grails and Rails at my company. Runtime performance, easy debugging, nice Eclipse integration (it's plain old Java after all), no "black magic" happening at runtime. In fact, there is no Roo runtime library needed to run a Roo app, just the library dependencies like Hibernate and AspectJ. You can look at the code that is generated so you know exactly what is going on. Also a biggie for me is that Google has chosen Roo as the preferred tool for creating GWT apps going forward and they are throwing their support behind it. I have been extremely impressed with Roo thus far, I think it will be the tool of choice in the near future.
Performance issues with RoR are going to be caused more by the $5 hosting plan than by the choice of language and framework. Consider Heroku for your hosting, as you can start cheap / free, and then scale up as needed.
For a simple bookmark app, however, Rails is probably overkill. Take a look at the Sinatra framework as well, as you weigh your options.
Have you looked at Gaelyk? http://gaelyk.appspot.com/
It's a lightweight Groovy framework for Google App Engine
I know this post is a bit old. It's 2012 now and Spring Roo just released version 1.2.2 3 months back.
I'm a Java developer & has just started an ambitious project that will see me launching a web application for wide adoption. I'm going through Spring Roo & is getting my hands dirty. My first impressions are nice, but when I read over the Internet about it being a good framework for fast prototyping and only for developing CRUD operations etc. I feel a bit demotivated to use it.
But I personally think that Spring Roo (SP) gets my project started with best practices already implemented with the choice of files created which I can use as template for custom use. Obviously, I'm not afraid to code. We will always have to code ourselves, I don't want any "magic".
I also tried to look around the RoR scene and is easily intimidated by the learning curve involved.
I don't see much traction in the Spring Roo community. Is there any specific reason for it?
Also are there any better alternatives? I'm a bit confused over my decision of finalizing a framework that is both robust and scalable in future. I don't want to be a position where Twitter is now where 2 years worth of RoR code makes them re-think their choice of RoR. Is Spring Roo the best bet for me?
I work in a medium to small team ( 10 people ) developing and supporting several web enterprise applications.
We have a dozen of them built with a house-made framework with asp-classic working against ms-sql server.
We are evaluating the migration to a new development stack.
We'd like it to be open (free) and simple.
I've been looking around the java web frameworks, but all of them seem to be extremely overbloated for our needs (with the possible exception of http://www.playframework.org/, which I couldn't study yet...)
We are thinking about porting our own framework to this new stack, rather than adopting a whole new stack that we are unaware of ...
so far now, we though about the following possibilities
plain java - jsp - jsf
groovy - gsp (no grails at all)
jruby (no rails at all)
we feel really comfortable working with dynamic languages (well, as dynamic as classic asp can be) and with a lean and understandable framework...
I see no small and simple web frameworks for java, like there are for php or ruby...
I really like groovy, but I see no web implementations outside of grails... Besides the language documentation doesn't seem to be quite complete (I might be looking in the wrong place, perhaps)
php could be an option, but I think it would be hard to advocate for it in my current work...
any other option, advice, pros and cons?
thanks a lot
--
edit
some related link Can anyone recommend a simple Java web-app framework?
I'd suggest you take another look at Grails. It does use hibernate and spring under the covers, but for most situations, you don't need to know the details of those frameworks. There's a large community and lots of documentation/blogs/mailing lists for support, as well as a thriving plugin community with over 300 plugins solving pretty much any need.
If you're still put off by grails, you could look into the play framework. I don't have any experience with it, but there has been some traffic recently around it on hacker news and the like. I know it uses groovy for the templating language.
I cannot recommend anything, but strongly recommend that you consider these things:
Rapid development. Basically you want to save a page file, and reload it in the browser. Instantly! It can be done, do not settle for long deployment times.
Plain, readable text files!
Convention coding instead of explicit coding - big XML files will eventually drive one or more developers insane. The less, the better.
Good tool support (just having syntax coloring may be a big help)
Consider the long term support of your choice. You are basically remarrying with your software - will it still be maintained in 10 years? By whom? Will you have alternatives (JSR's are great - look at the amount of servlet engines)?
And WHEN you choose - get the source code for it, and ensure that it builds correctly. It will never be easier than now, and some day you WILL need to fix something inside. On short notice! (You may even consider allocating resources for donating documentation/patches/time to the open source project you are building your business on).
EDIT: A few more things:
You want to be able to verify things at compile time. One of the things that make it possible to build cathedrals in Java is that the static typechecking prevents a lot of nasty runtime errors. "Oh, THAT method? Well, it's not here, sorry. Boom!"
You want good error reporting. Built in! Try throwing a NullPointerException deep, deep down and see what 1) the user and 2) the developer is told about it. Anything that requires going to a log file to get the details WILL cause calls at 3 AM eventually.
Look into scalability from the start. Any non-trivial customer will need to and the world goes to multicores, so you might as well think about it already now. What will you do when all the magic pixie performance dust has been used and it just isn't enough: The application requires more than a single box.
And read this: http://www.pragprog.com/titles/mnee/release-it
You're forgetting about the other major player in this field: the LAMP stack (linux, Apache, MySQL and mod_perl). All components are free, there are many books available on LAMP development and each of these components, and there are vast numbers of libraries and components already available.
Apache: the Definitive Guide
Learning Perl: by SO's brian d foy
Practical mod_perl
If you are afraid of Grails and need Java, try Stripes and read the excellent Stripes book (http://www.stripesbook.com/blog/). You can buy the eBook pdf for $23. The book covers the framework in amazing detail. Stripes is a very strong, lightweight MVC framework that deals with all the common problems of web development (templates, url mapping, form validation, security, internationalization, testing) but it won't automagically create the database layer for you unless you want it to by using Stripernate. You can also use Groovy with it. You can use it standalone or with Spring.
I've had great success in simple web projects using Spring MVC with JSTL JSPs. Spring MVC is a framework that can be kept pretty darn simple (1 additional XML file used for configuration). You can eschew all the fancy options and just specify a set of JSPs that you want to associate with view names, then forward to those views by specifying their names in the controller.
Spring MVC can also easily scale up and be as complex as you need, letting you switch from JSTL to JSTL with Tiles, or Struts, or JSF, or Wicket. It can also handle complex web flows using the Spring Web Flow project. But for most projects I just keep it simple -- build a JSTL JSP, create a controller that provides the objects that JSP needs, and associate them by having the controller return that view. Once you get the project set up and you're familiar with the configuration, it takes maybe a couple minutes to wire a new page into place.
If you like Groovy but don't like Grails you could try Gaelyk, which is a lightweight Groovy framework. However, AFAIK you can only use Gaelyk if you're hosting the app on the Google App Engine
If your apps won't be hosted on GAE, and you really don't want to use Grails, another option is to use Groovlets, Groovy template servlet, GSPs.
However, personally I think it's a big mistake to dismiss Grails. It really is a great framework, and you can go a long way without knowing much about Spring and Hibernate. One of your complaints is a lack of Grails documentation. I think you must have been looking in the wrong place, because in addition to all the books available, there's a very extensive reference document and a lot of other documentation available on the website. Finally, there's a very active mailing list.
My platform of choice is JRuby - Rails (3) because of its very rich and powerful ecosystem, but mainly because:
* very easy to use
* many MANY libraries
* fast support via IRC
* deep documentation
You can also check out Scala + Lift Web Framework ( imho best static typed language, nice framework )
Alright, so I am a compsci college student who, being in college, has not branched out towards a certain specialization yet. I have been programming since I was a young teenager, certainly know my stuff - well versed in about eight different languages as well as compsci theory, etc. In addition, I have about four years of web programming (PHP mainly) behind me, having started freelance work in that area since web 2.0 became hot.
My summer job now as an intern of sorts is to write an application for an industrial, not software-related startup. This application will be used to manage production lines and logistics flow. I have chosen Java for my language because I don't want to shoot myself in the foot.
I am well-versed in the syntax of Java, in its data structures, language theory, and such, but I have absolutely no idea where to start. I can picture the program perfectly in my mind, I understand the problem clearly and got the solution's theory nailed. Namely, I have no idea what libraries to use, and am scared that they won't be well documented.
Here are some general outlines of what I'm going to make:
Two applications, one server and one
client (of which there will be many
copies).
The server and clients obviously will
communicate via (I don't know).
Both the server and the client
software will have GUIs.
The server software will have to
query a MySQL database.
The client software must be 'live' in
the sense that the GUI updates when a
change is made to the database. This
is one of the reasons why it can't be
a web application.
I'm not even sure if a framework is right for me or not. I've used MVC tons of times in my web freelance work, but I dont know how that will translate for desktop applications.
In short, I'm looking for the right libraries for the job, as well as advice on whether or not I should use a framework (and if so, which). Thanks.
This is a summer intern job? To be honest, this sounds more like a major project if you ask me. You say the start-up is not software related? Who came up with this idea? Do they have any idea of the (huge) scope that something like this might actually entail?
The business of software development is something quite different to language syntax and libraries. It's about requirements gathering, defining a spec, writing code, ensuring quality of that code, having it tested and so on. These are not things an intern should reasonably be expected to pick up. For something like this you should be under more experienced supervision, someone you can learn from, someone who has done this before.
That being said, unless there's a really good reason, I would probably do such a thing as a Website rather than a desktop app. Desktop apps are a lot more complicated in many ways. You need to code both a client and a server. Communication is a bit trickier. You have to worry about the issue of maintaining state in multiple applications, how to handle updates being pushed around and so on.
In short, it's a big job. Even a Web site is a big job but a lot of these issues go away. You could do this with Java. I've certainly coded my fair share of Java Websites but PHP might be a far simpler bet.
Also, desktop development on Java is, well, torture. Swing is (imho) tried and true but also incredibly painful to develop in. Other desktop libraries (eg Netbeans RCP, Eclipse SWT) are more modern but have other idiosyncrasies.
Desktop remoting libraries include things like Spring remoting, even Web services and other things like Burlap. For the server side, I'd be using either Tomcat or an application server (Glassfish is my preferred choice), servlets and Spring. Persistence can be done via Hibernate or Ibatis (or lots of other options).
But honestly, the desktop option is so much more complex than a Web-based one. You'd probably get a lot more done faster using PHP + jQuery + MySQL.
If you are doing this keep it as absolutely simple as possible. Try to define the absolute minimum you need to initially deliver and do that. Once someone has that they'll then have a better idea of what works for them and what doesn't. Basically it's easier to refine something that already exists vs define something that doesn't.
I recommend that you only build a web application. A web application can be 'live' in the sense you are describing it by using AJAX. It would be much easier to build just one thing. If you also want to have a rich client, then you need to build the UI in a technology you are not familiar with (like Swing or SWT) and design/implement the communication mechanism.
Have a look at Hibernate (ORM tool) and Spring (IoC framework). They have a somehow steep learning curve, but they will make your life easier at the long run. For the UI part perhaps JSF is easier for a beginner.
As a last note, I think you have an over-ambitious plan. What you are describing is not an easy project and requires expertise with a lot of technologies. Do not try to do everything in one shot.
Java Desktop 6 (JRE)
JDBC (built-in in any JRE)
MySQL JDBC drivers (freely downloadable)
for communication you have several choices: RMI (built-in) however this days I recommend
learning something like Java Web Services (JAX-RS)
Libraries?
JDBC for the database. You may want to look at ORM mechanisms like Hibernate
I would recommend the Apache Commons libraries for all your utility work (handling files, IO etc.). There's a lot of stuff there to save you reinventing the wheel.
A standard logging framework like Log4j will allow you to log in lots of different ways, filter your logs and plug into monitoring solutions easily.
You don't say whether browser-based solutions are acceptable for the client/server GUI, and that decision will drive a lot of the further architecture.
If you're looking at browser-based solutions, then I would advise a grounding in servlets regardless of any framework you ultimately choose (no doubt a lot will be recommended here).
By this stage it's getting to be a major project. Perhaps you need to concentrate on getting the fundamentals (client/server functionality) working, and worry about the GUI later. Otherwise it's a huge amount of work (and GUI work can draw an enormous amount of time).
Just one nitpicking:
Both the server and the client software will have GUIs.
I advice you to have a headless (in awt parlance) server, with an administration GUI, not a GUI-server.
Well this can go as wild as you can think of or you can go and do KISS.
If you would like something that is really simple (as in not using any frameworks):
* In the server side you can use RMI. This server side will use plain JDBC to connect to your MySQL database. But some said that this is kind of old, so if you want to get funky you can try JAX-RS which can return a JSON objects/XML to your client.
* Your client can be made using Swing (assuming you are developing desktop) or Servlet + JSP (assuming you are developing webapp) and connect to your server by calling the RMI objects/JSON objects/XML that is exposed by the server.
If you would like to get nasty which will help you in terms of code maintainability you might want to plug-in Spring + Hibernate into this application.
Good luck!
I have a rather large (80k loc) java desktop app that talks to a database. We're now looking at exposing some parts of the database via a web application, using the existing codebase and preferably not having to modify it.
I have good separation between the data access, business logic and presentation layers, but we haven't used enterprise java beans or anything like that (if that's important).
What's the best way forward? Which of the java web frameworks will be best suited to the problem? Learning curve isn't terribly important, since I haven't done any java development on the web...
To be true, it depends what you already have, and how well is the design of your current desktop application. You might not be able to use any or may be minimal of your existing code without modifying it, if its designed badly, and everything is tightly coupled.
Assuming that you are having a system with a good design, everything is de-coupled well enough. You can look into Stripes to make your presentation for the web, and use your existing data access and business code. I wish you all the luck.
Few other goodies to look into are, Groovy on Grail, Wicket.
I don't recommend anything like Seam and Spring they are more of a container and sophisticated large frameworks, which give you almost everything, solution for almost all of your problems. As you mentioned that you already have a complete system, and you just need to make a web interface to publish it for the web, these are not recommended, IMO.
JSF, is a good framework, but it might drive you nuts and has a big learning curve, according to few folks.
The two frameworks I would recommend would be Grails and Struts 2.
Grails comes with a whole bunch of stuff that it configures under the covers including Hibernate and Spring. It makes generating dynamic pages to send to the browser ridiculously easy. What you are probably going to need to do is set up controllers that call Grails services which reference your existing code as you probably don't want Grails managing your database interactions. The disadvantage with Grails is not so much that it is written in Groovy, which is easy to learn for Java programmers, but that the IDE support for Groovy is still maturing. Still if you want quick productivity this is the route to go down.
Struts 2 offers a clean command pattern framework implementation that talks to JSPs (or velocity or FreeMarker templates) on the front end. To use this you would configure actions to call your existing code. You may want to investigate adding Spring to the mix depending on what you need to do.
There are other choices but these are two that I have had some success with.