The hidden overhead when creating thousands of empty folders

Over the past weeks I've been looking for a way to store some hundred million files inside a desktop file system such as Ext3 or NTFS.

On previous experiments, I've noted that after >30 000 files on a single folder it would not be possible to use a GUI file browser and even the listing of these files using the command line becomes sluggish.

The next hypothesis was to avoid a huge number of files/folders on the same root. For example, for a file I'd remove the name portion and compute a SHA1 checksum signature of 40 bytes. With this signature I'd use the first 4 bytes to create a folder, then I'd use the next 4 bytes to create a sub-folder inside the first one and so forth until I have 10 folders that represent the unique signature of the file.

On the last folder I would add a text file containing the path and name information. If more files would be found in the future, the respective path information would be added on this text file. I thought that using the 4 bytes would reduce the number of possible combinations and permit re-use of the folders that would scale to millions.

In theory it worked OK. On my first tests it worked OK with the first thousand files. The problem was a bit more unexpected. Folders, despite containing nothing other than other folders will also require disk space to exist. While the initial project was a success, we could store/access thousands of files without noticeable latency, we brought aboard a problem of disk storage.

To index something like 40 000 files with this SHA1/folder combination was using 2.2Gb of disk space. This was a hidden overhead, very underestimated on my early estimation.

I didn't tested under the Windows NTFS, having this problem under Linux was already a no-go for this option. Fortunately, on the bench was already being planned an alternative.

Our file-system (at minimum) requires only to write files once and then read them when needed. So, a very simple solution would be writing all files together to create a very large file. And then have a second file indicating the position of each file within this large binary block.

There are some problems with this approach:
  • Easy to corrupt. If one byte within the large block is removed/added then it invalidates the index structure completely
  • Error checking overhead. Right now it copies files directly onto the big binary block (BBB). If an exception occurs while copying a file, this leads to corruption of the whole big file.
  • Limited to operating systems capable of handling files bigger than 4Gb
  • (..more exist, just pointing the ones most troublesome at the moment) 
Still, as a storing solution this is so far working as desired. Helped to remove the folder overhead and is extremely fast. I'm writing the index file as the coordinates of the file within the big file along with its original path/name combination. An example can be found at https://raw.githubusercontent.com/triplecheck/tdf/57a776d7ea065b686cb024f1dc924b5b06f8752d/run/test.tdf-index

As far as I'm concerned, creating millions of files on a desktop-grade file system is something I won't be pursuing further. It is tempting to have all the files ready for processing in their original format but I'm simply not finding a feasible manner of accessing millions of files in their original form without resorting to file systems such as XFS and HDFS, or resorting to some kind of data base.

So, opting with a big-binary file as simple storage for now.  






GitHub: Indexing all users non-stop

Last week was dedicated to index the users registered on GitHub.

Getting the users was a needed step in order to test how difficult it would be extracting information from the self-appointed largest (public) open source repository on earth.

To my surprise, it was relatively straight-forward and quick. Over the past months I've understood why GitHub is becoming the place of election for hosting. It was a neat user interface, provides incentives for developers to commit code and simply goes straight to what really matters.

In regards to acessing the information, GitHub provides a pretty amazing and reachable API access. When looking at sourceforge or googlecode, I don't fell minimally invited to work with them in regards to analyse the open source data. I'm sure they have their valid reasons, on my side I'm just looking for a straightforward (and legal) way to access this kind of information.

To access the API was available a set of Java libraries (or you can just use the raw JSON format). There is JCapi (freeware) which is the one that I found more suited. The reason is because every now and then we'd expire the API rate limit (5000 requests/hour) and these libraries permitted to keep the connection in pause until the limit was lifted. There were some defects noted while using the library, however, the developers behind the library were pretty amazing. They solved most of the reported issues in light-speed.


With the library in place, I've wrote a java project to iterate through all the users registered on GitHub using the authorized API calls. At first was noted that the Internet connection broke very often, usually around 200k indexed users. I was doing these tests from the office network and was not stable enough. Then moved the software to a dedicated server that is continuously online at a datacenter. From there the connection lasted longer but still failed at 800k indexed users.

Being a stubborn person by nature, got myself thinking on how to resume the operation from the point where it had stopped. The API did provided a resume option from a given user name but the libraries didn't yet covered this point, to my luck the jcabi team was very prompt in explaining how the API call could be used. With the support for resuming available, was then a simple matter to read back the text file with each user per line and get the last one.

Didn't said it before but the storage media that I'm using are plain text files (a.k.a flat files). I'm not using a relational database, nor have I looked much into "NoSQL" databases. From all the options that I've tested over the years, nothings beats the processing simplicity of a plain text file to store large arrays of data. Please note that I emphasize simplicity. If performance had been affected significantly, I'd use a more suited method. However, turns out that normal desktop computers in 2014 can handle text files with millions of lines under a second.

With the resume feature implemented was then possible to launch a single machine for indexing the user names non-stop. After two days of processing, the indexing was complete and showed a total of 7.709.288 registered users.

At the time of this writing (July 2014), GitHub mentions in their press page a total of 6 million users. The text file containing these user names is sized in 81Mb. It contains one user name per line.

Perhaps in the future would be interesting to see a study noting the demographics, gender variation and other details from these user accounts. On my context, this is part of a triplecheck goal. Open source is open, but is not transparent enough. And that is what we are working to improve.

Following the spirit of open source and free software, the software used for generating this index of users is too available on github. It is released as freeware under the modified EUPL (European Public Licence) terms. You find the code and compilation instructions at https://github.com/triplecheck/gitfinder


This code does more than just indexing users, I'll be writing more about what is being done in future posts. In the meanwhile you might be asking yourself: where can I get this text file?

For the moment I didn't made the text file available on a definitive location. Will likely talk with the good people at FLOSSmole to see if they would be interested in hosting and keeping it easily reachable to other folks.

Forward we move.
:-)


 




Java: Parsing text files with minimum delay

In this blog post I'm gathering some of the things that I've learned from practice while making my own code process faster a significant amount of lines inside a text file.

In the most recent work I'm parsing 440 000 lines inside a text file under a second. My hardware is nothing special for today's standards, it is a Toshiba R630, a x64 CPU with 4Gb of RAM running Windows 7.

The result can currently be seen on https://github.com/triplecheck/reporter/blob/b5ca1781dc511b3a823724606a07d7fc61e1d9e3/src/spdxlib/SPDXfile2.java#L197 on the method processFileLine. The link might change in the future, so please do write back a message in case I don't update the above link.

During this parsing, quite a number of time consuming tasks take place:
- Discovering the type of file extension (is it a source code file? an image? an archive? ...)
- What kind of line are we reading (a checksum line? the file size? the license details? the next file? ...)
- Creating a node to place the current file on a treeview under a specific folder

All in all, the first edition worked fairly for smaller text files but failed at reports that contained thousands of lines. Either the memory wouldn't be enough (not enough heap size) or it would just be too slow (for example, generating the treeview was real slow). There was a serious effort to merge the number of loops onto a single loop and to drastically reduce the calculation and filtering time. I've started with first testing different ways of reading all files one by one and BufferedReader came as the fastest option.

Then, step by step I'd introduce a new value being parsed and test the performance to see how it would be degraded and try to optimize. The end result was satisfactory and below are some of my field notes that I kept around for future memory. It is not an exhaustive nor correct list of things you should/can do. It worked for my own goals and it is my hope it can somehow be useful for you too.

If you know any further optimizations that can take place, I'd be happy to include them here and assign proper credits.

Compiler not compiling

The Java compiler is not perfect. Just because it seems to always do a good work, there are some (rare) cases where you will need ask for a general re-compiling of all the classes. This has sometimes worked to address strange behaviors on the code that I was having trouble to figure until a full compilation was asked.

ASCII: party like it's 1998

One significant code speed-up happened after going back to compare characters instead of strings. There is a heavy performance cost when comparing strings but I guess nowadays machines have grown so fast that it gets easy not caring and just compare strings. When looking for performance, it is needed to go back into the days where an ASCII table was always present (if you didn't knew the ASCII codes by memory like Mr. Bill Gates once said he did). So, back to the 90's and looking online at places like http://www.asciitable.com/ to get refreshed with the chars codes.

There is a dramatic speed-up boost when looking for a char inside a string. Here is a working example:

        // find the "(" char which is represented by "40" in ASCII
        final int index = value.indexOf(40);
        if(index==-1){
        // do your code here
        }

Nested IF's

I'm not a friend of spaghetti code. However, from my experiments was possible to note that nested IF's can help to improve performance too. On my context, I was reading a large text file line by line and trying to recognize tags. This required quite a number of IF's.

In the past, perhaps due to dislike for nested IF's, I overlooked the simple fact that they should be nested with an "IF ELSE, IF ELSE, IF..." format. This is important. Once a condition is matched, the other IF statements shouldn't matter.

Breaking large code into smaller methods

I have no scientific evidence for this recommendation but besides the advantage of making a large method easier to read, I've noted that when moving a piece of code onto its own method that I'd get a slight performance boost. It is my impression that the compiler is better prepared to optimize smaller methods than large ones.

ENUM, ENUM

When possible, use and abuse of ENUMS. A comparison between Enums is faster than comparing strings. In the past I've neglected too often this kind of performance magic, simply because it was easy to compare strings, even when using statically defined strings. Looking into the code, I've replaced everything where possible with an Enum. Whenever the value for a given object would only fall into a couple of categories, enum you become.

How to convert from a piece of String to Enum?

Use the .valueOf("sometext") method that available by default on Enums. This turned out to be very efficient converting the set of possible values onto an enum that we can process.

Here is practical example where I get the value from a text line and then place it directly inside an object that expects an enum. If you note, I have no error checking present:
final String temp = tagGetValue(is.tagFileType, line);
tempInfo.setFileType(FileCategory.valueOf(temp));

Trust the data

Another thing that I always tried to do is preventing errors from happening. I placed quite an effort in detecting if a given piece of data was within a set of restrictions before being used. For performance, I can't afford to do these checks. You have to trust that the data being provided can be fed directly onto the object.

What happens when data has a problem? Things fail. There is an exception to be caught and that should be the only safety net that you have around for ensuring that you can process the data. Thinking about our own context, this made sense. For large text files, most of the effort is automated by tooling and not so much by humans. If something is wrong in the file, this should cause quite a fuss in order to be corrected.

The end result is a performance boost since we removed the need for so many IFs: "Is the text different from null? Is the value an integer? ...". Trust the data.

The Final countdown

I never realized how using "Final" for strings could have such an impact on performance. Only now understood how this tells the compiler: "This string doesn't chance EVER AGAIN", which in return blessed the program execution with a whooping speed boost. I'm unable of explaining the intricacies behind this mystery but is something that I'm now using with good results.

This is valid not just for strings but rather for any object out there.


GPU vs CPU

I've considered the usage of GPU (processing through graphic cards). This is wonderful for speeding up the computation but then noted that my own code needed to be optimized and throwing more hardware power at the problem wouldn't really be a solution. Our machines are so much more powerful than most servers back in the 90's. Somehow they managed to get things done efficiently, so must we.

One big loop to rule them all

When looking again into the working code I noted too many loops. There was one to find all files, another to place them on a treeview and sometimes a full loop for each time, resulting in exponential calculations that were not really efficient. So, decided to use a single loop. No excuses, just one big loop to do all the math for each file item.

Wasn't easy at first (a lot of the code had to be rewritten) but guess what? The code previously taking some 8 seconds to compute the treeview paths now takes less than a second. One big loop forces code to be simpler, helps to note immediately if loading performance is degrading somewhere.

Keep strings small

Another thing that helped was keeping the size of strings to be compared as minimally small as possible. Avoid a full string text search, do instead a search that starts from the beginning of the text, up to a specific number of characters.

Code will be deleted

The side effect of optimizing code is removing a lot of the fat existing before. The hardest part is actually deleting source code files because it kind of raises an alarm. From a psychological point of view, deleting files means losing code. I guess it is counter-intuitive that when an application get better by removing code, it just feels wrong to delete old files. Not easy, but a clean-up needs to be done.

If it is not recommendable to delete the source code file, consider moving into the "old" folder where it can be retrieved if/when necessary.


Leverage the knowledge of others

My thanks to Michael Schierl the extra tip added on this post. In his comment Michael brings up the advantage of using tools and frameworks already available to help profile performance. I quote and agree with his comment:
There are lots of code style and performance checking tools available (PMD, CheckStyle, FindBugs) - run them on your code and have a look at least at the "high priority" issues.

If you are too lazy to set up multiple tools and wade through multiple reports, get the free edition of SonarQube, add all free Java analysis plugins you can find, and let it analyze your code, then look at the resulting report. (In case you are using CI like Hudson or Jenkins - most likely for larger projects or commercial ones - add a SonarQube job to it - SonarQube has ways to filter "new violations" - even by committer - if run often enough, so that you don't have to look at the same issues every time.






Java: catch (Exception e) does not catch all exceptions..

Today I was testing a piece of code that resulted in exception. The result from the exception was output to screen.

I've placed the normal "try..catch" block to control the exception but it was stubborn. Completely ignored the generic exception and kept on moving along its way.

After some research on this strange phenomenon, it turns that the "catch-all" (Exception e) is not catching "everything" when an exception occurs. The explanation came from this other blog post at http://10kloc.wordpress.com/2013/03/09/runtimeexceptions-try-catch-or-not-to-catch/

There is another class of exceptions called "RuntimeException".

When replacing "Exception" with "RuntimeException" then I was able to regain control of the exception handling and get more details about why it was happening.

Well, mystery solved.

Java: pluralizer

Every now and then one needs to output quantities in plural and singular forms. In English language it is pretty much straightforward, just add an "s" to the end and you get a plural.

However, doing it programatically adds up a few lines of code that tend to make things less elegant (and simple) than they ought to be. For example, when listing the number of files inside a folder it is annoying to see a text saying "1 files", knowing that this is not grammatically correct.

To solve these cases, I've wrote a simple method.

    /**
     * This method simplifies showing values with associated terms when they
     * occur either in plural or singular manner. For example, solves the issue
     * of output "1 files" onto the correct "1 file"
     * @param value The value to output
     * @param text The text that will be "pluralized"
     * @return The pluralized text
     */
public static String pluralize(int value, String text){
   if(value == 1){
      return value + " " + text;
   }else{
    return value + " " + text + "s"; 
   }
}

As you can see, very simple code. From there I can rest assured that the correct form will be used according to the value that is used.

Java RegEx: detecting copyright string inside source code files

Recently, one of my goals was to detect and index the copyright notices that can be found inside source code files.

This copyright notice is helpful to automatically get a first idea about the people that were involved in developing a given portion of code and can be considered as copyright holders. It is part of the the work with the SPDX report generation tool that you find at http://triplecheck.de/download

Detecting copyright notices is not an easy task. There exist a myriad of different combinations and variations to consider. Nevertheless, it was needed to start from some point and was decided to attempt detecting common cases, such as "Copyright (c) 1981-2014 Nuno Brito".

After some testing, this is the regular expression that was used:

String patternString = ""
             + "(\\((C|c)\\) |)"    // detect a (c) before the copyright text
             + "(C|c)opyright"      // detect the copyright text
             + "( \\((C|c)\\)|) "   // sometimes with a (c)
             + "([0-9]|)"           // optionally with the year
             + "+"                 
             + "[^\\n\\t\\*]+\\.?";
It can detect the following cases:
Copyright (C) 2006-2014 Josefina Jota
Copyright (c) 2012 Manel Magalhães
Copyright (C) 2003 by Tiago Tavares <tiago@tavares.pt>
Copyright (C) 1993, 1994 Ricardo Romão <ricardo@romão.pt>
(C) Copyright 2000-2013, by Oscar Alho and contributors.

It is not perfect. There is no support for cases where the copyright credits extend for more than a single line nor for the cases where "copyright" is not even used as identifiable keyword. Last but not least, there are false positives that I already noted, such as:
copyright ownership.
copyright notice


Currently I don't have a better solution other than specifically filtering out these false positives.

You find the working code in Java at https://github.com/triplecheck/reporter/blob/master/tool.iml/run/triggers/CopyrightDetector.java

And you find a simple test case for the regular expression at https://github.com/triplecheck/reporter/blob/master/tool.iml/test/trigger/TestTriggerCopyright.java

This detection could certainly be improved and the code is open source. Suggestions are welcome. :-)






Windows: single-line command to download and install software

I noted that users of Linux and OSX are sometimes greeted with a very nice feature. Sites like Bowery present on the front page a nice command line code that downloads their software and gets it running immediately.

This is great, however, this was the code provided for Windows:

curl -O download.bowery.io/downloads/bowery_2.1.0_windows_amd64.zip && sudo unzip bowery_2.1.0_windows_amd64.zip -d /usr/local/bin

If you're a Windows developer, you likely notice the above code gets stuck right on the first part of the code simply because "curl" is a command that is not available by default on Windows.

How can this work under Windows?

I was curious and decided to find a way of doing the same thing using only internal Windows commands. Took some digging but discovered bitsadmin to be a somewhat equivalent tool for this task.

And the one-line command that can be run from a Windows command prompt is:
bitsadmin /transfer t http://triplecheck.de/launch %temp%\x.bat&%temp%\x.bat

What does this code do?

bitsadmin is great because it comes inside any Windows machine since 2000 and above. There is a drawback, it is considerably slow. The first line of command will download a batch script and run this batch from the temporary folder.

The first action by the batch script is to create the needed folders (at c:\triplecheck) and then download wget.exe as the default downloader. This is a single and small sized executable that will speed-up the download process.

Then, we get the software. I didn't had much time to implement a way of extracting zip files under Windows from the command line and so decided to use the default cabinet archive format (.cab) for all packaging. My software runs on Java so I've added some checks to verify if there was Java available on the machine or simply download the Java runtimes from my own server.

At this point must say that the independence of Java tastes really great. Just download, unpack and Java is available. After all these steps are done, the script will download a shortcut that I created earlier and places this shortcut on the user desktop for his convenience when launching the tool.

Everything is finished by opening an Explorer window on the newly created folder and starting up the tool.

The full script code can be found at  http://triplecheck.de/launch


What are the advantages?

On my case this provides a one-line command to automatically download and deploy my software on Windows. It is lightning fast, if you already have Java installed then the whole process gets concluded in some 10 seconds on my machine and this is something impressive.


Disadvantages?

I'm using wget.exe and this will be a problem for certain Anti-virus which might not enjoy the fact that a downloader executable gets inside the system. A possible improvement is checking if wget.exe was in fact permitted to stay on the end-user's folder. If it was removed, then revert to bitsadmin as default downloader.

This bitsadmin tool is marked as deprecated, this is actually something that I don't find so often in the Windows world. Very surprised (and disappointed) to read the message. It seems that from Windows 2000 to Windows 8 machines will be possible to run this tool.

Does not run on Windows RT. The installation script does not take into consideration the newish tablets with Windows RT. Therefore the Java runtimes will not work on devices with an ARM processor. The script could be improved but not so many folks use WinRT for this kind of work.

Cabinet files are used, instead of standard zip files. It is possible to later improve this script for enabling the built-in Windows zip extraction but this wasn't something readily available. The drawback is having two maintain two different sets of archives when distributing my software.



Hope you find this useful.











Java: Sorting an hashmap according to its value

I had an HashMap composed with an object and an Integer value associated. By design, hashmaps are not ordered. Eventually, found around the web a nice method and modified the code to ensure it could be generic and ready to use with any kind of object.

Below you find the method ready to use. Attention to the copyright assignment (thanks WikiJava) where I'm referring the source from where the code derives.

 /**
     * Sort an hashmap according to its value.
     * @origin http://wikijava.org/wiki/Sort_a_HashMap
     * @date 2011-05-28
     * @modified http://nunobrito.eu
     * @date 2014-04-04
     */
private Map sortHashMap(HashMap input){
Map<Object,Integer> map = new LinkedHashMap<Object,Integer>();
List<Object> yourMapKeys = new ArrayList<Object>(input.keySet());
List<Integer> yourMapValues = new ArrayList<Integer>(input.values());
TreeSet<Integer> sortedSet = new TreeSet<Integer>(yourMapValues);
Object[] sortedArray = sortedSet.toArray();
int size = sortedArray.length;
for (int i=size-1; i>-1; i--) {
map.put
(yourMapKeys.get(yourMapValues.indexOf(sortedArray[i])),
(Integer) sortedArray[i]);
}
return map;
}

Inside your code, you can use the snippet below. Attention that "FileLanguage" is the name of my object, you can replace this with a String or any other object you wish.

// sort the result
Map<Object,Integer> map = sortHashMap(statsLanguagesFound);
// show the ordered results
for(Object langObj :map.keySet()){
FileLanguage lang = (FileLanguage) langObj;
int count = map.get(lang);
System.out.println(lang.toString() + " -> " + count);
}


The end result is the following:

File: busybox-1.21.1.spdx
C -> 796
UNSORTED -> 674
SCRIPT_LINUX -> 19
HTML -> 9
PERL -> 3

File: flyingsaucer-R8.spdx
JAVA -> 4
UNSORTED -> 1

File: jfreechart-1.0.16.spdx
JAVA -> 1035
UNSORTED -> 57
HTML -> 48


Hope you find it useful.  :-)

Java: counting how many times a string is repeated

Recently I needed to find a simple way to count how many times a specific keyword is repeated inside a large text. A regular expression would be possible but (besides the complication), it is very slow on large text files (>60 000 lines).

The solution, a very simple code that is crude but works with good enough performance:
int counter = (text.length() - text.replace(keyword, "").length()) / keyword.length();

Not intensively tested but functional.

Hope it helps you.

A escolha


Mais um dia fechado em casa
e como depressa o tempo passa
Até parece que o tempo escapa
e depressa transforma em nada

Às vezes procuro um plano d'salvação
mas lá no fundo já fiz a minha opção
entre fugir ou enfrentar o perigo
venha o diabo como meu amigo (ou não)

Java: removing the non-numbers characters from a string.

This is one of those code warrior snippets with two-lines that one never seems to find around the Internet, so I'm posting here for reference.

If you have a String and want to remove all the characters inside the string that are not numbers, this works:

public static int justNumbers(String input){
         String temp = input.replaceAll("[^0-9]""");
         return Integer.parseInt(temp);
     }

 Seems pretty simple doesn't it? Now look around the Internet and see the other techniques being proposed.

Hope this helps you.

TripleCheck, Beanshell and SPDX

I've been using most of my free time to develop the new SPDX tool. It started as command line tool and then moved up to a desktop edition. 

Not happy with the usual static forms that you see on normal GUI applications, I decided to add a flavor of HTML inside the Swing containers. The result was great. Then, I wanted to make sure that other people could change the code. It is no fun when you always need to compile things around when all you want is to just change a few settings.

Beanshell was used for scripting the plugins. Editing Beanshell scripts is not so much fun when programming errors happen. There is no syntax checking, no assistance to write code in the same smart manner as you see in modern IDEs available today.

The answer was creating what I call of Java-like beanshell. Moved things up to a state when you can comfortably write a Beanshell script exactly in the same fashion as it was a normal Java file. This was one heck of a productivity boost. Suddenly, writing dynamic scripts was much easier thanks to this neat trick.

Then came the next step, what about the web? I had been avoiding the idea of writing a web application. Basically because it places some restrictions such as requiring users to open a network port on their machines, which might not be possible on the case of many people working on machines at their companies.

Solution? Do a bridge between desktop and browser world. Today I completed this goal. The screenshot below demonstrates how it is possible to write java-like beanshell scripts that will behave exactly the same, regardless of the user access the program from the desktop or web edition.


 


From a programming point of view, this makes life quite simple. Imagine this thing like a PHP meets Java and Ruby on Rails altogether.

It is quite a mix. The best of the Java infrastructure (OS agnostic, robust language syntax, huge repository of available libraries and connectivity), the best of Beanshell (scripting just like PHP) and the best of two user interfaces: Desktop and Web Browsers.

Inside the beanshell script, a method is declared with the object that contains all the details about the request. Writing a plugin for the log viewer was a simple as this:

    /**
     * Displays a basic log of what has been happening
     * @param request The request from the end-user
     */

    public void showPage(WebRequest request){ 
       // get all the messages since the beginning
       String result = log.getMessagesSince(0);
       // replace the break lines with an HTML break line
       result = result.replace("\n", html.br);
       // write everything for the user to read
       request.setAnswer(result);
    }

Really simple, really fun.

I'm doing this code for the TripleCheck software that generates SPDX documents. If there is interest, I can later release this particular part of the code as project of its own for those who are interested in:

- Writing apps that work both on a Swing or Web browser
- Writing apps based on a Java-like scripting language that can be written from a normal IDE
- Keeping things simple and small (the whole software is less than 10Mb)

:-)





BeanShell unleashed

I'm a big fan of BeanShell.

Not only I enjoy the fact that this was the first scripting language available for the Java platform, as I really enjoy the phenomenal possibility of allowing the users of my software to make changes.

Phenomenal is indeed a suited word. The potential of BeanShell is unleashed on the fact that after a given software is compiled it gets very complicated for end-users to customize a tool. So, this nifty scripting language does what is needed.

There is however one bogging weakness. There is no proper IDE available for writing code in BeanShell, let alone an IDE that allows integrating the scripting language directly onto the libraries from our software. You get code that anyone can modify with a simple text editor and at the same time abdicate the comfort of modern day development environments since not so many folks play around with this kind of scripted language.

I've been dwelling with this IDE problem for more than two years now across different products being developed. Tried different approaches but the result was still lacking in terms of quality, until today. :-)

For a while now that I imagined how it would be possible to combine an IDE (say NetBeans) with BeanShell. The basic Java language is equal to some degree on both sides, should be noted that BeanShell is no longer a developed product and the language stopped on Java 5. Still, what would happen if we renamed the common beanshell extension (.bsh) to a .java extension?

And so I did. It was easy to configure NetBeans to accept an additional folder as source. The problem are the small differences between the two worlds. What I did was quite simple, I created a new class and then dropped the code from a BeanShell script inside.

Eventually, I noticed that it was possible to parse and change the lines of the script file in RAM, modifying the Java code to be acceptable as BeanShell. Not many changes were needed:
- Removing the declaration of "package"
- Deleting "@override" sentences
- Modifying the "class" sentence to create an object of the Plugin class

After these minor changes that are automated when running a script, the Java code becomes BeanShell code. Awesome! I can keep using the same IDE while at the same writing scripts with a syntax checker and all the fancy tools that allow adding up so much code automatically nowadays.

I'm not planning in doing a separate product to demonstrate this kind of functionality in action, but if you're interested then do let me know and I will do a small prototype.

BeanShell rocks! :-)


New laptop - Lenovo U310 (i7 version)

After fighting many battles with the help of my faithful Toshiba R630 over the past years, I've now placed it to rest and got a new machine.

Before getting into details of the new machine, I have to say that Toshiba has really lived up to my expectations. It has been exactly three years using the laptop nearly on daily basis for most of my day-time work:
  • Battery holds a full charge and I can work some four hours without an electricity plug
  • Original Windows installation that came with the computer is still working great. Updates and normal usage over these years haven't made me need to remove it away
  • DVD drive got broken, no longer works
  • From the outside, still looks as a modern machine

So, why have I got a new machine then?

As part of my work I need to run some very specific tools. One of them has a database of over 450Gb and requires (at minimum) some 8Gb of RAM to be able of functioning. It is a software intended for server machines. However, I wanted to have something portable and independent of network connectivity. Initially I just bought an 8Gb memory card and a new SSD upgrade for my old laptop but unfortunately this was still not enough to make the software perform as necessary, so a new machine seemed like a reasonable approach.

I wanted to keep costs at minimum, I wanted an i7 CPU processor, some 8Gb of RAM and I wanted the new machine needed to look "nice". Please don't burn me for wanting laptops to look nice, just remember that I will work with the same machine on daily basis for several years in a row. When possible to decide which machine to use then I will give some selection points to aesthetics.. :-)

After consideration of the machines available right now, I've found the option from Lenovo as the most interesting one for my case.

The specs were nice:
  • i7 CPU
  • 8Gb RAM
  • 500GB HDD
  • 26Gb SSD
  • Touch screen
  • Windows 8
  • Compact machine (not a bulky laptop)
  • Stylish look (dark-blue metal)
  • Under 900 Euros

I couldn't find many reviews online about this specific model. It seems that all the reviews that I could find discussed only the i5 CPU with 4Gb of RAM from an older model. So, it was kind of a "leap of faith" to trust fully on the specifications from the manufacturer. In either case, not much risk was involved since I am allowed to return the equipment in case it doesn't perform to what was needed.

So, I've got this machine and my first reaction when unpacking was "wow, it is small". Over these years I should already got used to how fast technology packs such a hefty power into smaller and smaller devices but quite honestly this is something that I enjoy getting surprised about.

The initial boot went ok, Windows worked. This is my first machine with Windows 8 and I've got to say that I find the lack of a start menu disturbing. I've read that with Windows 8.1 there is some kind of alternative being added, let's see. My goal wasn't having a Windows 8 machine, what I required was a Linux operating system to be up and running as fast as possible to test the software.

My weapon of choice was Linux Mint. Optical drive is not available on this laptop but typically you can install Ubuntu/Mint straight from Windows. I did a mistake here. On my desk table was already available an ISOstick with Mint available as ISO and I decided to install it from there to save some time. The big problem is that later during the reboot it launched the CD installer and from there I decided (on my own will) to ignore the Windows installer, causing later to have two entries on the boot menu. Lesson learned, next time I will just use the ISOstick with Mint to permit running Linux in full speed.

On newer laptops, I should note that it might help to try disabling the "Fast boot" and "secure boot" services from the BIOS setup in case you're not getting the boot up to happen.

With an SSD equipped on this laptop, I decided to use this disk as default location for the Mint install. Also my first time running a Linux install under SSD. Under an hour I had my basic Linux setup running amazingly fast from SSD on a machine with an i7 core and 8Gb RAM. All basic drivers worked out of the box (WIFI, sound, screen and even shortcut keys). Didn't tested the web camera or other details, might also be working. My only complaint is that the mouse pad is very sensitive and quite often the mouse tracker moves (and changes the text cursor position) while writing text because of your wrists touching it. The Windows driver is ignoring this kind of design quirk but the Ubuntu driver was not handling this quirk by default (will later try to find how to get this point addressed).

From there, got the older versions of MySQL 5.1 and the Oracle JDK 1.6 working. Copied over the database and then the software functioned as intended. I was happy, problem solved.

I like this machine. It is more silent than my older Toshiba laptop and still strong enough to act like an enterprise machine when needed. I didn't had much contact with Lenovo before, only knew them after the acquisition of the ThinkPad product line from IBM and was quite impressed to see such a nice ensemble available on this equipment. Let's see if it will last long on my hands. :-)


Testing Windows 8

After a while, I went back to the Windows 8 install to see what I was missing with the new OS. There are some things I like about the metro design. It is great to use touch for displaying pictures and talking about them with others. I found the Windows market place quite poor in comparison to Android's. The worst thing for me was not knowing how to "search" for apps. Had to look around the web to discover that I needed to press "Windows-key + Q" to call the search box or use swipe the finger to bring about the right-side menu with the search bar. Lesson learned, I just wish there was some kind of visual hint or button for this action.

The lack of a start menu was indeed a bother. Took me quite a while to rebuild some of my often used shortcuts for Windows utils. What I hated most is the fact that I can't quickly type from the start menu to find a program like before. I've ended finding "Start 8" from IOBit as alternative, this software impressed me because it addresses exactly what I wanted. The problem: it seems to be powered by infamous "push ads" and has already asked me to install some "system cleaners" that I would gladly live without. I'm still keeping it installed, hope it doesn't get worse or another option needs to be found.

At the end of the day the biggest surprise was something unexpected. I was in bed with my better half, she wanted to see something nice on the PC before falling asleep. Out of her own initiative she clicked on the "bing travels" icon to see some holiday pictures. Inside this metro app came the option of looking at some 360 degree pictures from famous locations. I was impressed. The touch screen was so responsive and you could use the fingers just like in "Minority report" to explore the given detail of a location. What an unexpected surprise, the future is arriving at quick pace indeed. In the end, we both enjoyed doing some tourism without leaving the house. Definitively a plus point there for the nice surprise.


The aftermath?

New machine, plenty of work. Let's move. :-)


Ubuntu and Richard Stallman

Typically, I enjoy participating around the web in forum sites, mailing lists and just any other normal social activities.

It is a good experience for the most part, can say that I've learned so much from plain interaction with other folks around the web. However, the current situation with Ubuntu turned into a distribution that automatically logs your activity and sells this information to other parties is something that deeply upsets me, mostly because I really hoped that the Ubuntu project would not turn evil.

This just gets worse with Unity. A user interface that goes against any comfort for the end user and that on the most recent editions of Ubuntu reveals the reasons why it was so oddly designed: mixing advertisements with the tools that people are looking for.

Very sad, very disappointing. The border line of this situation was looking on the announcement of an article at ZDnet entitled "Ubuntu 13.10 Review: A great Linux desktop gets better".

Using the term "review" and "better" as head line for the article is a shame for ZDnet, should be better called "marketing" with the author minimizing the critics to the Unity interface or selling of data to Amazon while going as far as praising the install procedure to bring users into the Ubuntu One cloud storage with "5GBs of no-cost storage. The commercial version, at $39.95, gives you 20GBs" .

Seriously. On a time when governments around the world are exposed for obvious enticing of people to place more of their data in the "clouds" where everyone can bypass the basic privacy rights of end-users, this kind of thing really brings me to disappointment.

Even worse to see normal people making the work easier for these marketeers and to support them completely. I was frustrated. Like a religious person in Brazil (Padre António Vieira) once said back in the 16th century when criticizing the slavery practice: "If nobody cares about what I preach, I will preach to the fish but will not stay silent". Reminded me of what Richard Stallman once wrote about Ubuntu some time ago and how it still made sense today. I understood better the motivation of Stallman and Vieira to write such words, it is disappointment.

So, feeling overwhelmed with people replying on the forum topic where Unity is great, where the loss of privacy is not true despite recent leaks. I felt quite alone on this question and wrote a message to Richard Stallman. To my surprise, he replied with calming words of advice.
When people say, "Nobody cares", you can respond, "Quit exaggerating.
Lots of people do care.  Neither of us can speak for others.  The
question is, do YOU care?"
It was a pacifying answer. At that point I just wanted to go back into the discussion, talk loud, do noise and bring to surface that these kind of things are simply not right. His answer is much less conflicting, indeed there is a lot to learned from RMS.

So. Lesson learned. I stopped arguing with those folks on the forum topic after feeling that there was nothing more of productive to be added from my participation. I will nevertheless preach to the fishes with the hope that some day in the future we can have Ubuntu as a "good-guy" again.


Com! magazine article, progress on wb

It has been exactly a month since the new winbuilder generation was released and I already see a screenshot of the software on the most recent edition of the Com! magazine.

Kudos for the editorial team that works so fast! :-)


The next step already in progress is to add support for visually impaired users, following the feedback from users it was possible for me and Peter to make sure that the next editions of winbuilder can be used by users who cannot see.

The choice of using Java has really helped out to make this possible with minimal effort on our side, there was already available a bridge for Windows workstations that allows to tie up directly with the accessibility features. To test, I have installed NVDA on my own computer and simply closed my eyes to get into the skin of those who cannot rely on vision to use a computer. It is not easy, users that struggle with this problem every day have my utmost respect and admiration.

The NVDA software reads out loud what is happening on the screen to the end-user. Since wb is distributing its own version of Java, it was possible for us to slipstream the files required to make the bridge connection work. This way we make winbuilder easier to be interpreted by NVDA.

Things have been so busy recently that I haven't had as much time as desired to do all the things that are needed. Over the past month I've changed the default theme of official website to a MSDOS theme: http://winbuilder.net and then updated some of the content. There is still the need for a big overhaul and to write proper documentation. It is kind of convenient to publish no documentation for the moment since it helped to refrain the motivation of developers to write plugins for a not-yet stable platform, allowing us to make the needed changes/corrections with minimal impact to both developers and end-users.

Packed inside winbuilder is also the phenomenal support for creating VHD archives out-of-the-box, but I've got really no time to go ahead and write projects that demonstrate this feature to create VHD based boot disks. Anyone available to volunteer for the task?

On a side note, UBCD4win has no longer a forum. This was kind of sad to see. Anyone knows what happened?

Lots of work, let's move my friends! :-)











The new Winbuilder generation

Today was a great day. The new winbuilder generation was made available for the first time to the public.

It is a moment that I'm proud in watching. Was a long walk over over the last 4 years to reach the current state where we are able to provide the first WinPE builder in the world that is fully independent from Windows API.

A lot of work to implement native support for reading/writing:
- WIM archives
- ISO 9660 archives
- Link files (used for shortcuts)
- VHD containers formatted with NTFS
- Registry hives
- the details of Windows .exe files

For the first time, a builder combines all necessary components necessary to create a Windows PE boot disk in a fully independent manner.

Why does this matter?

Because controlling the aspects of building a boot disk introduces an amazing level of quality assurance in regards to the end result. We are now able to predict exactly how the builder will work regardless of the platform underneath.

But the new builder doesn't just introduce platform independence, it brings great features such as user interface abstraction. For the time, we have built an application that simultaneously supports three distinct types of user interfaces straight from the box. You can use the command line, use a normal GUI or even use a web browser if you wish. They are all equally relevant and empowered for controlling winbuilder either from an unattended process, or remotely across another computer somewhere on the network, or from your own desktop as traditional if so you wish.

There would be a lot to talk about in regards to changes, I'd just like to resume some of the other relevant points for the sake of succintness:
  • uses java-like language for other developers to write their plugins
  • we make available an app-store web service for uploading and distributing the plugins
  • plugins use a "hook" system that allows them being triggered according to specific system messages
  • settings for plugins use a nice a customizable HTML format
  • Windows, Mac OSX and Linux are supported as platforms
  • can automatically build a WinPE boot disk without needing user interaction
  • does not requires admin permissions
  • does not require installing any drivers
  • supports full translation of log messages to other languages

I'm really happy. Boot disks are generated in around 3 minutes with no fuss.

If you would like to try it out, it is available at http://reboot.pro/files/file/342-winbuilder/

Have fun!
:)

A trapped Nokia

And so the riddle ends. Microsoft made a deal to buy the Nokia phone division for an incredibly low price of 4 Billion euros.

Might help to note that the current CEO of Nokia was a Microsoft executive just three years ago. When he first arrived, I just hated to see his decision of throwing away the Meego operating system in preference of moving to a Windows phone OS.

You might not remember but Nokia was an early supporter of Linux based operating systems for cellphones, their machines were not only in front of the market as the software itself was already ahead of times.

Microsoft on the other hand, pushed their muscle and made nothing other than Windows CE. An operating system that resembled more of Windows 3.11 than a modern OS for handheld devices. It is sad. Sad that Microsoft never really understood that people have an opinion and a say about their technology preferences. As a big company, for sure they can make life harder on end-users to ensure they get squeezed but you won't get loyalty out of them that way.

It isn't surprising that when a valid alternative surfaces like Android, that people just jump in flocks. Now, through planting a trojan horse as CEO on Nokia and bringing it down to the knees we see MS acquiring the assets of the once largest cell phone manufacturer.

What Microsoft management seems to neglect is that good karma and reputation are based on what you do, these are not things that can easily be bought.

Through this awful chain of events, the former Nokia CEO, Stephen Elop has acquired a awful amount of bad karma. First for destroying the independence of Nokia as a software and hardware manufacturer, second for selling the phone division to Microsoft and jumping happily to their wagon.

Now tell me. Do you really think that people will support a windows phone built with such people in charge? I'd say plenty of analysts will say that people are like sheep which either don't know or don't care about these kind of things. But let me tell you, Nokia as a cellphone maker had a story of their own. Had emotions, had a spirit and a touch that made users feel quite connected to their adventures.

Microsoft has no such thing. Has Ballmer as (ex)CEO that bullies just about everyone and now a pretender to his throne (Elop) that literally buried one of the most shining cellphone makers in the world.

Maybe people are dumb indeed. With Internet access still being relatively free in the current day and age, there is plenty of information and the sympathies will not be high for Microsoft.

The price given for Nokia is a shame indeed. Just this week Verizon bought over half the stocks on their own company that were owned by Vodafone in a deal that was worth over 100Billion. Skype, the chat program bought over by Microsoft was done for a cost of 6 billion.

Not good, not fair for Nokia.

At least Elop is far away from the Finnish company now.

Nokia, how about starting a new phone division?

An MSDOS theme for Wordpress

I don't know where to use this theme right now but I'm writing a blog post so that more folks can find it: http://wordpress.org/themes/wp386

A great looking MSDOS theme. Call it "DOStalgy" but I sometimes really miss those days.

The rebirth of SourceForge

Sourceforge has been quite a presence in my life, it is the place where eventually I ended up visiting way too often across the years whenever in need of downloading some file from an open source project.

One thing that always bugged me was the fact that the site itself was quirk, slow and just plain difficult to use for both developers and end-users.

Now, I'm getting pleasantly surprised (and perhaps spoiled). Slowly, very slowly I see a new Sourceforge surfacing. It accepts logins from the most popular web services available today (google, facebook, twitter, ...), has a front page that actually looks useful and inviting for visitors to use. Last but not least, finally seems to be focused in improving the forum support. Check it out at https://sourceforge.net/

Bravo! I have to say that this is a rebirth for this giant.