April 14, 2012

VIM & CTAGS for Erlang

I pretty much only use VI(M) for coding and CTAGS is essential to increase productivity – It makes it easier to jump through files when I need to look at a function or where some variable has been declared, amongst other things. I have been using CTAGS for years when I was coding in C, Java and most recently PHP, Python and Erlang.

Here are the steps to enable CTAGS for Erlang on Mac OS X:

1) Install the latest version of Exuberant ctags

You need to install “Exuberant Ctags” which is an enhanced CTAGS implementation of the GNU CTAGS.

Exuberant ctags make it possible to jump to the definition of a class, method, variable and any other language object (e.g. C, C++, Python, PHP, Erlang) in vim. ‘ctags’ is able to generate an index file (a.k.a tags file) for one of 41 supported programming languages. Index can be used by editors like vim to quickly find related keyword.

sudo port -v install ctags

2) Check installed version is correct (5.8)

ctags --version

 Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
 Compiled: Mar  6 2012, 23:30:52
 Addresses: <dhiebert@users.sourceforge.net>, http://ctags.sourceforge.net
 Optional compiled features: +wildcards, +regex

3) Check if the right ‘ctags’ is in the path

which tags
It should show:

/opt/local/bin/ctags

/opt is where Macports install bundles

4) Install Taglist VIM extension script:

Download taglist.zip and unzip the files to the $HOME/.vim

5) Go to the root of the project you want to generate CTAGS for

cd /projects/my_erlang_root_project_dir

6) Generate tags recursively

ctags --file-scope=no -R --languages=erlang .

7) Edit your .vimrc and add the following at the end

let Tlist_Use_Right_Window=1
let Tlist_Enable_Fold_Column=0
let Tlist_Show_One_File=1 " especially with this one
let Tlist_Compact_Format=1
let Tlist_Ctags_Cmd='/opt/local/bin/ctags'
set updatetime=1000
nmap ,t :!(cd %:p:h;ctags *)& " Maps the updates of tags to key ,t.
set tags=tags; " The ';' at the end will cause the ctags plugin to search for current dir and above dirs until it find a tag file.

" Add the following below if you want to generate ctags upon saving a file
" Auto-generate ctags upon making changes to a file
autocmd BufWritePost *.erl :silent !(cd %:p:h;ctags *)&

" If you want to auto compile (erlc) upon saving a file, then add that one as well
" Run erlc on the file being saved
autocmd BufWritePost *.erl :!erlc <afile>

8) Basic Usage

Basic usage boils down to 3 commands:

   ctrl-] takes you to the declaration of a keyword your cursor is currently over.
          Jump is made so it doesn't matter in which file it is defined. Keyword is put on the tag stack.
   ctrl-t takes you a step back in the tag stack.
   ctrl-w w toggles the keywords list window.

Additional resources:
http://ctags.sourceforge.net/faq.html#15
http://www.zalas.eu/jumping-to-a-class-function-and-variable-definitions-in-vim-with-exuberant-ctags
http://www.thegeekstuff.com/2009/04/ctags-taglist-vi-vim-editor-as-sourece-code-browser/
http://linux.byexamples.com/archives/385/vim-with-ctags-for-multi-level-directory-hierarchy/
http://ctags.sourceforge.net/

I use a gentags.sh script that I have customized a bit and put in my ~/bin – It generates tags in individual directories and I just run it initially to create all the tags, then I use ,t key in vim to update the tags for a directory where I have modified/added/removed content in a source file or have it done automatically using the ‘autocmd’ explained above. If you want the gentags.sh file, let me know and I can make it available.

Happy Erlang Tagging! 🙂

April 1, 2012

Google Maps 8-Bit! :)

Gotta love it – Especially the street view 😉

March 26, 2012

Back to the Blogosphere…

Well, it has been a long while since I blogged about anything. Have I felt bad about it? certainly not, but the one thing I miss about is sharing things that I think are really worthwhile mentioning.

My Java.net blogs seem to have survived.

In any case, I hope to be adding some interesting content very soon – I have been working on very cool and exciting stuffs for the last 2 years. More soon.

Videbo vos mox

September 22, 2009

Videos to get acquainted with Apache Derby and Java DB

javadb.png

derbyLogo.png

Kristian Wagaan and Richard Hillegas, both Apache Derby committers who also work on Java DB, recently gave some great presentations about Apache Derby and Java DB.

Kristian Wagaan presented at the 2009 OpenSQLCamp, in conjunction with FrOSCon 2009 in Europe.

The presentation (slides) gives a brief overview of Apache Derby, its history and the community around it. Further, it goes into the details of features that have been added in the latest releases and show how they enable powerful ways to use a relational database.

Rick Hillegas gave an introduction of Java DB / Apache Derby at The San Francisco Java User Group’s Sep 8th event in San Francisco.

September 14, 2009

Java DB 10.5.3 is now available

Following the release of Apache Derby 10.5.3, Java DB which is Sun’s supported version of this last one is also now available.

Java DB 10.5.3 is primarily a bug-fix release and inherits all the bug fixes and localized messages from Apache Derby 10.5.3.

Java DB offers installers for the following platforms:

  • Solaris
  • Linux
  • Windows
  • Mac OS X (newly added)

Here is a recap of all changes that are coming as part of Java DB 10.5.3:

  • SQL Roles – SQL roles (as described in SQL
    2003 and errata) are useful for administering privileges for groups of
    users. Administering roles is generally less error-prone than
    administering privileges for individual users. SQL Roles are defined in
    Feature T331 "Basic roles" and Feature T332 "Extended roles". Java DB
    10.5 implements a subset of T331, plus support for CURRENT_ROLE, which
    is a part of T332.

  • Generated Columns – Generated Columns is a
    feature which instructs Java DB to fill a column with an expression
    built out of other columns in the row. Java DB constructs these column
    values at INSERT and UPDATE time. The user declares indexes on these
    columns. This in turn improves SELECT performance since it lets users
    declare indexes on pre-computed pieces of the WHERE clause. This
    feature satisfies support for SQL Feature T175.

  • LOB Improvements – There were many performance and usability improvements for BLOBs and CLOBs.

  • Replication of encrypted databases – With 10.5 it is possible to replicate encrypted databases.

  • OFFSET/FETCH FIRST – SQL 2008 has added new
    syntax to support a direct way to limit the returned set of rows in a
    result set, through the fetch first and offset clauses.

  • In-memory back end – Initial implementation of
    a storage engine for Java DB where all data is kept in memory. There is
    no documentation for this feature. This functionality itself is not yet
    fully implemented, but users are welcome to experiment with it. For
    details, see the Primer for In-memory Back Ends.

  • Standard ALTER COLUMN syntax – Allow standard
    SQL "SET" keyword in ALTER COLUMN syntax, like so: "ALTER TABLE ALTER
    COLUMN columnname SET DEFAULT default-value"

  • SYSCS_UTIL.SYSCS_UPDATE_STATISTICS
    New system procedure that updates cardinality statistics (or creates
    them if they do not exist) for a table’s index or for all the indexes
    on a table, allowing a user to ensure that a query plan based on the
    most recent state of the table can be created.

  • Service tag – Introduction of the Java DB registration service (service tag).

Further details on new features, changes, and issues in this release can be found in the Release Notes.

August 26, 2009

Apache Derby 10.5.3 Bug-Fix Release is now available!

The Apache Derby project is pleased to announce a new bug-fix release of Derby, 10.5.3.0.

Apache Derby is a subproject of the Apache DB project. Derby is a pure
Java relational database engine which conforms to the ISO/ANSI SQL and
JDBC standards. Derby aims to be easy for developers and customers to
use.

Derby 10.5.3.0 can be obtained from the Apache download site:
http://db.apache.org/derby/derby_downloads.html

Derby 10.5.3.0 contains many bug fixes plus localizations for messages
added in the previous feature release, 10.5.1.1.

10.5.3.0 replaces
10.5.2.0, which introduced a query-ordering regression.

Here is the list of bug fixes addressed in 10.5.3.

May 29, 2009

Java DB at CommunityOne and JavaOne 2009

 

The Java DB team will be at CommunityOne and JavaOne 2009 next week.

Feel free to come and visit us at the Java DB POD and share feedback with us. You might even get a nice T-Shirt 😉

We will show demo’s of new features, including some nice JavaFX application using Java DB / Apache Derby.

May 29, 2009

Java DB 10.5.1 now available

The Java DB project is pleased to announce a new feature release of Java DB 10.5.1.

Java DB is Sun’s branded distribution of the Apache Derby open source  database. Java DB is a pure Java relational database engine which conforms to the ISO/ANSI SQL and JDBC standards. Java DB aims to be easy for developers and end-users to work with.

Java DB 10.5.1 can be obtained from the Java DB download site:
http://developers.sun.com/javadb/downloads/index.jsp

Java DB 10.5.1 introduces the following new features and improvements:

  • In-memory databases for test rigs and transient data
  • Replication of Encrypted Data for failover of sensitive databases
  • OFFSET/FETCH FIRST for paging through query results efficiently
  • SQL Roles for administering fine-grained access controls
  • Generated Columns for speeding up queries by pre-computing results
  • LOB Improvements for speeding up access to large binary and text objects
  • Optimizer Statistics Improvements for better management of query plans

Java DB offers the following: 

  • Installers for various platforms
  • Support offering (more info)
  • Notification of new releases and updates via registration
  • Native Netbeans integration
  • Bundled in GlassFish and Sun JDK6

If you are interested in learning more or/and sharing feedback about Java DB, please come and visit us at our POD during CommunityOne and JavaOne 2009.

May 1, 2009

Apache Derby 10.5.1.1 Feature Release is now available!

The Apache Derby project is pleased to announce a new GA feature release
of Derby, 10.5.1.1.

Apache Derby is a sub-project of the Apache DB project. Derby is a pure
Java relational database engine which conforms to the ISO/ANSI SQL and
JDBC standards. Derby aims to be easy for developers and end-users to
work with.

Derby 10.5.1.1 can be obtained from the Derby download site:
http://db.apache.org/derby/derby_downloads.html.

It contains the following new features:

  • SQL Roles – SQL roles (as described in SQL 2003 and
    errata) are useful for administering privileges for groups of users.
    Administering roles is generally less error-prone than administering
    privileges for individual users. SQL Roles are defined in Feature T331
    "Basic roles" and Feature T332 "Extended roles". Derby 10.5 implements
    a subset of T331, plus support for CURRENT_ROLE, which is a part of
    T332.
  • Generated Columns – Generated Columns is a feature
    which instructs Derby to fill a column with an expression built out of
    other columns in the row. Derby constructs these column values at
    INSERT and UPDATE time. The user declares indexes on these columns.
    This in turn improves SELECT performance since it lets users declare
    indexes on pre-computed pieces of the WHERE clause. This feature
    satisfies support for SQL Feature T175.
  • LOB Improvements – There were many performance and usability improvements for BLOBs and CLOBs.
  • Replication of encrypted databases – With 10.5 it is possible to replicate encrypted databases.
  • OFFSET/FETCH FIRST – SQL 2008 has added new syntax to
    support a direct way to limit the returned set of rows in a result set,
    through the fetch first and offset clauses.
  • In-Memory back end – Initial implementation of a
    storage engine for Derby where all data is kept in memory. There is no
    documentation for this feature. This functionality itself is not yet
    fully implemented, but users are welcome to experiment with it. For
    details, see the Primer for In-memory Back Ends.
  • Standard ALTER COLUMN syntax – Allow standard SQL
    "SET" keyword in ALTER COLUMN syntax, like so: "ALTER TABLE ALTER
    COLUMN columnname SET DEFAULT default-value"
  • SYSCS_UTIL.SYSCS_UPDATE_STATISTICS – New system
    procedure that updates cardinality statistics (or creates them if they
    do not exist) for a table’s index or for all the indexes on a table,
    allowing a user to ensure that a query plan based on the most recent
    state of the table can be created.

In addition, Derby 10.5.1.1 contains many bug and documentation fixes.

Java DB, which is Sun’s distribution of Apache Derby should be available as a 10.5.1.1 release level very soon.

March 27, 2009

Java DB Articles and Interviews with Masood Mortazavi, Engineering Manager

Amongst the recent updates to Java DB’s portal, I recommend reading these 2 great interviews of Masood Mortazavi, engineering manager for Java DB.

You can also find a various selection of technical articles, tips and white-papers.

If you are using Netbeans, this article will show you how to use Java DB more effectively inside this IDE.