For what reasons do people choose Ruby over Java? [closed] - java

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 13 years ago.
I am a beginner to Ruby. I've heard the following complaints about Ruby, and was hoping the Stack Overflow community could address each point raised.
Common complaints about Ruby that I've heard:
Ruby is slower than Java
Ruby is not statically typed
It's not suitable for large projects
Given these admittedly opinion based statements, how is Ruby 'better' than Java? and will Ruby ever be a widely used language both by businesses and individuals?

Ruby is slower than Java to run but faster to write, or read. Which is more important to you? I don't know any company in the world who'd pass if given the opportunity to (say) cut their dev time in half at the cost of doubling their hardware.
Ruby is not statically typed, but neither are Python, Perl, Lisp, shell scripts, etc. Is this really a problem for you? I'm sure you could find just as many people in dynamic languages who would complain that Java, C#, C++, etc., are statically typed. We've no lack of examples of systems built on dynamic languages.
I'll agree that Ruby isn't suitable for large projects, but neither is any other language we have today. The state of software engineering is pretty clear to me: nobody can reliably build large systems well. At least Ruby makes your large projects smaller in lines-of-code, which makes them (somewhat) more manageable. It's syntactically richer so you can say (something closer to) what you mean. It's faster to write so you'll find out quicker if you're going down the right path or not.
If these are the best arguments against Ruby, then Ruby is doing better than I'd thought.

Ruby's speed has greatly increased in the latest version. Though in older versions Ruby is slower than other scripting languages.

For some purposes, Ruby is too slow in operation. For others, it's fast enough.
For some purposes, Java takes too long to develop.
For some applications, static typing is unnecessary, for others it's highly desirable.
The size of the project is largely irrelevant.
In some ways, Java is better than Ruby, in other ways Ruby is better than Java. Anyone who maintains that one is "better" in any circumstance probably doesn't know enough about either to hold a valid opinion.
And what about JRuby?
I think it's fairly well-documented by now that Ruby is "popular". Not as "popular" as Java, C++ or C, for example, but popular nonetheless.
See
http://www.langpop.com/
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

The answer to the question "which language is better, this or that?" is always subjective. Sure, objectivity is valid and you can somehow reach a conclusion about a language being better for X task/project.
However, even then, if your team is happy with some other language that is not the first choice for a certain task/project, but the work can be done anyway... a wise team will choose the language that makes them happy because their productivity will also be greater.
Concluding, no one can tell you his choice is better than your choice. They can try to persuade you, but if for some reason X language makes you more excited, they cannot do anything about it.
Having said that: Ruby 1.9+ has improved a lot as far as performance is concerned. If you ask me, my biased opinion is choose Ruby because I like it. But if you wanted an unbiased opinion, we would have to discuss more aspects and examine what exactly you want to do with the language/framework etc.

I advise you to try both languages and then decide which you think is best.

Ruby is a popular language already :)
I don't agree with you on "We should always think about the performance" and "ruby is better than java". On some project, code readability may be more important than performance. Think of optimized C++ code which no one can read and maintain for example. And there is no perfect proof that "Ruby is better than Java". Where did you take that information ?

how is Ruby 'better' than Java?
It's not, and Java isn't 'better' than Ruby. Both have their pros and cons, and it depends on your project; what is the best tool for that job.

Depending on what you need to do.
We expect our code to run for decades. Staying with pure Java means that we are pretty certain that the technologies will stay "in fashion" and that future colleagues can maintain the code. Going for the language of the day, will eventually mean that you will have programs written in languages which have gone out of fashion and therefore is more difficult to maintain.
"Pure java" basically means we are staying with the standard Java Runtime, and implementations of Sun specifications (like JavaServer Faces). It is not as boring as it sounds :)

Related

Haskell vs JVM performance [closed]

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 11 years ago.
I want to write a backend system for a web site (it'll be a custom search-style service). It needs to be highly concurrent and fast. Given my wish for concurrency, I was planning on using a functional language such as Haskell or Scala.
However, speed is also a priority. http://benchmarksgame.alioth.debian.org results appear to show that Java is almost as fast as C/C++, Scala is generally pretty good, but Haskell ranges from slower to a lot slower for most tasks.
Does anyone have any performance benchmarks/experience of using Haskell vs Scala vs Java for performing highly concurrent tasks?
Some sites I've seen suggest that Scala has memory leaks which could be terrible for long running services such as this one.
What should I write my service in, or what should I take into account before choosing (performance and concurrency being the highest priorities)?
Thanks
This question is superficially about performance of code compiled with GHC vs code running on the JVM. But there are a lot of other factors that come into play.
People
Is there a team working on this, or just you?
How familiar/comfortable is that team with these languages?
Is this a language you (all) want to invest time in learning?
Who will maintain it?
Behavior
How long is this project expected to live?
When, if ever, is downtime acceptable?
What kind of processing will this program do?
Are there well-known libraries that can aid you in this?
Are you willing to roll your own library? How difficult would this be in that language?
Community
How much do you plan to draw from open source?
How much do you plan to contribute to open source?
How lively and helpful is the community
on StackOverflow
on irc
on Reddit
working on open source components that you might make use of
Tools
Do you need an IDE?
Do you need code profiling?
What kind of testing do you want to do?
How helpful is the language's documentation? And for the libraries you will use?
Are there tools to fill needs you didn't even know you had yet?
There are a million and one other factors that you should consider. Whether you choose Scala, Java, or Haskell, I can almost guarantee that you will be able to meet your performance requirements (meaning, it probably requires approximately the same amount of intelligence to meet your performance requirements in any of those languages). The Haskell community is notoriously helpful, and my limited experience with the Scala community has been much the same as with Haskell. Personally I am starting to find Java rather icky compared to languages that at least have first-class functions. Also, there are a lot more Java programmers out there, causing a proliferation of information on the internet about Java, for better (more likely what you need to know is out there) or worse (lots of noise to sift through).
tl;dr I'm pretty sure performance is roughly the same. Consider other criteria.
You should pick the language that you know the best and which has the best library support for what you are trying to accomplish (note that Scala can use Java libraries). Haskell is very likely adequate for your needs, if you learn enough to use it efficiently, and the same for Scala. If you don't know the language reasonably well, it can be hard to write high-performance code.
My observation has been that one can write moderately faster and more compact high-performance parallel code in Scala than in Haskell. You can't just use whatever most obviously comes to mind in either language, however, and expect it to be blazing fast.
Scala doesn't have actor-related memory leaks any more except if you use the default actors in a case where either you're CPU-limited so messages get created faster than they're consumed, or you forget to process all your messages. This is a design choice rather than a bug, but can be the wrong design choice for certain types of fault-tolerant applications. Akka overcomes these problems by using a different implementation of actors.
Take a look at the head-to-head comparison. For some problems ghc and java7-server are very close. For equally many, there's a 2x difference, and for only one there's a 5x difference. That problem is k-nucleotide for which the GHC version uses a hand-rolled mutable hashtable since there isn't a good one in the stdlibs. I'd be willing to bet that some of the new datastructures work provides better hashtables than that one now.
In any case, if your problem is more like the first set of problems (pure computation) then there's not a big performance difference and if its more like the second (typically making essential use of mutation) then even with mutation you'll probably notice somewhat of a performance difference.
But again, it really depends on what you're doing. If you're searching over a large data set, you'll tend to be IO bound. If you're optimizing traversal of an immutable structure, haskell will be fine. If you're mutating a complex structure, then you may (depending) pay somewhat more.
Additionally, GHC's lightweight green threads can make certain types of server applications extremely efficient. So if the serving/switching itself would tend to be a bottleneck, then GHC may have the leg up.
Speed is well and good to care about, but the real difference is between using any compiled language and any scripting language. Beyond that, only in certain HPC situations are the sorts of differences we're talking about really going to matter.
The shootout benchmark assumes the same algorithm is used in all implementations. This gives the most advantage to C/C++ (which is the reference implementation in most cases) and languages like it. If you were to use a different approach which suited a different language, this is disqualified.
If you start with a problem which more naturally described in Haskell it will perform best in that language (or one very much like it)
Often when people talk about using concurrency they forget the reason they are doing it is to make the application faster. There are plenty of examples where using multiple threads is not much faster or much much slower. I would start with an efficient single threaded implementation, as profiled/tuned as you can make it and then consider what could be performed concurrently. If its not faster this more than one CPU, don't make it concurrent.
IMHO: Performance is your highest priority (behind correctness), concurrency is only a priority in homework exercise.
Does anyone have any performance benchmarks/experience of using
Haskell vs Scala vs Java for performing highly concurrent tasks?
Your specific solution architecture matters - it matters a lot.
I would say Scala, but then I have been experimenting with Scala so my preference would definitely be Scala. Any how, I have seen quite a few high performance multi-threaded applications written in Java, so I am not sure why this nature of an application would mandate going for FP. I would suggest you write a very small module based on what your application would need in both scala and haskell and measure the performance on your set up. And, may I also add clojure to the mix ? :-) I suspect you may want to stay with java, unless you are looking at benefiting from any other feature of the language you choose.

Is Java is an "island" for developing new apps and libraries? [closed]

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 11 years ago.
I will be making a cross-platform, graphical mathematical modeling application, for example, a user can drop a bunch of nodes on a canvas, specify some mathematical relationships between them, and run a simulation. I'm also interested in seeing in this being a web app.
I have had some programming experience in Java, MATLAB, Python, but I have never made a large application, thus I know very little about software architecture, and how multiple languages work together.
I am trying to figure out the best IDE, language(s), etc., to work in. The previous work done by my group has a lot of C/C++ libraries to draw from for back-end work, like simulation. I was told by my boss that Java is an "island" for development, meaning the Java app has difficulty using libraries from other languages and making its own libraries usable to other languages.
Is this true? Can someone shed some light on this topic?
Also, then what tools should I be using? I am ready to learn anything, but I'm trying to go for what would be the most productive route. Learning and then programming everything in C/C++ does not seem like a very productive route to me currently.
Things I've looked at so far include WindowBuilder/GWT Designer (this seems like a way to make both desktop and web apps), Mono/GTK+/MonoDevelop, and Delphi
Please feel free to be as verbose as you can, thanks!
I fear this post may get closed as off-topic. But it seems a little too specific to toss, IMHO.
Java interoperates with a lot of non-Java projects, products, etc. However, a major feature of it is portability, so you'll find that folks go out of their way to stay within the JVM environment. In that sense it's an "island".
I suggest you think about exactly what you want to interoperate with and get specific - see whether the hooks are there or not.
For your back-end C/C++ libraries, you'll need to implement JNI interfaces. I'd describe this as having a small but moderately steep learning curve - not a lot to learn, but it takes a little thought - especially if the amount of data passed back and forth is so large that performance is an issue.
You may find that you don't have what you need with GWT for the graphical aspects of what you're doing.
I'd think hard about how much you need the web aspect. If you do, consider skipping a desktop-only solution (and maybe Java/GWT) altogether, and just going to the web. This is especially viable if you don't need to support older browsers.
I'm not going to touch the "what tools" question - it's too broad.
Considering Jython, Groovy, Clojure, and a whole host of other language adaptations for Java, I would firmly suggest that your boss does not know what he is talking about. Java also has the ability to execute native code if necessary, so it is not terribly difficult to incorporate other, non-JVM toolkits. But even if he were right and there was no cross-linguistic work with Java, the language has been around long enough, and it is verbose enough, that you can generally find libraries which will supply the inter-operability you're looking for.
Without knowing more about your specifics it will be hard to give a precise answer, but the general rule is that the language you know is better than the language you don't, so unless your language goes completely against the idioms required, use it. Eg. if you have in-house expertise in C/C++, those languages are perfectly adequate for building applications. JavaScript significantly less so.
You do not want bugs which are caused by faulty assumptions about the language. Those are nearly impossible to track, especially since you won't know where to look.
Well, if cross platform is an issue, I would suggest developing in Java, it makes everything very easy in that regard. As far as loading C/C++ libraries, I don't have much experience with it, but I would recommend taking a look at something like Java Native Access.
As far as tools go, they are wide and varied. I personally use Netbeans or Eclipse, but untimely that sort of choice comes down to what plugins you may need and what you personally prefer.
All in all, I would say program out a little stub of the application in different environments and different languages and see what you like. You really need to know the details of the application to make an informed decision, and it varies in most cases. Best of luck!

why java number one? [closed]

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 12 years ago.
Why is Java the most used programming language ? Why are the most programmers jobs for Java ?
Don't get me wrong here ? I like Java and I work in Java ? I don't have anything against it ?
Also, I'm trying to learn some other stuff out of the OOP box, like Clojure with its functional programming.
But, I'm wondering, why is Java number one ? I mean, dynamic languages (Ruby, Python, Php, JavaScript) people says that static types languages (Java, C/C++, C#) people envy them for their productivity ? They say they get the job done faster...
Ok then, if dynamic languages are more productive, how come Java stands where it stands ?
It was backed by a major commercial company Sun -- which other business value when decided on adopting such things.
It continued in the syntactic tradition of C++ -- already a widely used language at the time. In many ways, it was sold as a far improved C++.
It came with batteries included -- the framework.
Superb marketing effort of write once / run everywhere (platform independence).
The fear of Microsoft's dominance at the time forced a lot of companies to collaborate in the Java endeavor, notably IBM.
I don't think other languages on your list had these qualities (even if I fall into the dynamic/productivity camp). Arguably Python filled some of those niches at the time.
Typically it's easier for people to conceptualize in imperative languages with garbage collection (C#, Java)
Spolsky considers Java to be an easy language, he has a famous post on it.
Java is well-defined and thus easier for formal analysis efforts
Java runs on most modern platforms without massive grief
Java is "enterprisey", by which I mean it seems to be heavily adopted and developed by large corporations, which, due to sort of a best-practice risk-minimization approach, means other large corporations will also use it.
Java is taught in many universities.
Just off the top of my head...
Huge potential user base.
Large set of libraries.
Established community.
Fast VM.
Platform independent.
It's free.
It's been around for ages.
Some of the factors that have given Java its popularity are:
Its Maturity
Easiness to learn
Great API
Also, due to its philosophy of "Write Once Run Everywhere", Java programs are extremely portable and the Java platform itself is quite mature, in terms of the kind of applications that can be developed with it; not to mention the plethora of new languages that are being developed to run on the JVM.
Remember, most used, doesn't mean better; for many purposes you'll find that Java simple falls short of a viable solution.

Java vs. PHP Speed Comparison [closed]

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 12 years ago.
Which language is faster for web, Java or PHP?
It is a difficult one to answer as in theory Java should be faster:
it's precompiled, any trivial algorithim will run faster in Java than PHP and there has been a vast amount of work done to optimise Java from improving the code, standard libraries, to JIT compilers, etc.
PHP is loaded and interpreted every time if you're not using the Zend optimiser, objects are intialised on every execution, even the most trivial string varaible is actually a complex object with many methods to support.
The problem is that in practice PHP sites seem to run faster using fewer resources.
I think this is because PHP developers take a more straightforward approach to design and don't get lost trying to implement exotic design patterns and implementing endless pointless abstractions.
Speed doesn't matter
in most cases.
Processing is cheap. Code in what you're comfortable with. Writing proper code goes much further for speed then choosing a language. Solid coding conventions and design plan will also help more.
Best answer I could find
"stuff to consider:
Java web applications are compiled
to bytecode. Even JSPs, which are
compiled at runtime. This is an
advantage over most uses of PHP,
where the Zend Optimizer is not in
use.
Data can be cached in a live servlet
instance - no direct/easy way of
doing this in PHP to my knowledge
(there is only ever a single
instance of a servlet/JSP in memory)
If anybody knows how to cache data in PHP without resorting to ugly
hacks, please enlighten me!
Java applications tend to be
n-tiered, which generally results in
a more maintainable application at a
slight performance penalty. This
probably sounds trollish, but
honestly: even within Java itself
direct use of JDBC will always be
faster than going through three
layers of objects to the database.
But is an n-tiered Java application able to hit the database sooner than an uncompiled, hacked-up monolithic PHP script? I don't think there's an answer to that question.
All that said, I'm working on an n-tiered MVC framework for php 5 (it's called Pure (http://www.sf.net/projects/php-pure)), so my PHP applications are generally n-tiered too. I'll worry about speed when and if it becomes an issue. For now, it's definitely not an issue."
courtesy of krumms
Speed aside, I believe the performance of Java is better than PHP. But developing a project in PHP is faster.
Can't answer this question with one or the other unless you define what you want to measure the speed of.
Some things are much faster in PHP (in a native function for example), other things are much faster in Java.
The intent of each language is substantially different from the other, so if you're debating over which to use for a particular task, you should generally based the decision on that task (and how well suited each language is to it) rather than performance.
For raw performance of code written in the language (as opposed to simply calling code in the standard library), Java will probably run faster than PHP as an extremely general rule. If that matters, chances are that PHP just isn't very well suited to the task at hand.

Struts vs Zend ? Java vs PHP? [closed]

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 know it's a hot question that need anwsers ^^
From my viewpoint, using Java vs PHP, is nowadays a problem of system resources (Hardware, Software, etc.).
For Java, you have to deploy J2EE Stack (JDK, AppServer, etc.) (~200M) on your server, for PHP you need to deploy a LAMP system (~100M).
Using Java was in my opinion due to object oriented programming in web application, but today we have a lot of Object Oriented Web Language (Ruby, Python, PHP).
So the question when to choose between Java or PHP for new projects ? Maybe the community difference ?
I know that stackoverflow is not made for discussion, but it's a (good?) question that need answers (for me and for others maybe) ^^.
What are you guys talking about....
Okay JAVA has some pros, but it also has some cons. Now with PHP it is exactly the same, it has some pros, but it also has some cons.
People who say PHP doesn't have a good OO environment, well either does javascript! And really that is the heart of all web 2.0 projects; javascript. The back end today is becoming more of a resource for the front end. What you can do in JAVA now days you can do in PHP 5.3 - to some degree. If you are a good developer you will be clever enough to abstract your design to make it maintainable and if you are brillant you can match and even improve object sharing in PHP, which majority of web "designers" don't know about - or dare I say, comprehend. Check this article out by O'Reilly ON JAVA!.
I develop both in Java and PHP. I'll always use PHP for my server side and I'll use Java for Android Development, and desktop development. (By the way I have developed in java for backend development, but it take twice as long to do something in JAVA then to do it in PHP. That is why I stick to PHP.
I hear this spagetti code problem with PHP all the time. Yeah. Maybe 5 years ago! If you project ends up like this then the person, or you, is a poor programer, and you should stick to drawing pretty pictures. It is easy to separate your logic from presentation, and it is also simple to separate your business logic from you data layer. Think before you code. Don't just open up a note pad and start typing. Plan! People who fail to plan, plan to fail! Jacco you're on the money!
I see uni students all the time building code where I think, "The person who is going to end up with this guy is going to regret it". If the student just planed and documented what he was going to do then every thing would be organised and ready for scaling - again if he was good enough.
Both technologies are great and you should use what is more comfortable to you or your developers. If you go down the road where you think one is better than the other and you know nothing about that technology, well guess what? No matter what you do your projects outcome will be missed, and you'll end up having to do it again.
Other constraints are usually taken into account. Things like
development time,
maintainance cost of the codebase
availability of qualified programmers
salary cost for available qualified programmers
to name a few.
Hardware and software are cheap if you compare them to the above so they tend to be less important.
I did a non-scientific performance comparison of J2EE and PHP. The comparision was to see the user experience of each system under various load conditions.
I found that PHP's response time was very slow and CPU maxed out very quickly. I understand there are some compilers that will probably help, but I wanted to make an out of the box comparison of performance of rapid development systems.
You can read the full details here: PHP vs J2EE: a Practical Approach
It depends on what you're doing. Choosing a language/framework without analyzing your project requirements is a bad idea.
Choosing a language depends on what you want to do, But I am very sure that the different hard disk space requirement will be the least important aspect of your decision.
Here is a possible hint: If you want to reuse your work (or parts of it) in a desktop application, Use Java. PHP is virtually non-existent for everything except web programming.
I really don't think that it is a question that can objectively be answered. In the end it is about people and what they feel more comfortable with. That is why e.g. Facebook developed a PHP to C++ compiler (with which the performance benefit that Java has might become smaller, too) instead of just hiring C++ developers for doing the Job.
On the other hand, the Java platform offers some interesting new approaches like Grails (which is basically a Groovy Wrapper around Spring) and Lift, as well. That makes Frontend development faster and easier (I still find that this is a real pain with plain Java) and you can combine the benefits that other languages have with your existing Java codebase and expertise (btw. most of the Frameworks mentioned don't need a J2EE runtime environment a simple Tomcat installation with around 5M and an installed JRE should be enough). So it is not really about the Java programming language alone anymore.
And if you really can't decide at all you just run PHP in Java (works as well for Ruby, Python, Javascript ...).
PHP wins in front end in web development. Because it has much smaller development time which make things cheaper and cheaper.
PHP will lose in mobile app development. There is no way to develop a mobile app front end with PHP. And Because its performance gap with java and other static languages, PHP will lose the back end battle. Java is old, but it has a pretty young and professional community. Check out those names: lucene, weka, hadoop,scala,cassandra, hbase, what does php provide us in back end service???????
I do not really agree on the fact that the choice of a language is related to system resources.
Hardware is cheap and we are not in a time where we need to closely look at the system resources as we used to have. Don't misunderstand me: we still do need to pay attention, but the time where people were xoring their pointers to save some space is over (luckilly).
And if your main concern is performance, then either running a JVM or an interpreted language is probably not the best option.
I do not think it is related to the orientation of the language per se either. Ok, I know, PHP is not object oriented but still, you can now code OO with it. You will find descent web frameworks for almost any language.
I agree with Jacco on his list.
Another aspect is indeed the culture the language refers to.
PHP is for script kiddies. Java is for serious, wearing suits business developers. Of course, we all have many counter examples but still. Java was largely adopted by big companies, now competited by .Net. There are good reasons for this, among which the fact that it a lot easier to write poor code in PHP than in Java (and almost any other language). On the other hand, Java is not exactly freedom oriented.
If your project is strictly personal, you can choose whatever suits your tastes better. If you plan to develop as a team, the choice of the language will impact its general mood/way of thinking.
I would finally add some important parameters to me: fun and elegance
This may be a matter of taste here again, but I have much more fun coding in python than in C# for instance.

Categories

Resources