Saturday Sep 06, 2008

Things To Do in Coming Months

As the beta of Scala for NetBeans released, I found I have several things to do in the coming months.

First, I'll keep the Scala plugins going on, I'll try to re-implement the Project supporting, which, may be an extension of current NetBeans' plain Java Project, that is, you just create plain JSE or JEE project, then add Scala source files to this project, you may mix Java/Scala in one project. Another perception is, it's time to re-write whole things in Scala itself? I have a featured Scala IDE now, or, the chicken, I should make eggs via this chicken instead of duck.

Second, we get some contracts on mobile application for Banking, which, will be implemented via our current Atom/Atom Publish Protocol web service platform. The platform is written in Erlang, but, with more and more business logical requirements, maybe we should consider some Scala things?

Third, oh, it's about AIOTrade, I'v left it at corner for almost one and half year, I said it would be re-written in Scala someday, I really hope I have time. I got some requests to support drawing charts for web application, it actually can, if you understand the source code, I just wrote an example recently, I may post an article on how to do that.

Thursday Aug 14, 2008

Scala for Netbeans Beta Is Ready, Working with NetBeans 6.5 Beta

>>> Updated Aug 15:
For Windows Vista users: There is a known bug #135547 that may have been fixed in trunk but not for NetBeans 6.5 Beta, which causes exception of "NullPointerException at org.openide.filesystems.FileUtil.normalizeFileOnWindows" when create Scala project. If you are Vista user and like to have a try on Scala plugins, you may need to download a recent nightly build version of NetBeans. Since I have none Vista environment, I'm not sure about above message.
======

I'm pleased to announce that the first beta of Scala for NetBeans is released, followed NetBeans 6.5 beta releasing. The availability and installation instructions can be found at http://wiki.netbeans.org/Scala.

Features:

  • Full featured Scala editor
    • syntax and semantic coloring
    • outline navigator
    • code folding
    • mark occurrences
    • go to declaration
    • instant rename
    • indentation
    • formatting
    • pair matching
    • error annotations
    • code completion
  • Project management (build/run/debug project)
  • Debugger
  • Interactive console
  • JUnit integration
  • Maven integration (works with Lift Web Framework)

There are some known issues. Bug reports are welcome.

Installation on NetBeans 6.5 beta:

  1. Get the NetBeans 6.5 beta or later version from: http://download.netbeans.org/netbeans/6.5/beta/
  2. Get the Scala plugins beta binary from: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=11854
  3. Unzip Scala plugin binary to somewhere
  4. Open NetBeans, go to "Tools" -> "Plugins", click on "Downloaded" tab title, click on "Add Plugins..." button, choose the directory where the Scala plugins are unzipped, select all listed *.nbm files, following the instructions. Restart IDE.

Tuesday Jul 29, 2008

Run/Debug Lift Web App Using Scala/Maven Plugin for NetBeans

I'm a newbie to Maven, so I encountered some issues when run/debug Lift apps. The following are tips that I got, it may not be perfect, but at least work.

1. When pom.xml is changed, and classes not found errors happen on editor, you can close and reopen the project

This is a known issue, that I didn't refresh compiling context when pom.xml changed, thus the classpath dependency may be not refreshed at once, I'll fix this issue in the near future.

2. Run project by external Maven instead of embedded Maven of NetBeans plugin

I encountered "java.lang.NoClassDefFoundError org/codehaus/plexus/util/DirectoryScanner" when use embedded NetBeans Maven plugin (3.1.3) when invoke "Run" project, but fortunately, you can custom the binding actions in NetBeans Maven. The steps are:
  1. Right click project node, choose "Properties"
  2. Click on "Actions" in left-pane, choose "Use external Maven for build execution", and "set external Maven home"
  3. Choose "Run project" in right-pane, input "jetty:run"
  4. Choose "Debug project" in right-pane, input "jetty:run"

3. How to debug project

I'm a bit stupid here, since I don't like to change MAVEN_OPTS frequently. So I choose to do:

$ cd $MAVEN_HOME$/bin
$ cp mvn mvn.run
$ cp mvnDebug mvn

Then I invoke "Debug" action from NetBeans toolbar, and get NetBeans' output window saying:

WARNING: You are running Maven builds externally, some UI functionality will not be available.
Executing:/Users/dcaoyuan/apps/apache-maven-2.0.9/bin/mvn jetty:run
Preparing to Execute Maven in Debug Mode
Listening for transport dt_socket at address: 8000

Open menu "Debug" -> "Attach Debugger...", in the popped window, for "Port:", input "8000". Everything goes smoothly then. You add/remove breakpoints just as you are doing for a regular Scala project.

Of course, if you want to turn back to "Run" from "Debug", you have to "cp mvn.run mvn" back.

Anybody can give me hints on how to get this setting simple? in NetBeans Maven plugin.

Here's a snapshot: (click to enlarge it)

nn

Monday Jul 28, 2008

Scala, NetBeans, Maven, and yes, Lift now

Per recent changes, Scala for NetBeans can live with Maven for NetBeans, and yes, Lift web framework.

The Maven for NetBeans has done an excellent work for Maven's project integration, with proper classpath supporting and indexing. So the Scala editor is well aware of auto-completion, types etc.

Here's a snapshot: (click to enlarge it)

nn

To get above features, you have to download the latest NetBeans daily build, then install Scala's plugins and Maven plugins.

For Scala plugins, see http://wiki.netbeans.org/Scala; For Maven plugins, see http://wiki.netbeans.org/MavenBestPractices.

Saturday Jul 26, 2008

Implementation of Scala for NetBeans based on GSF

The Scala for NetBeans is under pre-beta stage, other than bug-fixes, I'm preparing some documentations for it too. If you are interested in how to write language supporting under GSF's framework, you can take a look at this working documentation.

Implementation of Scala for NetBeans

And also:

Proposal of Scala for NetBeans

Progressing of Scala for NetBeans

Friday Jul 25, 2008

Scala for NetBeans Screenshot#12: JUnit integration

There is a Scala JUnit Test template in Scala for NetBeans now, you can create Scala JUnit testing and run testing, see testing result.

Here is an example test file:

 /*
 * DogTest.scala
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package scalajunit

import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.Assert._

class DogTest {

    @Before
    def setUp() = {
    }

    @After
    def tearDown() = {
    }

    @Test
    def testHello() = {
        val dog = new Dog()
        dog.talk("Mr. Foo")
        assert(true)
    }

    @Test
    def testAdding() = {
        assertEquals(4, 2 + 3)
    }
}

To get JUnit working, upgrade to Scala Project Module version 1.2.14, and re-create a new project for exist old project (if there has been one). Under the "Test Packages", create your testing packages, right click on package node, select create "Scala JUnit Test".

To run tests, right-click on project node, choose "Test".

And also, the beta-release is feature frozen, I'll concentrate on bug-fixes in next 1-2 weeks, and get it ready for public release as beta.

nn

Tuesday Jul 15, 2008

Employ Scala's Native Compiler in Scala for NetBeans

>>> Updated 3 hours later
Fixed document displaying and go to declaration for Java element.
Please update to Scala Editing version 1.1.4
======

Well, it's a fairly long time after I latest blog about Scala for NetBeans. I was busy on several things, and can only work on this project on my spare time.

The good news is that I've integrated Scala's native compiler into this handy plugin, it means that the error messages shown in the editor will be the same as building now. And, the auto-completion feature is totally rewritten too, which also use AST tree that was created by Scala's native compiler to get all the candidate content assistant items.

The only problem is that the Java's document comments and offset to be go to when press CTRL + Click does not work properly yet, I have several way to resolve it, but I'm looking for a best way.

Another exciting news is that I've been invited to join NetBeans Dream Team, and of course, I accepted this invitation.

I'm planning to get Scala plugin for NetBeans to beta release in August, which will be compatible with NetBeans 6.5

Tuesday Jun 10, 2008

Parsing Performance of Scala for NetBeans

I'm re-considering the indexing mechanism of Scala for NetBeans. The indexing is used to store meta-info of parsed templates/methods etc, for auto-completion and document/source offsets searching. Currently, the parsing phases include lexer, syntax and semantic analysis, not include type inference and type check.

With a basic performance testing on all Scala standard library and liftweb's library, the maxima parsing time seems less than 1s, the average parsing time is around 0.2s, not bad.

So, this may let the indexing feature a lot simple, I can store classes/objects/traits' meta-info only, instead of including their type parameters and their members (fields/methods, scoped importing etc), these additional information can be got via re-parsing the source file or querying the class file.

Tuesday May 27, 2008

Bundled Latest Scala Runtime to Scala for NetBeans

I just bundled latest Scala runtime to Scala for NetBeans, the version is 2.7.1.final, this brings two things:

First, you do not need to set SCALA_HOME any more to get whole plugins working. But, you can still set SCALA_HOME to specifying the target Scala version, if so, you should also need to download and unzip source jars to $SCALA_HOME/src;

Second, I'll begin to write some code in Scala instead of Java for Scala plugins. I can evaluate the features of Scala plugins in daily work, find and fix more bugs of plugins.

Friday May 09, 2008

Scala for NetBeans Screenshot#12: Better Completion with More Types Inferred

>>> Updated May 11
Mostly, infix expressions can be type inferred now. CTRL+Click on infix op name, it will bring you to declaration (since 1.0.29.0)
===

Well, the type inference work is not so easy (with performance in mind), but anyway, I've got a bit more progress, at least, the chained member call can now be correctly inferred in a lot of cases. It's some level as Tor's JavaScript for NetBeans now.

First, let's create a val "node", which is a "scala.xml.Node"

nn

Then, input '.' to invoke completion, as I know which type is of "node", the proposal items look good.

nn

I choose "descendant" function (which returns a "List"), and input '.' again, we can see the proposal items look still good.

nn

These features also work on Java's class.

Known issues:

  • It seems the indexing/scanning for Scala standard library source will perform twice when you first installed Scala plugins
  • The type inference is not consistence yet, so don't be strange for the strange behavior sometimes

Again, don't forget to download scala standard library's source jars and unzip to $SCALA_HOME/src, per sub-folder per jar

Thursday May 08, 2008

Which Programming Language J. Gosling Would Use Now, Except Java?

>>> Updated later
Maybe we can get completeness of J. Gosling's opinions about Java/Scaka/JVM from here
===

According to Adam Bien's blog from JavaOne

During a meeting in the Community Corner (java.net booth) with James Gosling, a participant asked an interesting question: "Which Programming Language would you use *now* on top of JVM, except Java?". The answer was surprisingly fast and very clear: - Scala.

I think Fortress will also be a very good future choice when it gets mature.

Saturday May 03, 2008

Scala for NetBeans Screenshot#11: Go to Remote Declaration and Doc Tooltip

Two crazy days of my spare time, I was coding between sleeping and eating, with a lot of cups of coffee. Now Scala plugins support Go-To remote declarations (CTRL + Click on var/function name), and when you put cursor on the identifier name with CTRL pressed, or under auto-completion, the doc will also be shown as tooltip.

These features work for Java classes too with a bit poor performance, I'll fix it later (fixed).

Not all identifiers have been type inferred, so these features are not applicable for all identifiers.

Please update to Scala Editing module as version 1.0.26.xxx when it's available, which is the only stable one these days. Remember to unzip Scala lib's source under $SCALA_HOME/src

nn

nn

Tuesday Apr 29, 2008

Scala for NetBeans Screenshot#10: Working on Auto-Completion for Java

I've done some hacking work to get Java classes to be completion enabled, but it's not full functional. Any way, it's a good start point for auto-completion for Scala plugins, I hope to get more type inference work to be finished, and finally support both Scala/Java classes smart-completion.

Click on the picture to enlarge it

nn

nn

Friday Apr 25, 2008

Scala for NetBeans Screenshot#9: Working on Auto-Completion

With the indexed cache of project's Class/Trait/Object, and Scala standard library's source files, the auto-completion is a bit smarter now. If the val/var is defined with type, the auto-completion can know which methods will be suggested. (Not work for java classes yet)

To get this working, you should follow these steps:

  • Update to newest Scala plugins (Editing version 1.0.21.1)
  • Delete the old-cache files which are located at your NetBeans's configuration directory (for example, .netbeans/dev/var/cache).
  • Download Scala standard library's source file, unzip them to $SCALA_HOME/src, per sub-folder per source jar file

Click on the picture to enlarge it

nn

Friday Apr 18, 2008

New Scala Plugins for NetBeans are Available for Public Test, and Fortress, Erlang

>>> Updated Apr 22
Due to the incompatibly changes of NetBeans underlaying modules, Scala plugins can not be installed/updated on NetBeans 6.1 any more, you should get the latest nightly build to play with Scala plugins.
===

>>> Updated Apr 19

  • Fixed some broken syntax
  • Fixed NPE caused by brace completion
  • Fixed indentation of case class/object
  • Added formatting options ("Preference" -> "Scala" -> "Formatting")
Please update your Scala Editing plugin to version 1.0.19 which will be available after NetBeans hudson building.
===

The new written Scala plugins for NetBeans are available for public test now, which can be installed on NetBeans 6.1 RC, and latest NetBeans nightly build. To get start, please visit http://wiki.netbeans.org/Scala

The following features are ready for test:

  • Syntax highlighting
  • Auto-indentation
  • Brace completion
  • Formatter
  • Outline navigator
  • Occurrences mark for local variables and functions
  • Instance rename for local variables and functions
  • Go-to-declaration for local variables and functions
  • Scala project
  • Basic debugger

And with known issues:

  • Auto-completion it not fully supported yet and not smart
  • There is no parsing errors recovering yet
  • Semantic errors are not checked on editing, but will be noticed when you build project
  • Due to the un-consistent of Scala's grammar reference document, there may be some syntax broken issues

BTW, Fortress editing plugin is also available on "Last Development Build" update center, see the installation part of http://wiki.netbeans.org/Scala to get it installed. It's a very alpha stage plugin.

And, Erlang plugins are also available from "Last Development Build" update center too, that is, you can install and use Erlang plugins with Ruby, Scala, JavaScript on the same NetBeans IDE (6.1 RC or nightly build). Thanks to Tor's work, the indexing performance has been improved a lot.

Erlang plugin will be rewritten in the near future too.