3

Ok, I'm a total newbie in this stuff.

So, I know Spring is really good as a framework, and I've been programming in Python for a while, so I was wondering if somehow I can use the Spring Framework but use code from Python.

I heard that maybe Jython was a good possibility for doing this, since it's (I think) Python running on the JVM, right?

So, is this possible? For me to use Spring while coding in Python?

1
  • 1
    I have no doubt that this is possible. Whether you will find it pleasant is something I cannot speak to. Commented Jan 17, 2013 at 21:47

1 Answer 1

3

First, you're right that Jython is Python running in the JVM. And it's not just running in the JVM, it can interact with it in pretty much all the ways you want—use Java classes as Python classes, implement Java interfaces in a Python class and pass it to Java code, etc.

However, unlike some of the other JVM languages, Jython doesn't make any attempt to be semantically equivalent to Java (or to a superset of it). And of course Python and Java have very different idiomatic styles.

So, in short, just about anything is possible, but not everything is pleasant, as Marcin says.

For specifics about how Spring works with Jython, a quick Google search turned up See how Spring Python works with Jython. And in fact, it's part of a blog called "Spring Python", which is part of a site also called "Spring Python". It seems like this may be a port of Spring to Python rather than about using Jython with Spring. ("This project takes the concepts of Spring and applies it to the language and environment of Python. This includes pragmatic libraries and useful abstractions that quickly gets you back to working on the code that makes you money.") So, that might be another alternative for you.

The next search result was Jython Spring MVC Controllers.

And there were half a dozen other promising results. So, I think you'll have no problem finding information and examples.

Sign up to request clarification or add additional context in comments.

2 Comments

I was kind of curious about that. Yes, I read about Spring Python, but I also read that the creator intended this as an utility, and not a framework. So I thought that it wasn't an option. Then again, this "MVC Controllers" make a lot of sense. I haven't been working with Spring that much but I think the controllers are almost all the code the framework uses on the back-end (there's also the model. I've been too much into Django =P). Am I right on this? If controllers are almost all the code, MVC Controller is an option?
I've never used Spring in anger, but it certainly seems like, with any reasonable MVC framework, for most designs, controllers will be most of the back-end code, so this seems reasonable. But my larger point is that if you're just asking the general question "Can Spring and Jython be used together", the answer is obviously "Yes, and Google will even find you some good examples and explanations." If you're asking something specific about your project, I think we need more specifics about what your project is. If you're just exploring at this stage, if you know enough to try it out, go for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.