Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
开发者_如何学C Improve this questionI am curious as to how people port open source projects such as Lucene and Hibernate from Java to .NET? Is it a simple matter of using the Java Language Conversion Assistant 2.0 released by Microsoft?
Unfortunately, there's usually a much greater effort involved for projects that large. What's efficient in one language may not be in another, and more importantly what exists in one language may not in another. NHibernate for example took years to port over, and they're still doing it (albeit adding features the whole time, like Linq).
It's usually a matter siting down and porting classes one by one, optimizing where possible, changing structures where needed. Things like generics, aliases and boxing all change in the port. Then, after you get it all over, there's often lots of optimization still left to be done (of course this is optional...), maybe it's events, maybe it's statics and extension methods, could be anything your new language/platform offers that the old one didn't.
Think of it this way, why are you porting it to .Net? I'd wager to say you're in one of two situations, one you're stuck using .Net because of work (doh, sorry!) or you like .Net because it offers you some advantage. In the second category that means you chose it over Java, so in porting you'd want to take advantage of whatever features that made you choose .Net in the first place.
Like Nick said it is not that simple. A lot more than just porting code is involved, especially if the architecture of the application you want to port isn't that great. You want to use the features of the language you are porting to, and sometimes they are design decisions that you might change, because they don't seem right to you. I am not going to reiterate what Nick said, but would like to add the following.
I would recommend following the development of Noda Time, which is Jon Skeet's attempt to port Joda Time from Java to .Net. Jon is actually documenting the experience on the following blog:
http://noda-time.blogspot.com/
I would recommend following the blog, the google groups page for this project, and google code project. The google groups and code page links can be found on one of the posts on the blog.
精彩评论