13

I write enterprise Java applications and web services at work (Spring, Hibernate, Maven, RESTEasy) and PHP (CakePHP) and Python (Django) for my side projects.

While I do see the value that Inversion of Control, Aspect Oriented Programming etc. that Spring brings in, I am not sure how massive web applications that are not on the Java stack manage without a framework like Spring.

So, do the developers just have to "put up with" tightly coupled components and other grievances that Spring eliminates or am I missing something?

For those unfamiliar with Spring, the features we use the most are:

  • Inversion of Control container: configuration of application components and lifecycle management of Java objects,

  • Aspect-oriented programming: enables implementation of cross-cutting routines,

  • Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects.

Arseni Mourzenko
  • 134,780
  • 31
  • 343
  • 513
rdasxy
  • 3,323
  • 7
  • 29
  • 41

4 Answers4

15

Other platforms don't need Spring because those languages are not anywhere near as restrictive as Java.

I'll give an example with node.js

  • Inversion of Control container: configuration of application components and lifecycle management of Java objects

server configuration is done either in code or a simple json config file. As for generic IoC systems, we simply don't need them, Javascript is an expressive and dynamic language. Yes you need IoC but that's simple, pass dependencies to your objects as function parameters.

  • Aspect-oriented programming: enables implementation of cross-cutting routines

I simply don't think we need something like this, we write modular code and it just works.

  • Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects

noSQL is incredibly popular. There is no notion of transaction.

Personally I would say such systems are bloated and over engineered and you just don't need them. Other languages and platforms simply stay lean and agile.

Raynos
  • 8,562
  • 33
  • 47
  • 8
    You've also missed how simple it is to use duck typing and monkey patching to inject stuff in Python and Ruby. – Danny Staple Nov 04 '11 at 23:44
  • 3
    Right, the reason other languages don't have Spring is because... they don't need Spring to actually be useful ;-) – Dean Harding Nov 05 '11 at 00:01
  • 7
    Saying you don't need IoC, AOP or transactional management is short sighted and wrong. Many high level languages allow you to easily write code using AOP and/or IoC design principles. It's just that most of the high level languages don't need an explicit class or container to provide those capabilities. – dietbuddha Nov 05 '11 at 04:02
  • Good non-answer! – Joe Internet Nov 05 '11 at 04:35
  • @dietbuddha they are not IoC, or AOP. They have different names. Yes they are "similar patterns" but that's like saying objects in dynamic languages are "singletons". Wrong terminology, it just doesn't translate. – Raynos Nov 05 '11 at 04:54
  • 2
    @Raynos _As for generic IoC systems, we simply don't need them, javascript is an expressive and dynamic language._ This is misinformation to some degree. You don't _think_ you need them. http://coffeescripter.com/2010/08/dependency-injection-and-ioc-in-javascript/ – Aaron McIver Nov 05 '11 at 04:56
  • @AaronMcIver correct me if I'm wrong but all I saw in that article was "pass your dependencies around as function parameters". Is that really IoC? That seems like modular programming 1on1. I'm saying it's stupid to use a system/library/framework for it. – Raynos Nov 05 '11 at 12:36
  • 4
    @AaronMcIver you were right, we need IoC. – Raynos Dec 20 '11 at 16:05
  • IoC is removing the responsibility to 1. initialize what could potentially be a large, complex set of objects 2. make it horizontally accessible 3. in the right scopes/objects, by taking it out of the code (read: decouple it) and into config. This removes "boiler plate" code. Rails does similar to set things up for you, it's just more hidden (pros/cons) while Spring is more explicit. Also, `noSQL is incredibly popular. There is no notion of transaction.` completely side-steps the issue. noSQL may be popular, but the vast majority of apps use a Relational DB and can benefit from transactions – Don Cheadle Jan 28 '15 at 20:05
15

In most high level languages it's trivial to write using AOP and/or IoC design principles.

All you need to implement AOP is for the language to support higher order functions. For example:

def log(fn):
  def wrapped_fn(*a, **kw):
    logger.log(fn_formatter(fn, a, kw))
    return fn(*a, **kw)
  return wrapped_fn

@log
def do_something(my_friend):
  return have_fun_with(my_friend)

You can also follow general IoC or Dependency Injection principles when programming. You don't need a particular container to provide that capability. You can just write the code that way.

def etl(iextract, transformations, iload):
  return iload(itertools.imap(compose(*transformations), iextract()))
dietbuddha
  • 8,677
  • 24
  • 36
9

Well Python enjoys the Spring also Spring Python.

Spring framework was created to ease Java development and what is true for Java development isn't necessary true for Ruby or Python development.

Ruby for example has Metaprogramming capabilities which means you can create your own AOP.

Ironically though, new Java web frameworks are trying to catch Django and Rails frameworks (see Grails and Play! frameworks for example).

Chiron
  • 4,543
  • 3
  • 28
  • 37
3

For Python, BlueBream (aka Zope 3) provides what Spring does and more.

Complexity and power comes at a cost, there are times when you don't want to pay it.

Many programmers find BlueBream daunting and way too much for what they need to do, they prefer leaner, smaller toolkits. Most of the other solutions (Django, etc.) are based on the MVC paradigm.

You can see a similar forces in action in the Java space as well, with things like the beautiful Playframework.