Thursday, April 23, 2009

IE still sucks...

I was given a small internal web project to work on last week. The best part about it was that I was given free reign on it's design and technologies used. I was pretty excited since I could finally use all of the new HTML/CSS/ECMAScript standards (existing and proposed). This was mainly nice since I didn't have to do stupid hacks and things for all of the different flavors of IE.

I didn't 'have' to support IE for this project but decided that I'd finish the project and then see how the new IE8 faired.

Well... I was, not surprisingly, let down again by IE. Here are a few things I noticed right off the bat.

1) No canvas support :( STILL!!! Firefox, Safari, Chrome and Opera support this. I guess MS is not being pro-active about supporting new standards as the canvas tag is part of the HTML5 spec. There is however this project ExplorerCanvas which does some nice javascript conversions to VML for IE so that you can use most of the features of the canvas tag.

2) Proposed ECMAScript Harmony features have been left out. This is funny since MS was one of the big proponents of limiting the proposed features of ES4 and yet they still can't get the limited functionality implemented (of which Firefox and Safari already support). For instance the new getters/setters and 'foreach' function of arrays makes IE8 confused (these are just a couple I noticed).

I wasn't too surprised by this lack of new features. But I was surprised to see some CSS3 selectors working, and that the site rendered very close to how Firefox and Safari/Chrome did (but not exactly, as there where still some things that where off). So I guess I'm happy that IE has made a huge jump since IE7, but it's still not there which sucks since IE6 is still one of the most dominant browsers used so I guess we can all look forward to missing things in IE8 for the foreseeable future. Ugghh..

Wednesday, May 14, 2008

missing ( before formal parameters


I ran across this little error the other day when I ran some javascript that was working fine in IE but Firefox just didn't like.
It was pretty easy, but vague, to track down what Firefox was complaining about and it was just another difference between JScript and Javascript ugh.
Here's a little example of what was causing this issue.

<script type="text/javascript">
// just create some dummy variables for namespaces
var some = {};
some.namespace = {};

(function($) {
function $.testFunc() { /*some code here*/ }
})(some.namespace);
</script>

The problem is when creating the testFunc function. JScript allows the '.' in the declaration and Javascript does not. Here is a quick and simple fix for this that will work in both IE and Firefox (and Safari).

<script type="text/javascript">
// just create some dummy variables for namespaces
var some = {};
some.namespace = {};

(function($) {
$.testFunc = function() { /*some code here*/ }
})(some.namespace);
</script>

Thursday, February 28, 2008

Some Fun Generating 'the power of' With F#

So for my first bit of fun with F# I figured it'd be fun to play with the BigNum (used for crazy big numbers) I figured I write up some quick functions that simple generate the power of some number, resulting in some crazy big numbers :)

(*all of my examples include '#light')

My first function doesn't use the BigNum but it's very simplistic.

let rec pwrof x y =
     if y = 1 then
         x
     else
         x * pwrof x (y - 1)

So for everyone new to F# 'pwrof' is a recursive function that takes 2 ints. 'rec' lets the compiler know that the function is recursive and the 2 parameters get resolved down to being ints at compile time. This came pretty naturally for me coming from a C# world, so lets try to mix it up a bit.

let rec pwrof x y =
     match y with
     | 1 -> x
     | _ -> x * pwrof x (y - 1)

This function does the exact same thing, but instead of using a familiar if/else statement we're using pattern matching (these are widely used in F#). It's like a switch statement. If y matches 1 then we return x, otherwise if y matches anything else, '_', then we recurse.

These were kinda fun, but I wanted to calculate crazy big power of calculations like 5000^5000. So here's an example that resembles my first function

let bpwrof x y =
    let x = Microsoft.FSharp.Math.BigNum.of_int x
    let pwr = x
    let rec pwrof x y =
        if y = 1 then
            x
        else
            pwrof (x * pwr) (y - 1)
    pwrof x y

And here's an example that resembles my second function

let bpwrof x y =
    let x = Microsoft.FSharp.Math.BigNum.of_int x
    let pwr = x
    let rec pwrof x y =
        match y with
        | 1 -> x
        | _ -> pwrof (x * pwr) (y - 1)
    pwrof x y

These are tail recursive so you can create some really, REALLY big numbers. If you call one of the last 2 functions you can calculate say 5000 to the 9000th power. It ends up taking a lot more time to print the result to the screen than it does to do the calculation(its pages and pages of number madness). I even tried 5000 to the 90,000th pwr, that's a big number.

 

Oh well, that's all for now...

Sunday, February 17, 2008

F# again

I had blogged about F# a while back and though I had tinkered around with it a bit, I got a little busy, and a little lazy. I've decided I'm gonna stick with it this time and learn it :) which means more upcoming blogs about F# (I haven't blogged in a while either so this will get me motivated)

I'm not one that enjoys scouring the web for information on things so I usually just go buy a book on whatever it is that I'm interested in. I decided the other day to head down to the local Borders and there was one copy left of Robert Pickering's F# book, titled 'Foundations of F#'. I'm currently only a few chapters in but it seems like a pretty good book thus far. It hasn't required a background in functional programming which is good and also seems to be a good read for the novice to expert programmers.

Well that's all for now, maybe next time I'll have some F# knowledge to share :)

Monday, November 19, 2007

14% done VS-2008

Eber told me today that the VS2008 was on MSDN.. I was pretty excited so we both logged into MSDN (which was amazingly slow today :)..
But we couldn't find it listed in the DevTools section..

We ended up finding it on the main page of MSDN(before you log in).

It's under the 'Top Downloads' section..

Sunday, October 28, 2007

Leopard

Leopard came out the other day and I started to loose anticipation for the release when it seemed more and more features were being dropped, or were just not being added as features. I was expecting that with the new Boot Camp there would better NTFS support, but the sales pitch from Apple on this is “Leopard understands the Windows FAT32 disk format”. I guess I could use NTFS-3G’s driver for this, but I guess I’ve been spoiled for too long and wanted it built right in :).

A feature that was actually on Apple’s web-site but then mysteriously disappeared was “Fast Switching” for Boot Camp. This would basically put one OS into hibernation and load up the other OS (Awesome if you don’t want to close all your programs down before switching).

BUT! There are a lot of things that I really like about the new OS. Probably one of my favorite things is the path bar in Finder (bread crumb like trail of where you are in the file system). This is one thing that always drove me nuts, when you had a file up and you had to do info or something on it to know where it was in the FS.

Spaces is probably one of my other favorite things. If you have a laptop and need a lot of stuff on the screen it’s nice to be able to place things in different spaces. I wasn’t too excited about this until after I loaded up Parallels and I could go full screen on one space and easily go back to a screen with all my Mac stuff. Parallels has Coherence but with all the Windows stuff I sometimes have loaded it’s easy for my screen to get cluttered.

I’ve never used iChat, simply because most of my contacts are using MSN. Well iChat still doesn’t support MSN BUT it does support Jabber now (as well as Google Talk, since it’s a Jabber too). So all I had to do was find a Jabber server that had MSN/AOL/Yahoo etc transports. The only bad thing was that I had to use Psi to create an account on the Jabber server I found to create my Jabber account. Once my Jabber account was created I could point iChat to it and I can now talk to all my MSN/Yahoo..... contacts. The other downside is that if you have Google Talk and a Jabber account (or more than one account of anything iChat supports) then each account gets loaded in it’s own window, instead of consolidating all your contacts into just one window. I’m still up in the air about iChat, I may still go back to using Adium since it pretty much supports anything you’d ever use, and they have announced that they are going to support video chats in the near future.

So far for the most part I like Time Machine. I don’t like the dock if it’s on the bottom (don’t like the reflective thing the icons sit on) good thing I always place it on the left (no reflectiveness if the dock is on the sides of the screen) I guess you can turn it off, I found a quick little shell command to do it but didn’t bookmark the site where I found it :). I don’t care for the little cross-walk in the dock (used for changing the dock size). Oh I forgot, I love the new Quick View feature too, much quicker to quickly grab something from a dock instead of loading up whatever to view it. Other than that I’m happy with it, they didn’t make major changes to where everything is so I didn’t feel lost like I did with Vista.

Whoa whoa! just as I finished writing this I think I just found my biggest complaint! I use Pages to do my blogging, I export it as HTML and use a Ruby script to make it Blogspot happy and get rid of the extra CSS it generates. Well just as I finished I went to export it as HTML and well.... that feature is GONE! (Right after I installed Leopard there was a Pages update so I figure that removed it). I’m not quite sure why they removed that :(.

Saturday, September 01, 2007

I love c#.. but lately.. whoa!

So lately I’ve been wanting to get into some programming on my Mac (yes I own a mac and develop .NET at work). Well I don’t really have a lot of time to devote to some new language like Objective-C. Yes I could use Java.... but I’ve really started to like c# a lot better than Java lately (maybe because it’s just what I’m used to, and I want to avoid people bashing me for taking sides :) ).
 
Anyways I’ve kept tabs on the Mono project every now and again and recently decided I’d give it a go. So I downloaded the latest (right now it’s 1.2.5) and started to tinker. I did the cheesy ‘Hello World’ console stuff just to start out. Well I’d really like to develop ‘real’ things, ‘useful’ things, but I was a little concerned about the GUI aspect (WinForms). I’d read a few places saying you need to install GTK and blah blah to get it working and that kinda turned me off of the whole thing.
 
Well I think I had been reading some slightly out-dated material. I wrote a little program to just pop-up a MessageBox and what do you know.. it worked!... and it worked on my Mac! (well you do have to run X11 first, but hey it’s a small price to pay)..
 
Then I wanted to see what new stuff was added to Mono. So I implemented a quick Lambda just for fun. Well it didn’t work right off the bat but after a couple Google searches I found the answer.
 
To use Lambdas, and some of the other c# 3.0 features, you need to use the ‘gmcs’ not the ‘mcs’ mono compiler command. (I remember reading that gmcs was newer and they plan on getting rid of mcs I think with v 2.0... don’t quote me though that’s from my wonderfully not so good memory). AND you need to provide this argument to compiler ‘-langversion:linq’. And that’s it!
 
So here’s my little program I did..
 
using System;
using System.Windows.Forms;
 
namespace Test {
   delegate string GetMessageDelegate(string name);
      public class Test {
         public static void Main(string[] args) {
            Console.WriteLine(“Hello from the console”);
            GetMessageDelegate getMsg = name => string.Format(“Hello {0}”, name);
            MessageBox.Show(getMsg(“Frank”));
      }
   }
}
 
And here’s what I did to compile and run.
 
gmcs -langversion:linq -r:System.Windows.Forms Test.cs
 
 
So basically you’ll get the message on the console and a message box that displays “Hello Frank”;
 
So I’m pretty sure I’m gonna stick with Mono/c# as my choice for development on my Mac :)