Well, its a while now but new hardware has been anounced and it really is quite impressive!
Key Stats
Theres more than the list that I’m showing, but theses are the most interesting ones. Among other bits are the X4170, X6270 and some new NEMS for the SunBlade 6000 chasis.
Well, it appears that google chrome is faster than alot of things. Namely:
Potatoes fired from a cannon
Paint shot by sound wave energy
Lightning striking a little ship (big ships untested)
All is explained and proved in the following little video. Credit to the editor of this filming, but I do have to say, the final test doesn’t look 100% fair, the mouse may have been clicked a split second too soon.
“:” is a little known Bourne Shell operator which is actually quite handy. However, like a alot of other short hand operators, its easy to forget, especially when its not used that much.
So what can it do?
You can replace the true command with it, letting you write something like:
while :
do
some_commands
done
Leave the then part of an if statement empty:
if :
then :
else :
fi
I agree, that example is probably useless for now, but amusing none the less.
So there you are! Next time you fancy steering from the norm of using true, you know what to do!
Oracle recently made a set of presentations which outlined what their strategy was in terms of hardware, software, markets etc.. Each speaker had a slide show to accompany their talks, and each of the slideshows was quite extensive.
Speaker
Webcast
Presentation
Charles Phillips: Welcome and Oracle + Sun: Transforming the Industry
His slideshow has one slide; a picture of a racing yacht with Oracle and Sun logos on it! This for me sums up his character. Hes got a ton of energy and sees his company more like something that he needs to guide and be successful with, and at the same time looks good whilst doing it!
In this respect, Oracle have made it very clear what they want to do with the portfolio they have acquired from Sun, and this does include investing heavily in SPARC processors. Given the kind of performance we saw with the T1000 on Heanets review, I’m personally looking forward to the day when Oracle manage to further commoditise this cool hardware
This little box seems to be quite far ahead of its time. I can imagine that there must be so many futurologist out there just waiting to see their ideas come into the mainstream, and then jump for joy when it finally does!
It has been announcedtoday that approval has finally been given for Oracle to merge with Sun Microsystems. The process began in September 2009 which means that its been long enough for plenty of rumours to go around about whats going to happen both internally with head count cuts, and of course with the product line itself. Most importantly, the people with power to make decisions in these two structures now actually have the opportunity to go ahead and make those decisions.
If Larry is true to his word about what he sees for the future of the Sun product line, I for one would certainly say that the future is going to be fairly bright.
Mr Ellisons (CEO of Oracle) own words:
“We are keeping everything. We are keeping tape, we are keeping storage, we are keeping x86 technology, we’re keeping SPARC technology, we’re going to increase the investment in it…”
“…we are NOT going to spin anything off.”
The discussions about improving data center power consumption efficiency and increasing demand for online services place the T-series equipment very well for those who know just how good they are. Coupled with the fact that Sun had famously invested early in the R+D for this kind of technology, theres also a great opportunity to get OpenSolaris beefed up in terms of packages and installers, and deployed in these environments.
I’m looking forward to seeing how its all going to pan out!
anton@opensolaris:~$ lynx -source localhost:8000
<title>Directory listing for /</title>
<h2>Directory listing for /</h2>
<hr>
<ul>
<li><a href=”lalala”>lalala</a>
</ul>
<hr>
…for those of you that want to see the source it produced! A very quick short term solution if you don’t want to go about setting up apache or change your apache settings!
Ten days ago we had a look at Java’s ability to deal with numbers which had alot of decimal places. Liam pointed out that having to loop through a variety of operations is longer than performing a more efficient operation once.
With Liams magical formula, we get the following Java, with no loop:
importjava.math.BigDecimal;publicclass The_proper_half {publicstaticInteger times_to_loop;/**
* @param args the number of times you want to run the loop
*/publicstaticvoid main(String[] args){
calculate(Integer.valueOf(args[0]));}publicstaticvoid calculate(int times_to_loop){//The Number we want to halfBigDecimal number_to_half =newBigDecimal("10");//The result of doing the halfBigDecimal the_half =newBigDecimal("0");//The number we want to divide byBigDecimal divider =newBigDecimal("2");
the_half =(number_to_half.divide(divider.pow(times_to_loop)));System.out.println("The last number has "+((Integer) number_to_half.subtract(the_half).toString().length()-2)+" decimal places: ");System.out.println(number_to_half.subtract(the_half));}}
As you can see, we only perform the opertation once (line 23), but admitadly, to get the correct number at the end, we still do the subtraction at the end!
Regarding optimisation, there are huge benefits. It turns out that the old way if hugely costly for thousands of iterations. These are the results for 10000 iterations, the old way:
anton@anton-laptop classes $ time java Half_of_a_half 10000 > /dev/null
real 5m22.714s
user 5m21.320s
sys 0m1.052s
The results for the new way are much better:
anton@anton-laptop classes $ time java The_proper_half 10000 > /dev/null
real 0m1.019s
user 0m1.248s
sys 0m0.052s
So it went from over five minutes, down to just a second. That was just by changing from a loop a single statement. Thats pretty cool stuff!
I have to admit here, the difficult bit is probably not the code. Its the abillity to see how a problem may be translated from one way of expressing it to another. Its that bit of genius thats really done the work here. Credit to Liam for the genius!
This is a common riddle, so if you’ve heard it, don’t shout out the answer (people might think your strange for shouting at the internet….)
Take a number. Then, half that number. Then half that half and add it to the first half. Before that gives people a headache, lets do a little example:
Lets use 10 . Then half of ten gives us 5. Then, half five (2.5) and add it to the first half, 5. This gives us 7.5
Continue to half the last half, adding it to the sum of the previous halves. Phew, I hope thats explained properly.i.e. half two point five, and add it the the 7.5 we already have, which give us 8.25
Okay, so the question is this. If we keeping adding on the halves, will we ever reach 10 again? Well, I like Java, so lets get all geeky and model the problem. For this, the double and float data types won’t give us enough decimal places. For this, we’ll need: math.BigDecimal . The Big Decimal. Sounds ominous!
importjava.math.BigDecimal;publicclass Half_of_a_half {publicstaticInteger times_to_loop;/**
* @param args the number of times you want to run the loop
*/publicstaticvoid main(String[] args){
calculate(Integer.valueOf(args[0]));}publicstaticvoid calculate(int times_to_loop){//The Number we want to halfBigDecimal number_to_half =newBigDecimal("10");//The result of doing the halfBigDecimal the_half =newBigDecimal("0");//The number we want to divide byBigDecimal divider =newBigDecimal("2");for(int i =0; i < times_to_loop; i++){
number_to_half = number_to_half.divide(divider);
the_half = the_half.add(number_to_half);System.out.println(the_half);}System.out.println("The last number has "+((Integer) the_half.toString().length()-2)+" decimal places");}}
This code takes a single parameter on the command line: the number of times to half by
e.g.
anton@anton-laptop classes $ java Half_of_a_half 10
5
7.5
8.75
9.375
9.6875
9.84375
9.921875
9.9609375
9.98046875
9.990234375
The last number has 9 decimal places
So as we can see, the decimal places just get long and longer. The additions are never big enough to get us close enough to the original number. Problem solved!
The fun bit is realising the significance of the calculation, or rather, the speed with which it was done. Performing 1000 divisions and additions takes less that 0.2 of a second! Maybe thats not so fast by todays computing ability, but by human standards thats pretty extreme.
anton@anton-laptop classes $ time java Half_of_a_half 1000 > /dev/null
This post has long code segments in it, so I’ll explain what it all does at the top. Then at the end, just copy paste into your favourite editor/IDE to play with it.
So the title kind of gives it away, but the concept behind it was quite interesting. Imagine you have some kind of resource, like a network connection, a file etc, which is needs to be accessed by many threads, but only one thread at a time. Using synchronized methods achieves this. Its especially handy where you might have hundreds of threads which need to modify the same resource, but should do it, one at a time. This code can do that (although its not perfect by far)
In this example, we have a padlock, which we can open , and close. Of course, we can’t open it whilst its being closed, and vica versa. You could just run the openLock and closeLock methods one after the other, but using threads gives us some bonus features. For example, we might want to open the padlock, get half way through, and then realise we want to pause, leaving the rest of the work for later. Or maybe we want to get halfway through closing the padlock, and then change our mind and open it (i.e. without fully closing it)
packageworkingWithSynchronizedThreads;importjava.util.logging.Level;importjava.util.logging.Logger;/**
* This class represents a simple padlock. You know, like the kind you use to
* lock up your bike. I use it as an example of how we can make fields in
* java , then try and access them through different threads. Using syncronised
* methods, we will prevent the lock from being opened whilst were still trying
* to close it.
* @author anton
*/publicclass padlock {/**
* Constructor object to make a new padlock
* @param isThePadlockOpen Whether the padlock is open or closed
*/public padlock(boolean isThePadlockOpen){this.isThePadlockOpen= isThePadlockOpen;}/**
* This field tells us whether or not the lock is open or closed (true for
* open, false for locked)
*/publicboolean isThePadlockOpen;/**
* This method simply sets the padlock to be closed by setting isOpen to false
* Closing the lock takes two seconds (hence the sleep statements) ).
*/publicsynchronizedvoid closeLock(){try{Thread.sleep(1000);
isThePadlockOpen =false;System.out.println("I'm closing the lock");Thread.sleep(1000);
tellMeIfThisLockIsOpen();}catch(InterruptedException ex){System.out.println("I couldn't close the lock");
Logger.getLogger(padlock.class.getName()).log(Level.SEVERE, null, ex);}}/**
* This method simply sets the padlock to be open by setting isOpen to true.
* Opening a lock takes two seconds (hence the sleep statements ).
*/publicsynchronizedvoid openLock(){try{Thread.sleep(1000);
isThePadlockOpen =true;System.out.println("I'm opening the lock");Thread.sleep(1000);
tellMeIfThisLockIsOpen();}catch(InterruptedException ex){System.out.println("I couldn't open the lock");
Logger.getLogger(padlock.class.getName()).log(Level.SEVERE, null, ex);}}/**
* Lets us know if our padlock object is open or closed
*/publicvoid tellMeIfThisLockIsOpen(){if(isThePadlockOpen ==true){System.out.println("The lock is open!");}elseif(isThePadlockOpen ==false){System.out.println("The lock is closed!");}else{System.out.println("Something is seriously wrong!");}}}
Do we need to do that casting from padlock to padlock in the openLock and closeLock thread classes?
Is it ok/understandable to make a field a question? (public boolean isThePadlockOpen;) ?
The inspiration for this work came from looking at some code were working on in my department, but the learning was really done looking at the Java Tutorials, which are ace!