A Blog about Software Development. Software development is the act of developing a software product.
Saturday, December 29, 2007
From dev to politics: I am taking part of Fox News boycott
http://www.debone.com/boycottFoxNewsSponsors.html
Cool links, cool projects
http://wiki.apache.org/lucene-hadoop/Hbase
Project Euler, enough said.
http://projecteuler.net/index.php
And LLVM.
http://ocamlnews.blogspot.com/2007/12/jit-compilation-from-ocaml-using-llvm.html
Why botlist sucks but doesnt suck as bad?
I look at other web 2.0 applications and shake my head in amazement at the uselessness of the various public tools. Twitter is a good example. It will probably receive a lot of funding and the twitter team will come up with a snazzy implementation, but the original concept is pretty useless. Some have called twitter a micro-blog. A blog is worthless (yes, including this one), a micro-blog is worthless times two. Why is it worthless? Isn't it obvious; who cares what you had for breakfast, or that you just got back from the mall. It is kind of funny how PC magazine editors spin twitter into gold because some silicon-valley investor told them to. "twitter!!! it is gold, baby, roll with it"
I don't have any ill will against twitter; twitter is just my reference example of the misguided web2.0 world. I feel the same way about facebook, del.icio.us, myspace, and clones.
Good Web 2.0 Apps/or other projects
Flickr
Google-* (maps, docs, etc)
Reddit (digg, you are skating on thin ice)
Wikipedia
Suspect Web 2.0 Apps
MySpace
Thank god no-one reads my blog?
Friday, December 28, 2007
Made it through some of the Project Euler examples
http://haskellnotebook.googlecode.com/svn/trunk/haskell/euler_problems/set1/
http://projecteuler.net/
Thursday, December 27, 2007
Short Post, an working example for a meta language with Antlr 3.0+
In any case, I was working on a grammar for my botlist remote definition file and threw together a grammar. The full source is available and it will parse an example grammar and print out critical tokens and values.
http://groups.google.com/group/jvmcookbook/browse_thread/thread/14b60345c6da2cbb
Saturday, December 22, 2007
Berlin from Dallas, going after text analysis
So over time, I hope to look at text analysis utilities including some simple natural language parsing; noun/verb parsing. From there, who knows.
Recent Resources
http://www.ibm.com/developerworks/library/wa-lucene/
Anagram Trees
Friday, December 21, 2007
New site, botnode.com
http://www.botnode.com/newspirit/
Moved newspiritcompany.com to the new host botnode (be warned, some of the project did not mirror correctly).
Tuesday, November 27, 2007
Web requests with the Haskell HTTP library
Web development work can exist at the server level but it can also exist at the client level. You may need to build a simple HTTP load test framework or test if a particular web application or page is available. It is also possible that you need to upload files. I have built a couple of simple HTTP frameworks in Java and Python but this be a first attempt at Haskell based framework. Actually, in this small example; there isn't much of a framework but just an example on how to use the most recent HTTP library update.
Install the HTTP library
It seems that GHC Haskell release 6.8 encourages that libraries exist outside of the base Haskell build. For example, the parsec parser library requires that you download parsec from haskell.org or other location or extract the source from darcs. Basically, development will continue on haskell libraries outside of the typical GHC development. With that being said, the same holds true for the HTTP library. You can pull the source from darcs or at the time of this blog entry, the latest HTTP library is HTTP-3001.0.2. I downloaded and did a Setup.hs configure/build/install against GHC version 6.8.
If you attempted to compile haskell source with out installing this library, you will get a package not found error.
ghc --make -package HTTP ManClient.hs
What does and do and how
The goal of this simple application is to post data or actually could be used to post to any website. Also, if you simply replace the POST string type in the code to GET, you can use this code to read content from a website and print the web page to the console.
Get Function
get :: URI -> IO String
get uri =
do
eresp <- simpleHTTPProxy (manRequest uri)
resp <- handleErr (err . show) eresp
case rspCode resp of
(2,0,0) -> return (rspBody resp)
_ -> err (httpError resp)
where
showRspCode (a,b,c) = map intToDigit [a,b,c]
httpError resp =
showRspCode (rspCode resp) ++ " " ++ rspReason resp
Build the Request Type
manRequest :: URI -> Request
manRequest uri = Request { rqURI = uri,
rqMethod = POST,
rqHeaders = [
Header HdrContentLength
(show (length forumRequestBody)),
Header HdrUserAgent userAgentMimicIE
],
rqBody = forumRequestBody }
Download Source
http://haskellnotebook.googlecode.com/svn/trunk/haskell/laughingman/haskell/ManClient.hs
Sunday, November 25, 2007
Blog Spam: Cat programming language
"Cat is a functional stack-based programming language inspired by the Joy programming language. The primary differences is that Cat provides a static type system with type inferencing (like ML or Haskell), and a term rewriting macro language extension language called MetaCat."
http://www.cat-language.com/
What I also thought was interesting was that Cat is embeddable.
http://code.google.com/p/scheme-cat
I hope to make OctaneLang embeddable as well.
Wednesday, November 21, 2007
Science behind botlist
First I need to develop the push-pull system a little bit further. This allows for botlist to be updated remotely. Right now, it is working fine but I want to ensure data integrity for when the client is communicating with the server. Basically, when the client sends data uploads to the server, I want to ensure that the server has all the right data. It will probably be a simple MD5 scheme to validate a binary upload or something similar. As of right now, the push pull system just ignores invalid records when they are encountered.
Recommendation System
Botlist is a really simple system, right now. New links are submmitted by users or by the remote bots and added to the table. I am currently working on a system for the main page to be filled with popular links and actual content. Recently I picked up a USA today newspaper and amazed at the layout. Who decides and under what conditions articles should be placed at the front. How much text is too much, too little, what is captivating to the reader. It would be nice mimic such functionality. If you have visited the Drudge Report, it would be similar to how that works (minus Drudge manually updating his popular links).
Sunday, November 18, 2007
Additional Resources (link blog entry: haskell and parsing links)
Resources
http://legacy.cs.uu.nl/daan/download/parsec/parsec.html
http://planet.factorcode.org/
http://halogen.note.amherst.edu/~jdtang/scheme_in_48/tutorial/overview.html
Wednesday, November 14, 2007
More practical Scala, searchable help document system
I go into more detail on the google code site, but here is a tool for creating searchable help documents:
"This is a small utility for indexing developer help documents with Lucene. And because some botlist documents have already been indexed, you can use it to search some of those example docs."
http://code.google.com/p/openbotlist/wiki/BotlistHelpDocumentSystem
Tuesday, November 13, 2007
Practical Scala; Walking a tree directory
First Version, use of File Class:
class DocWalkFile(file: File) {
def children = new Iterable[File] {
def elements =
if (file.isDirectory) file.listFiles.elements else Iterator.empty;
}
def andTree : Iterable[File] = (
Seq.single(file) ++ children.flatMap(child => new DocWalkFile(child).andTree))
}
def listDocuments(dir: File): List[File] =
(new DocWalkFile(dir)).andTree.toList filter (f => (f.getName.endsWith(".java") || f.getName.endsWith(".txt")))
Second Version:
Resources:
import java.io.File
object DocWalkFile {
def andTree(dir: File): List[File] = {
val fileList = dir.listFiles.toList
(fileList filter(f => f.isFile && f.getName.endsWith(".txt"))) :::
(fileList filter(f => f.isDirectory) flatMap (f => andTree(f) ))
}
def main(args: Array[String]): Unit = {
if (args length == 0)
println("usage: DocWalkFile [dir]")
else {
println("using dir " + args.apply(0));
andTree(new
File(args.apply(0))).foreach(f => println(">> " + f))
}
}
}
Sunday, November 11, 2007
Short primer, importing a SVN repository into a GIT one
Get GIT and install
I am working with an Ubuntu Dapper machine (yes, it is an older distro) and I didn't want to go through the hassle of using a very out of date version of git, so we are going to download the most recent git from kernel.org.
wget http://kernel.org/pub/software/scm/git/git-1.5.3.5.tar.gz
tar -xvf git-1.5.3.5.tar.gz
Pre configure and Installation
Actually, before running configure on the git source; you may need to get two
libraries.
On Ubuntu, I did the following:
- sudo apt-cache search libsvn-core-perl
- sudo apt-get install libsvn-core-perl
- sudo apt-get install libcurl3-dev
Run ./configure
At this point, you can start to build the git source; type ./configure at the command prompt and the subsequent make/install commands. Basically, standard steps for compiling and installing a typical linux source package.
- ./configure
- make
- sudo make install
Assuming git was built properly, you should be able to import a subversion
project. I suggest creating a directory and then have git create the .git repository information in that particular folder.
- sudo mkdir -p /usr/local/var/gitscm/botlist.git
- cd /usr/local/var/gitscm/botlist.git
- sudo git-svn clone http://openbotlist.googlecode.com/svn/trunk/openbotlist/
That is all that is needed to create a repository from subversion, notice that the svn (.svn) working directory folder is not included in your git project.
Running the git-daemon at machine startup
Unlike other linux daemons, setting up git-daemon is pretty simple. At least for running the git daemon server under the git protocol. Basically, git-daemon is a server for hosting git repositories and this particular server defaults to running on port 9418. GIT also supports hosting repositories through HTTP.
Run whereis git-daemon to find out where the executable is located. It is up to you how to pass the git-daemon arguments, I used a simple wrapper bash script and launched git from there.
BASE_PATH=/usr/local/var/gitscm
/usr/local/bin/git-daemon --reuseaddr --verbose --base-path=${BASE_PATH} --export-all -- ${BASE_PATH}
[End of Script]
Change the base-path path according to where you want to store your git repositories. In the script above, gitscm is just a regular directory. The subdirectories (for example, botlist) are actual git repositories (that contain the .git directory). Create a symbolic link in your init.d directory, something along the lines of this:
ln -s /usr/local/bin/git-daemon2 git-daemon2
With ubuntu, you can run update-rc.d to ensure that the git-daemon2 script gets launched at startup:
- sudo update-rc.d git-daemon2 defaults
Run and Test
Now, you can start the git-daemon2 script
- git-daemon2 &
- git ls-remote git://127.0.0.1/botlist.git
- To get the project, cd to some directory
- git clone git://127.0.0.1/botlist.git
Tuesday, November 6, 2007
Now Playing: Brandenburg Concerto
http://en.wikipedia.org/wiki/Brandenburg_concertos
They are widely regarded as among the finest musical compositions of the Baroque era.
Friday, November 2, 2007
13949712720901ForOSX Vote! I am actually helping Java
Personally, I feel that Apple has a right to leave out whatever software they choose. Plus, they already have Java5 working with their operating system so it is not like they are totally ignoring the Java community. But, if enough momentum is created for adding the new Java; would it hurt for them to listen to some of their users.
So, I am doing as the blog instructed and here is my vote:
13949712720901ForOSX
http://blogs.sun.com/bblfish/entry/vote_for_java6_on_leopard
Thursday, November 1, 2007
Google, we are watiing?? on opensocial
Google, what is the deal? Where is opensocial. I am actually kind of excited about this technology. I heard reports that library was supposed to be released on Thurs. It is 6:42PM (PST) , you have a couple more hours left. Don't be evil by lying to us.
I have a new perspective, Firefox and Flash bugs
https://bugzilla.mozilla.org/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&content=flash
Wednesday, October 31, 2007
Factor screencast, take 2, basic Factor usage with the tty listener
The following screen cast was developed to show basic factor usage including analysis of the data stack, how one would go about looking up help on words, etc.
Also, working with the stack takes a little getting used to, that is why I went it over in the screencast. Elie has some great images that I want to show here of some basic operations. I go over a couple of them in the screencast.
"Let's take our rot example from above and practice it with the help of the illustration. Write 1 2 3 4 in your input area and hit Enter (the Return key) on your keyboard. You should see the start stack displayed in your stack area. Notice the position of the top and bottom of the stack in your stack display area. Now write "rot" (without the quotation marks) in your input area and hit Enter. You should see the rot stack displayed as above because the "rot" word caused the 3rd stack item to be moved to the top while the 1st and 2nd stack item were pushed down." -- quote from Elie's blog on stack manipulation
In the second video (part two), I demonstrate the new vocabulary modules for structuring your factor application and a short demo on what your code would look like in emacs.
Screencast (1)
Resources
- http://factorcode.org/
- http://www.bluishcoder.co.nz/
- http://fun-factor.blogspot.com/
- http://useless-factor.blogspot.com/
This screen cast was created gtk-recordMyDesktop. And then encoded with mencoder (ffmpeg could also be used).
- bbrown@houston:~/tmp/capture$ mencoder factorcaptureA.ogg.3 -o f4_part2.avi -ovc lavc -ss 09:58
- bbrown@houston:~/tmp/capture$ ffmpeg -i factorcaptureA.ogg.3 -t 00:09:58 factorscreenlin1.avi
Monday, October 29, 2007
How to post to blogger through gdata API (example in Scala Language)
Actually, I have ranted a lot about this system in the last couple of days.
So, the next logical step was to create a simple blog client that could connect with the blogger/gdata API.
It actually wasn't that complex. Envision an API for posting a blog entry to blogger, and
the operations shall include: Authenticating to the service, provide a post URL to connect to,
provide the actual content and title to post. That is basically all that is required to use
the API. The documentation does a much better job of explaining the overall functionality
available through the service. And it is freely available and fairly easy to use. I created
the source below in a couple of hours. When using the API, just make sure to secure
your google username and password as it is probably use to access all of the google services.
Most of the scala source can be found below.
class ContentReader(filename: String) {
import java.io._
def readFile(): (String, String) = {
val file = Source.fromFile(filename)
var counted = file.getLines.counted
val fileData = new StringBuilder()
var title = ""
counted.foreach { (line: String) =>
if (counted.count == 0) {
title = line.substring(6).trim()
} else {
fileData.append(line)
}
}
(title, fileData.toString())
}
} // End of Class //
def createPost(service: GoogleService, blogid: String, title: String, content: String,
authorName: String, userName: String): Unit = {
// Create the entry to insert
val myEntry = new Entry()
myEntry.setTitle(new PlainTextConstruct(title))
myEntry.setContent(new PlainTextConstruct(content))
val author = new Person(authorName, null, userName)
myEntry.getAuthors().add(author);
// Ask the service to insert the new entry
val postUrl = new URL("http://www.blogger.com/feeds/" + blogid + "/posts/default")
val res = service.insert(postUrl, myEntry)
Console.println("INFO: create post");
}
def publishEntry(googleUsername: String, googlePwd: String): GoogleService = {
val myService = new GoogleService("blogger", applicationClientId)
myService.setUserCredentials(googleUsername, googlePwd)
return myService
}
Sunday, October 28, 2007
Firefox (2 and possibly 3) are unusable on Linux
There are a couple of problems that plaque my internet use. Slow startup (at least with FF2). Heavy javascript oriented pages wreak havoc on FF and the operating system.
Don't you find it a little odd that Ubuntu just recently upgraded to Firefox 2.0.0.8 only 2 weeks (or so) after the Gutsy (Ubuntu 7.10) release. I bet it was yet another Firefox memory fix or something along those lines. The worst part, as far as I can tell it works fine on the win32 platforms. Never have a problem with it. But once I start using FF on a Linux platform, I start praying to the gods I can do basic tasks like check my email or visit one of the three sites I frequently visit. It is really tragic.
My Solutions
I am trying my best to move away from FF, at least FF2. I am currently writing this blog entry under Firefox Granparadiso (FF3). But it is kind of difficult when you have been using some variation of Firefox for so long. Firefox on windows. Firefox on Redhat. Also, FF shares so many properties with Internet Explorer. I use the latest Opera on occassion and so far it seems to be very stable.
Plugins: Some articles on the web mention that Firefox doesn't work well with various plugins. I only really use Firebug and the non-commercial Flash plugin.
Tuesday, October 23, 2007
Project Diary Update: JVM Notebook
I have made the initial import of jvm language notebook source. Basically just a collection of source related to programming languages that run on the jvm. People are always curious about how one should get started working with for example Jython. Hopefully these notebook projects will show one how to do so. Here is a blurb from the project:
"The Java Virtual Machine ( Sun's JVM is called HotSpot? ) is a java bytecode intepreter which is fast, portable and secure. Jython, JRuby, Scala, ABCL (Common Lisp) are popular language implementations that run on the JVM that allow for the syntatic sugar of their particular languages. This project contains multiple subprojects and code demos related to those jvm language implementations. "
Monday, October 22, 2007
Random Ramblings: Haskell OpenGL on Win32 doesn't work at all?
I can't tell if it is a failure on the part of the Haskell OpenGL testing team (open source developer volunteers) or on my part for not doing enough research? Whatever the case may be, there seem to be a lot of issues with writing Haskell OpenGL code on the Win32 platform. If you read the mailing list, you will get 100 steps on how to either compile with FreeGLUT or get the opengl haskell source from darcs or both. With that being said, my issue is that I will compile some code and then attempt to launch the application and you can tell that the window launches but no 3D graphics and the window does not stay open.
Typically in a win32 environment. The runtime OpenGL DLL is resident on the system and the developer will only have to compile against a particular set of libraries. The Glut DLL is normally not installed but hardware vendors typically are supporting it now. I don't know if Haskell uses a FFI interface to connect to those DLLs or is it compiled against FreeGLUT. If your code is compiled against FreeGLUT that is normally more difficult to address because those libraries are needed at compile time.
Hopefully, in the near future I will write a wiki entry on how to really get OpenGL working on the win32 platform.
Sunday, October 21, 2007
Friday, October 19, 2007
Why contractual oriented programming is the only way to program in java
Tony Morris, a former(?) Java developer is very fluent in the ways of Design by Contract; he created the ContractualJ framework and had this to say:
"ContractualJ is an open source project that is aimed at providing a robust API specification for the Java programming language. The ContractualJ API Specification is independent of any given context, except that it either replaces an existing core J2SE API Specification that is poorly designed, or adds a feature that does not exist in the core API. ContractualJ serves as an example of writing software using Contractual Oriented Programming, while also highlighting the flaws of the dependent tools (e.g. Java) and exemplifying the optimal workaround to the existence of these flaws. "
Here are some more quotes from Tony and as of now I don't have much to say on the subject.
"1) Interfaces define a contract for *how a class may be accessed*, but don't provide ANY information about what the class does, or how it does it.
2) Abstract classes allow (among other things) *commonly implemented processes to be encapsulated"
* All classes are declared final. Concrete behaviour inheritance is not permitted.
* All local variables and fields are declared final, unless otherwise required not to be by the context. A local variable or field that is assigned once must be declared final.
Resources
http://archive.eiffel.com/doc/manuals/technology/contract/
http://www.freepatentsonline.com/6442750.html
Tuesday, October 16, 2007
Happiest day of my life, playing FFT on Linux
When several magazines call it the best game ever, there must be something to that. I knew it was the best game 10 minutes after playing it. Also, people always ask me why my screen name on freenode is ramza; where there you go. Ramza is the main character in FFT.
http://en.wikipedia.org/wiki/Final_Fantasy_Tactics
Anyway, I am playing through the psx emulator. Awesome. Thanks linux.
Tuesday, October 9, 2007
Last Java Reader Writer Utility you will need (especially for Log Analysis)
The goal is simple; given a input file, read the file and then rewrite the output based on that file. I am using this particular code for log file analysis.
Python pseudo code:
f = open(filename)
fw = open(filename, 'w')
data = f.read()
for line in data:
fw.write(line)
The java version is just that, but I wanted to do the iteration around reading a line through callbacks (anonymous inner subclasses). I designed the following loadFile routine to use an implementation of some ReaderWriter class because you certainly want to control how you iterate through each line of the document and only to focus on that particular task as opposed to the inner details of how the file gets opened or closed. For example:
FileUtil.loadFile(filename, (new HtmlFileUtilReaderWriter()
public void read(BufferedReader bufInput, List resultList) :while ((feed = bufInput.readLine()) != null
this.write(processLineSystemOut(feed))That is basically it, I know it is simple but it is pretty useful idiom. You can download the full source from my googlecode repository. In the future, I hope to create a similar set of libraries in Haskell and compare and contrast between the two languages.
Download
http://haskellnotebook.googlecode.com/files/javautil_filereaderutil.zip
Sunday, October 7, 2007
Imperative Haskell OpenGL development and demo
I have finally created the camera component for the Octane Mech game. It is pretty basic, but is a basis for the camera movement. The camera, as you would expect, is a n important aspect of a 3D game.
You can read more about the source and download the demo by going to the project wiki. I would have posted it on blogger.com but the code formatting here is terrible so I will only post to the wiki now and in the future.
http://code.google.com/p/octanemech/wiki/MechProjectDiary
Monday, October 1, 2007
Haskell Cookbook(Notebook) Released on Google Code
http://code.google.com/p/haskellnotebook/
Monday, September 24, 2007
Octane Mech, OpenGL Haskell based mech game; early code and some haskell notes
I am in the initial design and some development of OctaneMech; as the title implies is a OpenGL Haskell based Mech (bot, tank mobile) game.
An early goal is to recreate/port glAnts (mech game) to haskell
http://glants.sourceforge.net/
On Haskell
Haskell is a pure functional programming language where your primary view of your software is through the use of functions. In java or other objected oriented/imperative languages, you are looking at the lowest level components; in Haskell, you are able to concentrate on the operation a particular function is used for without focusing on the low-level details (step-by-step sequences) of the function.
I won't now or probably in the future detail the power you are given with Haskell and I leave that up to you the reader. I will focus on how I am using Haskell to build my project. And this first entry will contain some simple Haskell snippets.
Main
Like other applications, a Haskell application begins with entry point definition main function. For example, the following snippet below is all that is included in my Main module (included in a text file called OctaneMech.hs)
module Main where
import MechGLScreen
main = do
putStrLn "running OctaneMech"
mechLaunchGLWindow
It almost resembles a Hello World application. We import the needed library "MechGLScreen" and then write our main definition. putStrLn was used to print the startup message. mechLaunchGLWindow, is going to get a little bit more complicated. It includes the OpenGL initializations and sets the display callback.
Launch OpenGL
This function also may resemble more the sequential, call by call nature of an imperative program. If you are used to OpenGL development, most of the calls are window and GL initialization. It may get a little bit more interesting with the "SimplePlayer" data type which is composed of a x and y position.
mechLaunchGLWindow = do
getArgsAndInitialize
initialDisplayMode $= [DoubleBuffered]
initialWindowSize $= Size mechScreenWidth mechScreenHeight
createWindow mechWindowTitle
curMech <- newIORef (SimplePlayer {
shape = MechBoxShape,
posX = 0,
posY = terrainYSize-ssize,
angle = 0})
-- Get the current and rotation matrices
curMatrix <- get ((matrix $ Just $ Modelview 0)::StateVar(GLmatrix GLdouble))
rotationMatrix <- newIORef curMatrix
-- Keep track of camera movement
cameraRotPosition <- newIORef (0::GLint, 0)
-- Set the OpenGL callbacks
displayCallback $= displayGameLoop curMech rotationMatrix
-- Set the keyboard callback for handling actions
keyboardMouseCallback $= Just (mechKeyboardHandler curMech)
idleCallback $= Just idle
mainLoop
This particular function initializes the GL window and other game initializations. Now, open the MechDisplay.hs source. This function contains operations for swapping the GL double buffer and rendering the plain (Quad) object and player character (a simple cube).
displayGameLoop mechObjRef rotationMatrix = do
clear [ColorBuffer]
curMech <- get mechObjRef
prevMatrix <- get rotationMatrix
loadIdentity
multMatrix prevMatrix
curMatrix <- get ((matrix $ Just $ Modelview 0)::StateVar(GLmatrix GLdouble))
loadIdentity
scale 0.06 0.06 (0.06::GLfloat)
multMatrix curMatrix
-- Render the terrain, including the flat plain
renderTerrain
-- Render the Mechs
renderBasicMech curMech
-- OpenGL, swap buffers
swapBuffers
And I know it is short entry but I will actually continue in my next couple of posts on this topic. See all of the source code for this simple example below. Once you have it compiled, you should only see a 640 by 480 window open up and then you are able to use the keyboard (arrow keys) to move the "box" character around.
Source for Example
Download Haskell Example
Follow the Project at Googlecode:
http://code.google.com/p/octanemech/
Note: google code is horrible about the code formatting, so you will have to browse the included source to view the correct indentation
Tuesday, September 18, 2007
Botlist released on code.google.com
Here is the blurb from the googlecode page.
Botlist is a social bookmarking web application that contains a news aggregating/news/article submission site. There is also an ads listing section so that users can post personal/ad profiles. The application itself is created with the following libraries; JRuby and J2EE's Spring framework as a middleware piece, Hibernate for object relational mapping (ORM). It is designed to run with Tomcat but should work with other J2EE servers. Search functionality uses the Lucene API.
Other Features
News aggregation (some links will be included); over hundred and fifty thousands links thus far.
You can reply to comments, up or down vote the news articles, post new article links similar to other social bookmarking sites.
- Comma delimited output for easy, text based access (for developers)
- Numerous documentation on architecture
- Discussion Forums section
- User profiles
- Ad/Profile listing section, listed by city
- Sort search by relevancy, submit date
- Can also operate as a simple bug tracking system
Visit Botlist Home
http://botspiritcompany.com/botlist/
View the Source
Thursday, September 13, 2007
Why Java still sucks but there are some things done right for web development (to me anyway), in 10 minutes
Writing this will get me banned from the development community for life. Actually, I don't know if I really belong to any development community so I guess I can sleep soundly at night. Basically, unless you are living under a rock, the development world has made great strides in terms of language development. There are at least a dozen popular/mainstream programming languages that are used to perform various computing tasks. Some are open sourced, some are closed. Some are geared towards a specific niche in computing. Some are more general purpose languages. Java, C, C++, C#, Haskell, Common Lisp, Python, Ruby, Erlang Assembly/Machine Language (x86 for example) are probably some you have heard of.
Lets get to the point (this is really about Java); Java and some other imperative languages that are defined by a sequence of steps to define a particular task (which can be cumbersome) are not as productive as declarative programming styles where the step-by-step inner workings are hidden and you only are to focus on the particular goal of the operation based on the given inputs. For example, Haskell is a purely functional programming language that adheres to the declarative programming paradigm. There are probably various studies and analysis comparing lines of code, number of bugs, productivity and other metrics comparing different programming paradigms; the java/imperative/object-oriented, procedual approach seems to lose out. With that being said, Sun (creators of java) have created a complete system that may not include the best language but does include a set of libraries and components that can aid in a variety of different computing tasks. And this may not be the most important statistic, but millions of developers and thousands of companies probably rely on the java platform and it is too costly to which to something else. Me, I work with and write web software for a Financial Services company (sort of online banking); security is important, completing a task on time is important, accuracy, stability, reliability are important. Does a Java/J2EE based system gurantee that? Not 100% of the time? But, it does provide for those things a majority of the time. Would a system based on Rails, Django, Haskell Server Pages, ErlyWeb work? Maybe. My purpose in writing this is to say that there are some things that Sun and Java, J2EE have done right. In the future, there are some things that an emerging language may hijack from the Java platform to sway those developers. From the language developers I have read about and great hackers out there, they don't really care about how many users are using their particular tool. It is really more for the other developers (eg, java developers) who are fed up with things like NullPointerExceptions, Out of Memory Errors, 40 lines to open/read/write a file; these developers are dying to move away from the java platform, but a lack of a SSL library or lack of a database connectivity api held them back from switching to something else.
So, what has Java/J2EE done right?
There are a couple of things surrounding Java that I just find "productive", I have certainly missed a few and you certainly may disagree but by and large I find these things useful. And I know that some of these libraries don't begin and end with Java and are common in other development environments.
Jar files, War files
This is really a small thing. But I guess because of the nature of loading byte code compiled java classes, Sun wanted to create something similar to an executable. They came up with the jar (java archive) file which is basically just an zipped archive of java classes. If you want to get more creative, you can "Secure" your jar files and/or provide meta information like the target jvm and what-not. Personally, I think this is useful just like an binary executable is useful. All of the libraries are typically in one place and normally "read-only". Applications based on interpreted languages like Ruby, which are script driven run of a library of separate scripts as opposed to one archived file. This may or may not be a good thing. Sure, python has "egg", but I think the python developers chose the expanded directories. It is great to be able to edit a script or patch an application just by updating one single file but it has been my experience that "users" tinker with their applications (edit the script files) too often for my comfort, jeopardizing the integrity of the application. Having one file, plug and play library or set of libraries like the jar and war file limits what the developer has to worry about. In the case of the war file, you also can update your entire application remotely by uploading it through an application server web interfaces.
The servlet api
The core servlet api, especially the HttpServlet class is pretty simple and does what you would expect. Given a GET/POST/HEAD request, process the incoming request parameters and then modify the response. Pretty basic.
For example, a doGet handler might look like the following (python pseudo code)
doGet(request, response):
session = request.getSession();
parm = request.getParameter("action");
session.setAttribute("prev.action", parm);
out = response.getWriter();
cookie = new Cookie();
cookie.setAttribute("remember.me", "true");
out.println("");
response.redirect();
JSPs/Taglibs
A corrollary, along the lines of the Servlet class is the Java Server Page (JSP), the J2EE HTML/XML view technology. Think of JSPs as a HTML templating system that parses your java model classes and displays the values to the user surrounded by the rendered HTML or XML. JSP idioms can get ugly, especially when you want to iterate over a collection of beans in a List and then print the values out or perform other "if/choose" operations.
[c:forEach items="${command.mediaList}" var="curmedia" varStatus="status"]
[c:cout value="${curmedia}"]
[/c:forEach]
The default JSP (eg JSP 2.0) system has all but been replaced by taglib driven MVC frameworks like JSF and Struts. The advantage of these newer technologies is that the difficult web tasks like form validation, model driven development, error message handling are handled by the framework.
Filters
Filters are pretty useful especially in a high security application. Basically, you can apply a filter in front of a Servlet request and do post processing before the response goes out to the user. For example, you may want to filter all newline characters (protects against HTTP poisoning attacks) from a request.
doFilter(request, response, chain):
// process incoming input from request and modify output.
Web Archive Layout
The web layout for a Java web application is not entirely intuitive or behaviour driven like the MVC framework Rails, but it is consistent and it does make some sense in a java context.
MY_WEB_APP:
[includes view oriented files, jsps, html, etc]
WEB-INF:
[web configurations, like web.xml]
classes:
lib:
META-INF:
Consistent Database Connectivity API.
Java does have a general purpose connectivity library that provides an interface to database specific drivers. Some features go unused and some have security holes, but it is easy to connect to your database with a couple of calls. On the other side, some language implementations provide driver specific libraries, ODBC oriented libraries. These are ok and they normally provide interfaces for returning rows, meta information, but with JDBC, it is nice to be able to connect an Oracle or MySQL with the same code and only changing the url connect strings. I am kind of oversimplifying what is involved in database development in java; ignoring object relation mapping, connection pooling but you do have jdbc as a base to start with.
XML Libraries
Security
My knowledge of the java security framework is limited, but I know it is there and it works. I do know that other languages don't have or their security intefaces aren't reliable. What do I want from a security library? Well, the ability to do ssl/https socket connectivity is a start. APIs for the popular encryption algorithms are another plus.
Ant's Build.xml (and maybe Maven)
Ant and their build.xml in the java world is akin to the gnu make utility. It is XML based and may not be the best descriptive language for builds but it does the job of compiling java classes. It does allow for full builds of your application in one call at the command-line. Also can be used for daily builds (see cruise-control) without an over-complicated make/bash script. Outside of java build it provides an inteface for pretty much anything you could think of. FTP, SFTP, JUNIT calls, Copy, Mkdir (Maven, the other java build tool is supposed to be a better "ant", that is what I heard anyway)
Tomcat
Tomcat is a third party web servlet container developed by the Apache software group. It is simple, reliable and does its job; serving up jsp/servlet based applications. It may or may not be what you want in a production environment and will probably require some performance tuning outside of the default configuration.
The others, the other libraries and Applications
Java has certainly matured over the last 10-12 years. With that maturity comes a proliferation of a numebr of libraries for common tasks. Popular librares include:
SpringMVC/Struts (Middleware and MVC framework), Hibernate/iBatis (Object Relational Mapping), Lucene (Full Text Search), Log4j (logging framework), GWT (Google Webtoolkit for Ajax Development), Ant (build tool) JUnit (unit testing), iText (PDFs), dom4j/jdom (XML Processing) Jboss, WebLogic, etc, etc.
JVM Languages
Earlier, I didn't mention an overwhelming fondness for the Java language. Jython, JRuby, Scala, ABCL (Common Lisp) implementations allow the syntatic sugar of their according languages on top of the Java virtual machine. In most cases, you have access to any of the Java API's that are available.
Eclipse IDE (with WTP)
this resource hog wild java/web development environment has a little bit of everything; project management, java/package explorers, profiling tools, java debugging tools, ant tools, junit unit testing interface, custom views/perspectives, plugin support (for example interfaces to SVN, GIT, etc). Some developers despise it and chose something lighter like JEdit, Vim, or even IntelliJ. It does take some getting used to.
References
1. http://en.wikipedia.org/wiki/Category:Declarative_programming_languages
2. http://en.wikipedia.org/wiki/Haskell_%28programming_language%29
3. http://en.wikipedia.org/wiki/Common_Lisp
4. http://java.sun.com/
5. http://en.wikipedia.org/wiki/Java_(programming_language)
6. http://www.paulgraham.com/gh.html Paul Graham on Great Hackers.
7. http://lambda-the-ultimate.org/
8. http://en.wikipedia.org/wiki/Apache_Struts
9. http://en.wikipedia.org/wiki/Apache_Tomcat
10. http://en.wikipedia.org/wiki/Eclipse_(software)
11. http://ant.apache.org/
12. http://java.sun.com/javaee/
13. http://java.sun.com/j2se/1.5.0/docs/guide/concurrency/index.html
Wednesday, September 12, 2007
Hello Welcome
I love:
http://programming.reddit.com/
But, you may also see me on:
http://www.joelonsoftware.com/
I like creating various projects that frankly, users may not like. But, I love creating them anyway. My most recent project is (botlist, social bookmarking site):
http://www.botspiritcompany.com/botlist/
My next project is a web server/application server/database server in haskell. And with that, various snippets of haskell development.