开发者

Eventdriven app - what language or VM to choose? [closed]

开发者 https://www.devze.com 2023-01-22 16:39 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or开发者_运维问答 extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I'm considering writing an app that has the following requirements. I'm proficient with Ruby, but I'm willing to learn a new language like Scala, Clojure or Python.

Concurrency / Best performance

This is my main goal. It needs to be amazingly fast and support concurrency in a decent way.

Use Redis as a back-end

This won't be a big problem, redis has a wide range of drivers available, but it may influence the final decision on a language/platform.

Websockets support

Good support for websockets is a must. Using an add-on library (like Cramp for Ruby::EM) is okay.

Options

I've gathered the following options:

  • Ruby EventMachine
  • Python Twisted
  • Node.js
  • Clojure
  • Scala
  • Java

Writing raw C or assembler are not viable options at this time.

Concurrency

Ruby 1.9 still uses the GIL, where as all JVM based solutions can use native threads. I'm not sure about Node.js in this case.

How does the selected language affect performance?

The question

What do you recommend and why? Do you have hands-on experience? Please enlighten me (and the rest of StackOverflow)


Clojure is about twice as fast as node.js, which is about three times faster than Python which is held to be faster than ruby.


I'd vote for Clojure if high performance concurrency is your main criteria. Clojure was basically designed for concurrent development from the beginning, and there have been some impressive Clojure demos running on 800+ core Azul boxes.

It is very much worth looking at this video presentation to understand Clojure's approach to concurrency:

http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey

The main trick in Clojure's concurrency performance is a clever implementation of Software Transactional Memory (STM) that lets you conduct many concurrent transactions without complex and expensive locking schemes. It also uses persistent data structures to give immutability and efficient management of multiple versions of data. It's very cool.

As for general purpose performance, Clojure is pretty fast already and getting even faster with the new 1.3 alpha branch. A stated aim of Rich Hickey (Clojure's creator) is to allow you to do anything in Clojure with the same speed that you can do it pure Java.

Other things in Clojure that I really like but may or may not be relevant to you:

  • Hugely powerful LISP-style macro system - "code is data" and you can manipulate it as such
  • It's a fully fledged functional language
  • It's dynamically typed by default (for flexibility and quick prototyping), but you can add static type hints if you need to (for better performance)
  • Excellent JVM / Java integration, so you can make use of all the good Java libraries and tools out there (e.g. Netty for event-driven server communications)


On Clojure you could use Grizzly for async http processing and comet/websockets based apps. Redis is a great choice to cache and create a powerful distributed session with pub/sub protocol built-in Another big thing is use RabbitMQ or ZeroMQ to simulate a agent based distributed system and provide group, data or integration services for example.


Is relative ... a like clojure a lot and agree in parts with you , where clojure is one of the fastest language on jvm .

But the knowledge on language is essential and could confirm our feeling.

Some interesting links on benchmarks , performance and comparisons :

http://bit.ly/dtqHAG

"Premature optimization is the root of all evil", by Donald Knuth

0

精彩评论

暂无评论...
验证码 换一张
取 消