Emacs for web-developers

May 26th, 2007 by core

I wrote before about configuring Emacs to ease development in Ruby and Rails. But that is just a small part of the web-developer community out there.

Most websites out there still use PHP for their daily dose of web-development. In order to get the most out of Emacs in this situations there are a couple of modes that becomes a must-have:

Tramp mode
TRAMP uses remote shells to access files on remote servers. For instance opening a file using the following command C-x C-f /192.168.1.2:public_html/test.php will actually ask you for a password on 192.168.1.2 (if necessary) and will utilize ssh/scp to retrieve the test.php file. Any changes you perform on the file are stored directly on the server.
nXhtml mode
nXhtml mode is an extension on nxml-mode which allows you to edit xhtml files interleaved with other code fragments, like CSS, Javascript and PHP. Through the use of multiple major modes (MuMaMo) it makes the mode associated with each code fragment the major mode when editing that particular area so you can utilize the full power of those modes, for instance CSS’s attribute expansion.

Also the ability to edit XHTML fragments with full validation becomes extremely useful when writing blog posts ;)

The nXhtml website has some great screenshots.

Mewde
I personally have not tried this mode yet, however judging from the website it promises great power and usability to the web-developer so I did not want to leave it out. If you have used Mewde, please let me know how you liked it.
Snippet
Also utilized in the Ruby modes, snippet allows you to define commonly used structures and utilize them as abbreviations, much like the TextMate snippets work, a must have module for any developer really.

These are but a few modes that make my life easier when doing web-development. If you know of more, then please leave a comment below.

Posted in Emacs, ruby, modes, css, php, javascript, xml | No Comments »

TeX on the mac

May 22nd, 2007 by core

If you want to write LaTeX/TeX documents on the mac, check out this page.

Posted in Random | No Comments »

Autotools vs plain Makefiles

May 12th, 2007 by core

I always thought the autotools were the greatest invention ever when it comes to build systems. You just defined your configure.ac, your Makefile.am and include some m4 macros.

However I found out the hard way that the beauty of this system is also its undoing. If you want to build agains an unsupported version of a library or if the m4 macros are broken on a particular system it becomes a nightmare.

So searching the net for some alternatives you get dazzled by the amount of work around systems or alternative build systems. Jam for instance seems like a very good build system and I have used it in the past. Boost also utilizes Jam, only they have made their own version, which kinda defeats the point ;)

In the end, for my current project I am just sticking to plain Makefiles. At the top level you defined a Makefile that has all the configuration options and all other intrincacies are stashed away in the Makefiles at each level. This is basically how FreeBSD also does their build system.

The only problem is the dependency tracking of files, luckily gcc comes to the resque there by allowing the compiler to tell you what dependencies there are and you can capture those in a file which is included by the makefile, and thus having a somewhat automated dependency generation going on:

c++ -DMAKEDEPEND -M -I. -m64 -Wall -D_REENTRANT -fPIC -g  Main.cxx

All in all I am a happy coder again with a well working, non-surprising build system; Yeah for GNU make! :)

Posted in Code, Linux, c++, cpp | No Comments »

Emacs pages updated

May 5th, 2007 by core

I noticed that the Emacs pages over at gnu.org have been updated. The most promising addition is the Tour page which tells potential users about the basic functionality of Emacs.

Great job guys/girls!

Posted in Emacs | No Comments »

The perfect, free, digital photography setup

April 28th, 2007 by core

Digital photography is hot, just look at all the different sites where people can share their photos. However, when you get a little more serious about photography you quickly run into an expensive area of software packages. Just do a search for image organizers, image manipulation programs (Adobe Photoshop being by far the most popular). So, what if you just bought your nice little camera and you want to experiment without making all the costs?

Here is my setup which is very usefull and most of all free:

  1. An free operating system, I suggest Ubuntu version 7.04 or higher
  2. Install an image organizer F-Spot which already has a lot of features, including a Flickr upload feature.
  3. You will want to use The Gimp to perform image manipulations, it is similar to Adobe Photoshop.
  4. If you shoot in RAW mode you will want to install ufraw and gimp-ufraw (a gimp plugin) which allows you to load a variety of RAW formats (my Nikon D50 raw files are perfectly supported).

You now have a full setup to work with digital photographs. While you are at installing software, make sure you also install a backup program to ensure the safety of your digital photographs.

Posted in Linux, Digital, Photography, Nikon, D50 | No Comments »

2 frameworks to watch

April 22nd, 2007 by core

Rails is hot, but the Java guys are making it even hotter! Watch out for http://shale.apache.org/ and http://www.jboss.com/products/seam … ok, so I am biased :)

 Looks like rapid web app development is kicking in gears in the Java world, should make for interesting times..

Posted in Java, rails | No Comments »

Putting ACE Streams to use

April 9th, 2007 by core

In many applications you often want to perform a series of operations on data. Normally you would just chain a bunch of method calls that pass along the data, however, as anyone realizes, this approach is far from ideal.

The ACE library contains something called Streams which allows you to utilize the ‘Pipes and Filters’ pattern. You basically create a set of ACE_Tasks that perform isolated operations on the data. Then you bind these ACE_Tasks to corresponding ACE_Modules which in turn get pushed onto an execution stack in the ACE Stream.

Since each task extends an ACE_Task you can easily change the object into an Active Object by simply calling activate in the open method:

1
2
3
int LogOutputTask::open(void*) {
    return activate();
}

From that moment on the task runs in its own thread of control and will respond to messages passed onto its message queue from ACE_Tasks earlier in the chain. This allows for the decoupling of input and processing.

Since the required ACE_Modules are all so very similar, it is quite easy to create a template that allows for creation via a macro:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef BASEMODULE_H
#define BASEMODULE_H
 
#include <ace/Task.h>
#include <ace/Module.h>
#include <ace/Thread_Manager.h>
#include <ace/OS_NS_string.h>
 
template <class TASK>
class BaseModule : public ACE_Module<ACE_MT_SYNCH> {
public:
    BaseModule(const ACE_TCHAR *name) {
        // Open only writer side, ignore reader side task
        this->open(name, &task_, 0, 0, ACE_Module<ACE_SYNCH>::M_DELETE_READER);
    }
 
private:
    TASK task_;
};
 
#define BASEMODULE(NAME) typedef BaseModule<NAME> NAME##Module
 
#endif // BASEMODULE_H

This module only uses the writer side of an ACE_Module, which means that ACE automatically creates an ACE_Thru_Task on the reader side which just passes on the message without modification, making it a one way street.

The example code which comes with ACE has a good example in the C++NPv2 directory, in the file display_logfile.cpp.

Posted in c++, ACE, patterns, cpp | No Comments »

Assembly based XML parser

April 1st, 2007 by core

For years the movement of portable data structures to XML has been going on. XML is used everywhere, from storage to domain specific language implementations (look at hibernate for instance), and as most programmers realize it is an absolute pain when it comes to performance; parsing XML is just slow.

I have joked with past colleagues about writing XML/SOAP processors in assembly before, since that will get the most speed out of the machine wrt processing the XML, but it was always left at joking.

Now I ran into AsmXml, an actual XML parser written in x86 assembly and it is fast as a bat out of hell, pushing throughput on the benchmark machine to 200MB/s and extreme low parsing times, 1000 ms for a 10 MB XML file, see the benchmarks on the homepage for more information.

Absolute respect to the programmer!

Posted in Code, asm | No Comments »

ACE Logging

April 1st, 2007 by core

I have done some work with ACE in my spare time and one of the greatest things, besides it being the top of the line framework for network applications, is its logging facilities.

A great article explaining this facility in-depth is at the aw professional website, taken from the ACE Programmer’s Guide.

Posted in Code, c++, ACE | No Comments »

Making a better IDE

March 24th, 2007 by core

This article is not intended to insult any project or point fingers, it is my opinion and mine alone, that is my disclaimer.

Emacs is, according to its users (me included), the most powerful editor currently available. I use it to write code, blog posts, documentation and many more things. However I often miss the things that make IDEs like Eclipse or Visual Studio so attractive to use.

A small list:

  • Project centric facilities
  • True context sensitive code completion
  • Context sensitive documentation lookup
  • Edit time error / improvement indication
  • Refactoring tools

These are a few things that make life in an IDE good. You define a project and its dependencies, and all these features become accessible. Anyone using IDEs will tell you that it is an absolute pain to setup and manage configurations on large projects. Take a Java based multi module project in eclipse for instance, since Eclipse does not have multi module support you are forced to create multiple projects and manage their dependencies. Granted, tools like maven simplify this task greatly, but it is still very time consuming.

Jetbrains has the best IDE as far as I am concerned, although it still is a pain to setup when you need to do some more complex things, but perhaps the closest to Emacs editing power in their area; multi module projects, settings per project, good intelligence to aid the developer and a good plugin api and automated plugin installation.

So, how could we make this situation better? I want to use Emacs for my code editing, simply because of its extensibility and powerful editing features, but I also want the things in my above list and I want it for as many languages as possible.

CEDET provides some great tools for semantic analysis of code, but I believe it can do much better. I have been studying ANTLR, a parser generator, and came to the following ‘draft’ conclusion.

What we need is a domain specific language (DSL) to specify language agnostic projects which can be used inside Emacs to create the project centric nature for editing files.
To ‘understand’ the actual files inside a project we would need a parser/lexer that generates a language agnostic description of each source file that can easily be read by an LISP based engine, to provide context sensitive intelligence in any languages (which methods are defined on the current object, which fields are accessible from he current scope, is the variable assignable with the return type of the method called, etc.). This is wat Semantic does now, but moving the creation of this intermediate form outside of Emacs as a companion program will make it that Emacs can focus on editing and providing information.

In the realm of Java, C and C++ editing, xrefactory provides this means, which works really well, however it needs yet another configuration file and currently it is poorly maintained except for the C++ functionality (which is where they make their money).

So, what do I actually want? I want to create a program that provides Emacs with the information that describes

  • syntax highlighting rules for each language and the required editing mode
  • validity of the currently edited document
  • improvement notes in the current document
  • completions within context of the request
  • documentation within context of the request
  • refactoring
  • Seamless debugging support

If you take a list of Emacs modules that provide you with each little bit of the described functionality, you can get a long way, however most of these projects are not up to speed with the current world. Java has JDEE and xrefactory, both suffer greatly in Java 1.5 and up and cannot give you things like code completion anymore. C and C++ have great modes in Emacs, but code completion is far from usefull as well as documentation support. So it is time to start over, learn from the past and bring these features up to par with the rest of them.

I have begun designing a new set of modes and programs to actually start this work. But what I am more curious about is how you feel about the current state of Emacs as an IDE and what you want to see changed.

Posted in Code, Emacs, Java, c++, modes, ideas | 1 Comment »

« Previous Entries