Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Can someone help me understand why people is using scala over Java for spark? I have been researching but haven't been able to find a solid answer, I know both works fine as they both run on JVM and I know scala us functional and OOP language.
Thanks
Spark was written in Scala. Spark also came out before Java 8 was available which made functional programming more cumbersome. Also, Scala is closer to Python while still running in a JVM. Data Scientists were the original target users for Spark. Data Scientists would traditionally have more of a background in Python, so Scala make more sense for them to use then go straight to Java
Here is direct quote from one of the guys who wrote initially wrote spark from a reddit AMA they did. The question was:
Q:
How important was it to create Spark in Scala? Would it have been feasible / realistic to write it in Java or was Scala fundamental to Spark?
A from Matei Zahara:
At the time we started, I really wanted a PL that supports a language-integrated interface (where people write functions inline, etc), because I thought that was the way people would want to program these applications after seeing research systems that had it (specifically Microsoft's DryadLINQ). However, I also wanted to be on the JVM in order to easily interact with the Hadoop filesystem and data formats for that. Scala was the only somewhat popular JVM language then that offered this kind of functional syntax and was also statically typed (letting us have some control over performance), so we chose that. Today there might be an argument to make the first version of the API in Java with Java 8, but we also benefitted from other aspects of Scala in Spark, like type inference, pattern matching, actor libraries, etc.
Edit
Heres the link incase folks were interested in more on what Matei had to say:
https://www.reddit.com/r/IAmA/comments/31bkue/im_matei_zaharia_creator_of_spark_and_cto_at/
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last year.
Improve this question
I've been trying to learn Kotlin but I find it to be a lot easier to learn when I can slowly apply it to things I'm working on in Java. Is it a bad idea to mix Java and Kotlin in production?
I know the overall goal is to use one or the other but is there anything wrong with the latter?
Objectively, we can say that compatibility with Java was one of Kotlin's main objectives, according to the official docs:
Kotlin is 100% interoperable with the Java programming language and major emphasis has been placed on making sure that your existing codebase can interact properly with Kotlin. You can easily call Kotlin code from Java and Java code from Kotlin. This makes adoption much easier and lower-risk. There’s also an automated Java-to-Kotlin converter built into the IDE that simplifies migration of existing code.
Many features are designed specifically to ease calling Java from Kotlin or vice versa: for example, the fact that property accessors are implemented in the same way as normal Java accessor methods, and the ability to implement SAM interfaces; and where Kotlin implements things differently, there are often annotations or other ways to use a Java-style implementation.
And in my own experience, there are no issues with mixing Java and Kotlin classes. Many of our projects have both (new classes written in Kotlin, a few old ones converted but many still in Java), and I'm not aware of any significant problems. I also converted a major project from Java to Kotlin, one class at a time — and after each one, everything still compiled and tested and ran perfectly.
Of course, new projects can be written in Kotlin from the start; but if you already know Java, mixing in some Kotlin is absolutely an option, and may be the easiest approach. You can convert parts to Kotlin piecemeal, when convenient, or leave them in Java long-term; pretty much everything just works, and you benefit from the parts that are in Kotlin. (You might even find that the way you write Java code benefits from knowing Kotlin!)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I'm just new at Groovy and a few years experience on Java. I'm following a simple tutorial said 95% of Groovy syntax are same as Java. So I am wondering is that a good practice to write your Groovy code as Java? And why not?
thanks
You can write Groovy code in Java syntax to make it easy for Java developers to move to Groovy: as this language feature allows them to start by writing code as they know how to, or they can copy/paste existing Java code into a groovy script.
In other words: the groovy language was designed on purpose to allow for this, to help attracting users.
Looking at pros and cons:
The big advantage of writing java-like groovy code is simple: in case you get unhappy with groovy, it is easier for you to move back. And it allows your team members/coworker who haven't learned groovy to understand your work.
The downside: the whole point of groovy is to give you some features that Java is lacking, so to an experienced groovy programmer, "too much java" style might trigger the question: "why using groovy when you write pure Java all the time?"
Beyond that, keep in mind that groovy is really more of a niche language, that never gained a lot of attention (outside the gradle build eco system).
From that point of view, my personal two cents: don't write groovy code in the first place. Even gradle can be used with kotlin these days. Unless you get paid for doing so, rather spend your time and energy with other languages, e.g. kotlin.
"Is that a good practice to write your Groovy code as Java?"
You mean using a Groovy compiler to compile your Java code? Why would you do that?
Although Groovy supports Java syntax, it's mostly intended for simplifying and compacting your code, providing Groovy programming idioms and syntactic sugar. If you're just a beginner, it's ok to combine Groovy and Java code while you're learning Groovy syntax. But ultimately you should use Groovy syntax only.
So the answer to your question: no, it's not a good practise to write Groovy code as Java.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have a Windows service written by another developer who no longer works with me. It was written in C# with .NET 4.5 requirements. Our solution is making the move to Linux and the daemon naturally needs to be converted.
My dilemma is what to rewrite it in? C++ or Java? The daemon is not complicated. It's simply a controller for our other applications to ensure if they crash or are killed they are restarted. Aside from that it performs health checks through a named pipe and is controlled via a password protected web socket via a separate management Tomcat web interface and writes all of it to logs.
Please put aside any suggestions of "write in what you're most comfortable with" I have a fair amount of experience and knowledge in both languages, and I'll learn whatever else I need to as I go. My concern is the feasibility and effort to accomplish everything I need. I don't have any particular time constraints, but if one language is a fraction of the time of the other then maybe that's a better solution.
Writing it in Java looks like the easiest solution currently, but writing it in C++ has the advantage of being native no-frills code. However, I haven't ever written any web interface or socket code in C++ before, so I do not know the effort involved with that.
To break down my requirements:
Linux
Web interface for control
Named pipe for communicating with client applications
Existing code needs to be heavily refactored
Is C++ or Java more appropriate?
Edit: added more info
Edit2: I guess I should have mentioned that the code needs to be heavily refactored anyways. It was originally written in such a way that renders it difficult to make changes and additions. So rewriting is a cleaner solution at this point. As I mentioned, it's not a large program. Just a controller service.
Porting the solution to .Net Core may the way to go. It will run on Linux (and Mac for all intents and purposes...) and most of your codebase may need minimal refactoring. The only concern is if .Net Core currently has the features you would need supported in the app. And, .Net Core is still in preview.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Recently I have coded a application in jruby and made .jar file from it and deployed same in tomcat. I have also read an article on jruby which says "Jruby- scalablity of java and easiness of ruby".
Here I want to know does coding like this in jruby, give same scalability and performance like directly coding in java?
Just like this using ruby extension to run c code in ruby gives same performance as directly coding in c.
Thanks
(Disclaimer: this might not be a complete answer but it was too long for a comment)
Although I have next to no experience with JRuby's implementation in particular, dynamic languages implemented on the JVM have their limitations in terms of the speed you can get compared to what you would get if you coded directly in Java.
From what I understand, this comes from the trade-offs client language implementations (JRuby, Clojure, Jython, etc.) have to make, in order to "simulate" their inner workings on the host platform (in this case the JVM). Maybe in the most common scenarios the performance difference is not that bad since the JVM's HotSpot optimizations kick in, but when it comes down to getting Java-like code performance, you might need to dive into the details of the language implementation in order to bypass some of its limitations.
In the case of the Ruby extensions in C, what you are actually executing is native code (machine language) that was originally coded in C, but which you can call from your Ruby code. When running JRuby code, the language you are programming in is Ruby, which has to be compiled to Java bytecode, which runs on the JVM, which translates that into operations in the native operating system. Something analog to Ruby/C would be in this case JRuby/Java, that would be calling some Java code, that was originally written in Java from your JRuby program.
EDIT
This discussion mentions some of the points I have included above and a more detailed explanation on some other interesting points.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am considering using Akka in one of my projects, but I have to use only Java. A majority of the material (books/articles) are on Scala version, so I am wondering if I use Java I would be a second-class citizen.
Are there any significant functional/performance differences between the two?
Thanks
In terms of performance of Akka itself it will be the same since you are going to be running the same Akka byte code. However in terms of integrating you will be using the Java API and be limited to the language features of Java. As such you will be a second-class citizen in terms of using the API. However in functional and performance terms it will be pretty much identical. Just keep in mind that your Java code will be interacting with the library differently from Scala code. With Scala you have access to closure and other constructs that you cant use with Java (yet). Nevertheless Akka is a great library also when used from Java....
I think the main web site page on Akka sums it all: 11 lines of Scala, 17 lines of Java (+50%).
No or negligible performance difference (bytecode, JVM,...). The performance issues will be around what you write on top of Akka.
Significant functional performance (not in terms of possibilities but code clarity... and clarity has a direct relationship to bugs and fixing them)
Between the two implementations, there are no differences in terms of performance and functionality. If your formation is Java then Akka can be a good solution to introduce the actor model in your Java projects. Clearly with Scala would have the advantages that the whole expressiveness of the language offers.