How do I mix JVM based languages in a single Netbeans project? - java

For example, is it possible to have Scala, Java, and Clojure source all compile/build together properly inside the same project? Or, do I have to do them as separate project libraries then used by whatever I pick as the "master" project?
If neither of those, how's everyone else doing it?

Unfortunately, while the Java community seems to be very enthusiastic about polyglot programming, the IDE vendors haven't really kept up. They generally do have plugins for Java, Scala, Clojure, Groovy, Ruby, ECMAScript, Python, C++ projects, but mixing multiple languages in one project is generally not supported.
In Ruby, for example, it is quite common to use Swing as a GUI via JRuby. But if you want to use Matisse, the NetBeans Swing GUI builder you must use a Java project, you cannot use Matisse in a Ruby project. However, if you use a Java project, then you can't have a Ruby main executable, you must have a Java main executable. Also, you don't get Rake support and other things that the Ruby project type supports. (The ugly workaround is to write a Java main executable which creates a JRubyEngine instance by hand, loads the Ruby main executable into it and runs it.)
The Eclipse Scala plugin supports a limited amount of polyglotism, but the hoops that they have to jump through are tremendous. Basically, they use runtime bytecode patching to inject Scala Aspects into the Java Development Tools Eclipse plugin, to get type-driven cross-language refactorings to work. The Groovy plugin does similar things, as does AspectJ (in fact, they originally came up with the idea of using aspect weaving to inject new functionality into JDT). So, all of these plugins allow polyglot programming with themselves and Java. But unfortunately not with each other. (Although several of the maintainers have expressed interest in more closely collaborating.)
In general, I fear that the only solution is new IDEs.

Rather late to answer this question, but the answer is that IntelliJ IDEA does a very fine job on polyglot programming. I recently watched a demo where one of their developers did a mixed-language application in 5 (!) languages.
They manage to do multi-language-aware syntax coloring, refactoring and more. They've obviously sunk some effort into this and are justifiably proud.
I was very happy to note that IDEA is now (partly) open-sourced.

Related

IntelliJ IDEA plugin development in other JVM languages

Is it possible to use other JVM languages such as Scala and Clojure for developing an IntelliJ IDEA plugin? Or do we have to use Java for this purpose? I could find no pointers on this on web, hence posting the question here.
Yes, it is entirely possible.
Any plugin essentially is a set of extensions for several extension points which IDEA API provides. These extensions are regular java classes implementing predefined interfaces, and these classes are referenced to in the manifest. Also, you can bundle any libraries along with the plugin. So, if your language of choice allows implementing interfaces and finding out resulting class names, then nothing prevents you writing plugins in it.

maven-nar-plugin vs native-maven-plugin, which is better?

I am going to create a java project that uses JNI. I want to deploy the project as a stand-alone application, but some modules might be used as libraries of other applications as well.
I want to support different platforms and everything should be as painless as possible.
As far as I can see, I have the choice between the maven-nar-plugin, which wasn't updated for one and a half year now, and the native-maven-plugin, which seems less user friendly to me.
Do you have any experiences with one of them or recommendations which I should use?
I've only used the maven-nar-plugin for standalone C/C++ apps, but it's worked very well for that.
As for JNI, I've been using the native-maven-plugin for a few years now on a sizable application. We use it to allow our Java apps to interface with other applications that only offer C APIs. I've actually found it pretty user-friendly. The documentation is pretty good and explains basic usage, but you still have to deal with the C compiler and linker and whatever options that are required for building.
We just pass it the compiler and linker commands and options, the source location, and the javah file locations and it works. I have to say that with all of the pain we've been through with JNI, the maven plugin is one of the few things that hasn't been a big hassle.
The third slide in this presentation about the NAR Plugin by Mark Donszelmann of the Stanford Linear Accelerator Center compares the native-maven-plugin and the maven-nar-plugin. Quoting from slide 3, the pros and cons of the native-maven-plugin:
Pros
Very configurable
Cons
Did not run out of the box (no defaults)
No binary dependencies
Not cross platform (different profiles for different platforms)
I've used a lot native-maven-plugin since one year to cross-compile C and C++ source code (with a profile for each platform options like compiler, compiler options, linker options, etc...).
It works like a charm but I feel pretty alone in my situation.
Now, I don't understand why C/C++ developper still use make or cmake tools from an other era.
Maven is so better for managing versions and dependencies...

Compiling multiple Java packages with TextMate

I've recently been converted to TextMate as a diverse and powerful programmer's tool. But it appears to be lacking in Java support. So, I've been trying to mess around with the supplied Java bundle (Compile & Run) but it only contains one line:
javamate_bootstrap.sh
I can't find this file on my machine, but it appears to only work for simple Java classes (ie, classes not contained within a package).
First of all, why is TextMate so useless for Java programming, and secondly (and most importantly) : Does anyone know of a bundle I can use, or have instructions on how to create one for larger scale Java development in TextMate?
Thanks in advance.
First of all, why is TextMate so useless for Java programming
Mostly because there are three free (free as in beer) java IDE's, IntelliJ IDEA, NetBeans and Eclipse that almost all professional java developers use. Any one of them will give you all the functionality you want out of TextMate and much, much more. Given that, there's not much demand for java features in TextMate or BBEdit, or Notepad++, etc. That's not to say people don't use them. They definitely do, but not in a high enough volume to make it worth it to the maintainers to add features to make java development easier.

Should I use Jython, JRuby, Beanshell, Groovy, Rhino, or what for this small task?

I have some batch data-manipulation scripts which support a small business website.
The scripts are a "rat's nest" of Perl, Java, and Stored Procedures, which run on a scheduled basis to update data based on various sources and algorithms.
I want to get rid of the Perl so that I can at least take advantage of transaction management by containing the entire process in a JVM-managed database connection from start to finish.
Which of the various Java dynamic/scripting language should I leverage which will meet the following criteria:
Straightfoward to migrate Perl code by providing similar expressive power, I/O, regex's, etc.
Good IDE support, including code completion and debugging preferably in Eclipse
Easy to install. Preferably the entire scripting engine should be in a single jar file.
Not an orphaned technology. I want to pick something that will still be around in 5 years.
Of course - clean integration with the rest of the Java code that I already have.
I hope my criteria are clear enough that this does not get tagged as a subjective question.
For me this is definitely a programming question. I see all those languages as just "useful java libraries".
Thanks!
To be fair, Jython, JRuby, Groovy would all be good choices. They all have the decent IDE support, and the syntax is as expressive, and more succinct than Perl. (Python and Ruby both owe a debt to Perl in their conception, so porting from Perl isn't too much of a headache)
Of course, Beanshell and Javascript (in the form of Rhino) will be adequate too, although I'd say that both their syntaxes are less expressive.
Judging on current usage trends, I'd say Jython and then JRuby would probably be the two with the most general support / longevity, in relation to the others.
Really the choice comes down to your level with each of these languages, but of all of them I'd suggest you use Jython, but if your more comfortable with Ruby, JRuby.
I vote Jython since it can interact with existing Java code and it's got a strong support base. Not mention its Python which is easy to learn and use. Eclipse has pretty good support for syntax highlighting, debugging, and auto-complete. Finally the install is super easy since it's a stand alone folder (no real "install").
I'll admit bias since I have used the other tools you mentioned much less than I have Jython but I have not needed to since Jython has fit the needs so well.
I should say that that several benchmarks indicate that Groovy is wins in speed, compared to Jython and BeanShell. The test was performed using DMelt (http://jwork.org/dmelt) framework where you can jump from one language to another, calling same Java libraries.

Which programming languages can I use on Android Dalvik?

In theory, Dalvik executes any virtual machine byte code, created for example with the compilers of
AspectJ
ColdFusion
Clojure
Groovy
JavaFX Script
JRuby
Jython
Rhino
Scala
Are there already working versions of bytecode compilers for Dalvik available for other languages than Java?
At launch, Java was the only officially supported programming language for building distributable third-party Android software.
Android Native Development Kit (Android NDK) which will allow developers to build Android software components with C and C++.
In addition to delivering support for native code, Google is also extending Android to support popular dynamic scripting languages. Earlier this month, Google launched the Android Scripting Environment (ASE) which allows third-party developers to build simple Android applications with perl, JRuby, Python, LUA and BeanShell. For having idea and usage of ASE, refer this Example link.
Scala is also supported. For having examples of Scala, refer these Example link-1 , Example link-2 , Example link-3 .
Just now i have referred one Article Here in which i found some useful information as follows:
programming language is Java but bridges from other languages exist (C# .net - Mono, etc).
can run script languages like LUA, Perl, Python, BeanShell, etc.
I have read 2nd article at Google Releases 'Simple' Android Programming Language . For example of this, refer this .
Just now (2 Aug 2010) i have read an article which describes regarding "Frink Programming language and Calculating Tool for Android", refer this links Link-1 , Link-2
On 4-Aug-2010, i have found Regarding RenderScript. Basically, It is said to be a C-like language for high performance graphics programming, which helps you easily write efficient Visual effects and animations in your Android Applications. Its not released yet as it isn't finished.
Scala works very well.
I'm programming my Android application projects in Scala (Website written in Chinese with some screenshot, source code # GitHub), and it is pretty easy to setup the evnviroment (without IDE, using SBT as build tool).
It could access every API in Android SDK, so anything you could do in Java, you could do it in Scala too.
You may check this blog entry to see how to build Android application with Scala and SBT.
Kawa is a lovely but little known variant of Scheme that has existed quietly for many years and runs on both the JVM and Dalvik, natively. Therefore, its output includes no extra VM and only includes explicitly imported libraries. To the end-programmer, this means Kawa's performance and executable size are nearly identical to standard Java (ProGuard not required).
Kawa also includes lots of macros (including some specific to Android APIs) that make for a nice clean syntax (assuming one is not averse to parentheses), and adds some tasty goodies on top of Scheme, like "promises" (lazy eval and futures in one). The language is quite robust and well-documented, and has been actively maintained and evolving since the early days of Java.
The Java Advent Calendar summarizes Kawa's merits with some informative examples and links.
I haven't played with it but I know that Scala works.
http://www.scala-lang.org/node/160
Another JVM language that works on Android is Kotlin with Anko, both from Jetbrains.
Mercury also works on Android, using its Java backend. I've written a simple app that should help someone get started (there are still few other examples), and mercury-android-helper also for this purpose (although at this exact moment, it's short a few commits. And neither are using ProGuard yet, so the .apk size is shocking.)
Although the other posts here are cheerful about Scala-on-Android, posters in Scala forums are more concerned by Scala's ability to blow through some of Dalvik's limitations, and people who do use it say they reserve it for non-production code. (Some discussion about Scala's problems here.)
I can't say yet if Mercury has its own problems with Dalvik, but I've switched to it from Scala for the time being.
The dynamically typed languages wont be possible until Dalvik supports JIT (Just In Time) compiling. I believe there is JIT support in one of the experimental Eclair branches, but it is not yet officially available/supported in Android.
1) Angular + nativeScript
2) Reactnative

Categories

Resources