Monday, November 8, 2010

Why .NET?

The question is "Why .NET". Well it really starts with why a Virtual Machine (VM) runtime. The answer for me was :

When you think of your software running unattended for large periods of time and factor in the time you have to develop said software ... VMs help. 

Goodbye C++ / C. Hello .NET / JAVA. 
Now, "Why .NET". Really once you have settled on VM the only options you have for mass consumer targeting are .NET and JAVA. Really. 

So why .NET is actually a question of "Why not JAVA?" or "What makes .NET Better than JAVA?" 
Before I continue. Note that a major part of my final year project for BE Telecom was made in JAVA. (A SIP Proxy server). So there was a time that I "Loved" JAVA. 

JAVA as a language:
Java still doesn't have true getters / setters. You need to type GetName SetName yourself. If its a standard push it to the compiler please. 
The reason is that language features need to go through JCPs and it can still take years before it makes it to mass distribution. A non evolving language is either a dead language or a dying language albeit really really slowly (A note on JCP's lack of progress : http://blogs.apache.org/foundation/date/20101209 ). 

So here are the features I love in C# as it Evolves:
Properties
Linq
Dynamic Types
Yield (oh it is so hot!)
Async Programming
WPF ... okay its a library ... But an AWESOME one at that. Swing just does not come ANYWHERE close anymore

These will take a long time to make it into JAVA (if ever). JAVA is more focused on APIs rather than the Language itself. And the Desktop APIs still suck. More on that later. 

Now for the annoyances that already made it to the language. 

Exception me please:
You cannot add a new exception throw all of a sudden without the compiler complaining. All for the supposed claim that it will prevent unwanted exceptions. And the fun part. It can be bypassed. Virtualize or late bind much? I do. 
PS: Mostly people are just forced to catch and ignore exceptions. The compiler actually breeds BAD code. 

Return:
Okay I am being sloppy here. But while testing I like to return prematurely from a function sometime. Or maybe I write half the code. Then to test something else I put up a mock return. In JAVA I need to Comment out the remainder of the function just to compile. I prefer the C# version of the warning me but not getting in my way. Just run the code. 

Swing:
For those that don't know Swing is the THE premier JAVA GUI framework for the Desktop. What got me was Windows Vista going into the Windows classic look and feel stating "A running program isn't compatible with certain visual elements of windows". I would hate to explain this to my clients. http://www.hanselman.com/blog/SunsJavaJRESwitchesVistaAeroIntoBasicUIScheme.aspx

Jeff Atwood pretty much explained everything wrong with this in 2007. Its funny how a bad Desktop UI will almost always have a mention of JAVA.
 Oh did I mention desktop applications are what made me fall in love with programming and before Flex (yes it came first)/Silverlight desktop apps are the only place I would be found. Other than "really" trivial PHP scripts :).  PS: JavaFX has terrible penetration for a reason :) 

I like applications full of power. Desktop is the way. AUTOCAD / MAYA / MAPINFO / MATLAB / MS Office / TEMS  all great applications that are primarily on the Desktop for a reason. And if you are going to go to a runtime. You know which one to choose :). Plus I do Telecom Software. We love the Desktop. Its our home :)

Java and Lawsuits. So much for "Open": 
To be fair. Java defends "http://en.wikipedia.org/wiki/Write_once,_run_anywhere" very strongly. But their J2ME is no treat either. 

Microsoft:
Well for quite a while (a long long time ago) Microsoft's implementation of JAVA was awesome with great Developer productivity. Till Microsoft got sued for it: http://en.wikipedia.org/wiki/Microsoft_Java_Virtual_Machine
So Microsoft came up with .NET. Maybe Redmond already had such plans but I don't know. 
Microsoft responded for being sued by Sun: http://www.internetnews.com/ent-news/article.php/988071/Sun-Sues-Microsoft-Over-Java.htm Java still doesn't come preinstalled in windows. Your hardware vendor might do so. 

Google:
Yes. For android. Oracle sues Google for Java derived runtime: http://news.cnet.com/8301-30684_3-20013546-265.html . Google does not attend JavaOne : http://googlecode.blogspot.com/2010/08/update-on-javaone.html

Oracle is a financial institution
Oracle defends its profits VERY diligently. 
They did make MySQL InnoDB commercial as well : http://www.cloudave.com/7356/internal-email-on-why-a-software-company-migrates-away-from-mysql/ (Note the CEO also warns against JAVA). But I saw that (thanks to other intelligent folk on the internet) coming from a mile http://basaratali.blogspot.com/2010/05/free-for-commercial-use-high.html . Postgresql is the future MySQL. 

Finally Some JAVA love:
Java is not all that bad. I wouldn't be caught dead writing a JAVA app for the desktop....never again. But for the server of the top of my head GWT is cool. Well at least the results are ... I haven't tried it myself. Pentaho is very cool. JasperReports are amazing. These are not "JAVA" goodness per say but hey a runtime is valued by what it runs. So I guess its third party love :) But for my raw code I still doubt I would ever go there. 

Fun Java Quotes by People I Respect: 
If you feel these are taken utterly out of context. Well Quotes usually are so I link to the complete context :)
Everything on this page is my opinion. I am in no way legally liable for anyone else's actions.
The last update time for this page should help, since technology changes and JAVA might get these features :) 

Sunday, November 7, 2010

Setting up mojoportal on windows 7 64bit with sqlite

Yes ... these are all technically evaluated requirements :)

Just downloaded and extracted the "mojoportal-2-3-5-5-sqlite-net35-deploymentfiles.zip" file. 
Renamed "user.config.sample" to "user.config"
Defined a new website in IIS 7.5.

Anyways, First off I noticed my IIS was not working with ASP.net Error
Calling LoadLibraryEx on ISAPI filter 
Fixed it using the following: 
cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
aspnet_regiis -ir

Next I got the following error: 
There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined

This is because we are using .NET 4.0 on a .NET 3.5 website :) 
Just go to IIS application pools and change the runtime to .net 2.0 as shown: 


Got the following error:

An attempt was made to load a program with an incorrect format

Lazy of me. They did mention this one. http://www.mojoportal.com/sqlitesetup.aspx
Did exactly as they pointed out: 



Again navigated to:
http://localhost:8080/Setup/Default.aspx

Got the following Error:
Could not load file or assembly 'WebStore.UI' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded


Downloaded the source code changeset linked to the 2.3.5.5 release.
Extracted and Opened mojoportal.net35.sln
Right clicked "WebStore.UI.net35" Project in the solution and chose "Build"
Luckily ... it just built :)

Copied the WebStore.UI file from "\WebStore.UI\bin" folder in the source to the website.

This time setup ran fine :) But I got the following Error:
mojoSetup has detected that the database user does not have permission to alter the database schema. You need to correct this or provide a connection string with sufficient permission.

I deleted the "mojo.db.config" that came with the zip file.
ran the following after cd "Data\sqlitedb"
sqlite3.exe mojo.db.config

.read initdb.config
.exit

Now setup ran fine and everything works :)

Long live mojoPortal!

Enjoy!

Calling LoadLibraryEx on ISAPI filter "C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll" failed

After installing Visual Studio 2010 on my 64 bit windows 7 machine IIS failed open any webpages with the following error:

"Calling LoadLibraryEx on ISAPI filter "C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll" failed"

The following resolved it:

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
aspnet_regiis -r

Yes ... I forced asp.net to run 32bit. I also tried:

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
aspnet_regiis -r

and it too worked. But I have a reason to run in 32Bit because I use SQLite :)