douxin2011
douxin2011
2010-04-11 23:52

将Java应用程序移植到Go-有什么建议吗?

已采纳

We want to rewrite kodingen.com backend with Go which currently is Java, running as daemon using jsvc.

I have never touched any C in my life, am only experienced in Java so I don't know if this is something that I should even start.

However, task is pretty simple

  • read shell commands from mysql database
  • queue and execute them in parallel
  • save each shell output to the database

that's it. So these simple requirements gives me hope that I can start using this wonderful language.

What would you advise? Is C still better ?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • douti9286 douti9286 11年前

    I like Go a lot and have made contributions to the project. However, I think you ought to consider a few things about Go before settling on it for sure.

    • Go is still an unstable language. Its syntax, features, and packages are all subject to change. Make sure you're ready to keep up with this if you choose to use it.
    • Go's garbage collection is still immature. Your memory usage should be better than 1.2 GB, but it probably won't get you near C levels.
    • There's no core support for MySQL (or any other database). There are several unofficial MySQL package projects. The most recently updated ones are GoMySQL and Go-MySQL-Client-Library. I don't know anything about how complete or stable they are.

    As for queuing and executing in parallel, I think that's something Go will be able to do pretty well. You'll probably use the exec package to execute and parallelize with goroutines.

    点赞 评论 复制链接分享
  • douguaidian8021 douguaidian8021 11年前

    I think with the recent addition of panic/recover, Go is starting to become a viable option for website backends. I've been running a couple simple facebook apps using Go, but it's frustrating having the entire app go down for something like a map key error, or a null pointer exception. With panic/recover, it'll be possible to manage crashes.

    About your requirements - it should be fine for mysql and shell commands. But be prepared to patch some libraries :)

    点赞 评论 复制链接分享
  • douhang5460 douhang5460 11年前

    From the go langugage FAQ:

    The Go project was conceived to make it easier to write the kind of servers and other software Google uses internally, but the implementation isn't quite mature enough yet for large-scale production use.

    As I know, Go's garbage collector and scheduler is not ready yet. And its compiler is not optimized enough, anyway, C compiler has been improved for 20 years. If you want to use it in a production site, waiting for Go to be mature enough is better.

    But that does not mean Go is not a good language to learn. Actually, I'm happily using it to develop some useful utilities.

    EDIT: Before you switch to another language, how about making some experiments with the forthcoming JDK 7. There are some improvements in the garbage collection. You can check is the memory management better in your case.

    点赞 评论 复制链接分享
  • duandou1903 duandou1903 11年前

    I agree with @Chickencha

    At this point I have no plans to update my [1]: http://github.com/chbfiv/libmysqlgo "libmysqlgo" project. Contributions are welcome, but I'm too busy atm. I would recommend using more active mysql go projects.

    点赞 评论 复制链接分享