Posts Tagged ‘C#’

On “why I suddenly became an iPhone developer”

Tuesday, July 6th, 2010

DevCon Philippines 2010

Jonjon, with an iPad he doesn't own :(

I've been getting a lot of questions, surprised looks, expressions of shock, and scratched heads when people find out that I've recently become an iPhone developer.

"Won't they take away your MVP for that?" was one question. The words traitor, betrayal and turncoat all came up one by one in different occassions. :P

The answer to the MVP question is no: around the world there are numerous MVPs working as Java, Ruby and iPhone devs in their day jobs, whether or not concurrent to their use of Microsoft platforms. The MVP award is all about community, and I won't be giving up on my community activities anytime soon.

However the answer to the "why" question will bring me back to 1998, when I decided to join the Filipino language newspaper in college. Back then I considered my command of the English language as excellent, both spoken and in print, and I was having some sort of writer's itch, so it might have made sense to join one of the two college papers. So thinking about which one to join, I asked myself; should I merely stay in my comfort zone or not? Eventually I decided that joining Ang Pahayagang Plaridel was an excellent opportunity to hone my writing skills in my native tongue -- something much more unusual in this country and in many ways more special -- and so I wrote for the paper and the rest is history.

Bilingualism has many known benefits, and it could usually be summarized as being able to think in more ways than one. With the paradigms and mindsets of two languages usually being very different, it allows the mind of a polyglot to have a much wider perspective and more points of view, and as my own experiences suggest this same phenomenon applies to programming languages. This is very much the same reason I'm now studying Objective-C and developing iPhone applications -- striving to be a polyglot programmer contributes to your own awesomeness.

As for .NET, I'm sure I'll be writing in C# again soon, especially now that I appreciate its form all the more. ;)

DevCon Philippines 2010 in Cebu

Monday, June 28th, 2010

I had an awesome time last week in Cebu, having presented a 5 minute lightning talk at the DevCon Philippines. There I talked on a similar topic to that I presented in the Visual Studio 2010 Community Launch, Dynamics and Runtime Object Composition with C# 4.0, which I also discussed in a previous blog entry.

Dynamics and Object Runtime Composition With C# 4.0

It was nice meeting (again) the vibrant and passionate Cebu developer community! Hope to see you again next year!

Some pics from the event:

DevCon Philippines 2010

Jon Limjap at DevCon 2010

DevCon Philippines 2010

Kevin Leversee delivering his awesome presentation on WIIFM and Mediocrity

DevCon Philippines 2010

DevCon 2010 audience

DevCon Philippines 2010

Hackathon participants submit their entries onstage

DevCon Philippines 2010

Enric Sen Canales cheers after winning the Sybase Hackathon

The complete set of pictures are in Flickr and Facebook.

Update Enric Sen Canales won the Sybase, not the IBM Hackathon. There were 2 hackathons held, sponsored by Sybase and IBM. Congratulations to the winners. :)

Of tool preferences and programming languages

Monday, April 26th, 2010

A few months back in my post Why I love C#, Mike left some really interesting comments about the preference of C# over VB and what he thinks matters when it comes to return-on-investment vis-a-vis programming language choice, to quote:

The author of this C# article fails to mention even a single thing (a real example, in a real business situation) where he did something better and quicker because he was using C#

...

And if it is true that C# programmers cost 10% more, then I as a person who has been hiring programmers for 15 years, certainly do not want to bring in C#. Instead I will put my money in VB.NET which is easier to read and programmers cost less – so I save my company money – and achieve exactly the same results – in less time.

And in a later comment:

More importantly, almost all programming is done for use in a business environment. Which means there needs to be ROI, and the best one possible.

...

Of course ROI does not apply if you are doing non-critical (to business) programming work, in which case the longer learning curve of C# does not matter – as it is all for fun; but for serious business applications, Lambda expressions, and the odd features really do not matter.

His opinion on the matter is interesting because first, it comes from the perspective of a business person who, in the "15 years of hiring developers", has found no need for the use of any language more complex than Basic. He has found C# or other non-english-like language so unnecessary to his applications that he is convinced they are a waste of resources in terms of return-on-investment.

AK-47

The AK-47 is probably the most popular assault rifle in the planet

I actually agree with him. The key of success in many products is often their simplicity in terms of construction, operating principles, and the ease by which you could find or manufacture spare parts (as an analog to software maintenance) for these products. Consider for example, the most pervasive assault weapon in the planet: the AK-47.

The reasons for the AK-47's success is simple:

Even after six decades, due to its durability, low production cost and ease of use, the model and its variants remain the most widely used and popular assault rifles in the world. It has been manufactured in many countries and has seen service with regular armed forces as well as irregular, revolutionary and terrorist organizations worldwide. The AK-47 was also used as a basis for the development of many other types of individual and crew-served firearms. More AK-type rifles have been produced than all other assault rifles combined. [Wikipedia article on AK-47]

Clearly, the AK-47's superior qualities should have made it the assault rifle of choice for every military unit in the world, but there are a wide variety of assault rifles and other such weapons used around the world, for a variety of purposes. While some riflemen will simply dislike it because of idealogical reasons (e.g., its Soviet origins or association with paramilitary and terrorist organizations), others may find a variety of practical reasons not to use it: whether it be dimensions, recoil, range, handling, etc.

The same will be true for Visual Basic or its variants. While it's perfect for many, many business applications, with the perception that developers can easily be trained for using it for a reasonable return on investment, there will be cases and applications beyond simple business logic that will render it cumbersome, and where C# may be the better choice of language for development.

Mike also accuses me of dismissing Visual Basic simply because I don't want to be considered a beginner:

It is very clear that he associates VB with his first language BASIC; and because he wants himself not be considered a beginner (but a very experienced programmed well capable of using all symbols in C#) he chooses C#. It is C after all and not a Beginner languange(sic)...

C# with its more cryptic looking code, certainly costs more to the business.

Crayons

How many commissioned paintings are made with crayons?

If I follow his logic, believing that "cryptic looking code" costs more to business, and using a "simpler language" is more beneficial to businesses, then tell me, why aren't there more paintings made with crayons than those made with oil pastels, acrylic, and other more complex media?

I have to make this clear: I don't think using Visual Basic is tantamount to using crayons. But if I like doing paintings more with acrylics than with oils, or with watercolor than with gouache, or with sable brushes than synthetic ones, or with lacquer-based rather than water-based paints, should it be taken against me?

If the person who commissions my work mandates me to use Visual Basic, then by all means I'll use it, but that doesn't mean my preference for working with C# will go away. It's a tooling preference, a matter of choice, and not the kind of elitism Mike implies in his comment.

Every craftsman will have his tool of choice, and they'll try to use it as much as the circumstances will allow.

DEVCON Luzon 2010

Friday, February 12th, 2010

I had an awesome time presenting and participating in last Tuesday's DEVCON Luzon! More than 200 software industry participants attended the event at SMX Convention Center near SM Mall of Asia.

I was lucky to have been able to present, as a 10 minute Lightining Talk,  a topic I loved a lot -- What's new in C# 4.0. And for the first time, my talk was live-streamed over the net and recorded using ustream.tv.

Thanks to Karl Arao for the photos below!

18673_309766118584_151052508584_3558919_4732446_n

18673_309766128584_151052508584_3558920_4325744_n

Later in the evening I was part of the judges for the Hackathon where PHP10,000 pesos was awarded to the winner Elmer Rivera, after a 30 minute programming challenge.

Hackathon participants congregating around an access point. Maybe for faster documentation browsing? :P

Participants look on during judging

Special thanks to the Philippines Software Industry Association (PSIA) Secretariat, especially Diane, for a great DEVCON Luzon.

Hope to see you in Cebu for DEVCON Philippines this June!

MSDN Session: VB vs. C#

Tuesday, December 1st, 2009

I had a lot of fun when Warren Yu and I presented a rare dual-session in the showdown between VB and C# developers - whilst showing them the newest language features in the upcoming versions of the languages Visual Basic 10 and C# 4.0. The heated discussion (aided by some San Miguel Beer) afterwards was the most passionate we've heard from members of the audience, and their lively participation only means that we're going to do this again!

Here are some of the pictures from the event:

The speakers squaring off...

The VB camp...

The C# camp...

 

Ladies of VB

JL Tolentino with his passionate defense of C#

Jad with his views on VB

 

We want to thank new Microsoft DPE Dale Jose for all that booze (and the idea for the event, actually :P )

I again thank all the awesome audience who came, spoke their mind and helped us make this event truly awesome! Thanks!

Why I love C#

Monday, October 26th, 2009

BASIC was my first love. Notice the all caps -- that was how it was written back in the 80s. I discovered BASIC via a GW-BASIC manual I had found in my grandfather's boarding house, where a former tenant left it after graduation. From that lost book I was introduced to programming, and I moved from GW to QBASIC then to Visual Basic 4, jumping to VB 6 and finally, VB.NET. Visual Basic was my first foray into .NET, and with my skills back then, it was really, really good.

Along the way I met a bunch of other languages, though. In highschool we were also taught a data-oriented language called Clipper, and a weird semicolon-laden language called Pascal. It was the first time I saw line-terminators in a programming language. In college I finally got to meet C. Quite different a beast from BASIC, I nonetheless got the hang of C very quickly. It was terse, requiring fewer keystrokes to write in (there was no Intellisense back then) and I immediately kept all the keywords I needed in my head. It was great, but I didn't get to use it at once when I started working.

In the early years of .NET I was ambivalent between the choice of languages. I learned both Visual Basic and C# and said to myself -- what's the big deal between the two? Nothing much. So I just studied and learned and switched from one language to another, until one day I got introduced to object-oriented programming. OOP was a difficult, disciplined programming concept -- much harder to internalize than structured programming was. But that's where I saw what C# was good at: it was naturally geared towards OOP. I compared writing applications in both languages, and noticed that if I was doing OOP, it would be much faster if I wrote it in C#.

I had one last foray using VB.NET on a full-blown object-oriented designed application, and it just convinced me further that C# was the way to go. What nailed it further for me was when .NET 2.0, and then .NET 3.5 arrived. It was much easier to use and write generics, I could use anonymous methods (which wasn't possible in VB early on), LINQ was without hassles of unsightly underscores, and lambda expressions were just much more intuitively beautiful in C#. Likewise, with the ability to introduce unmanaged code, developers could also introduce more advanced tweaks that are impossible to include with VB.

C# empowers a .NET developer to realize the full potential of the .NET framework, aside from the language. This power becomes even bigger with the introduction of the dynamic keyword in C# 4.0, giving it the best of both worlds between static-typed and dynamic-typed languages. It is this power that convinced me that C# is the way to go.

So, why do you love C#? Why don't you like/love it? I'd love to hear your thoughts too. :)

Combining generic predicates in C#

Friday, November 21st, 2008

I've got a requirement wherein I needed to have a way to make dynamic predicates, with the need to support for And and Or operations between two predicates. I was aware that there are ways to create Dynamic LINQ queries if I wanted to use LINQ to Objects (I was using these on generic lists anyway), but a voice at the back of my head told me there would be a much simpler solution.

I was astounded at how simple it turned out:

    public static class PredicateExtensions
    {
        public static Predicate<T> And<T>
            (this Predicate<T> original, Predicate<T> newPredicate)
        {
            return t => original(t) && newPredicate(t);
        }

        public static Predicate<T> Or<T>
            (this Predicate<T> original, Predicate<T> newPredicate)
        {
            return t => original(t) || newPredicate(t);
        }
    }

Of course the assumption here is that the logic operations are simple.

The following are the tests to show how it works. Needless to say, the lambda expressions can be replaced by any method following the Predicate delegate:

    [TestFixture]
    public class PredicateExtensionsTest
    {
        [Test]
        public void PredicateExtension_And_method_performs_an_and_between_orig_and_new_predicates()
        {
            int t1 = 1;

            Predicate<int> orig = t => t == 1;
            Predicate<int> newPredicate = t => (t + 1) == 2;
            Predicate<int> falsing = t => (t - 1) == -1;

            Predicate<int> origAndNew = orig.And(newPredicate);
            Predicate<int> origAndFalsing = orig.And(falsing);

            Assert.IsTrue(orig(t1));
            Assert.IsTrue(origAndNew(t1));
            Assert.IsFalse(origAndFalsing(t1));
        }

        [Test]
        public void PredicateExtension_Or_method_performs_an_or_between_orig_and_new_predicates()
        {
            int t1 = 1;

            Predicate<int> orig = t => t == 1;
            Predicate<int> newPredicate = t => (t + 1) == 2;
            Predicate<int> falsing = t => (t - 1) == -1;

            Predicate<int> origOrNew = orig.Or(newPredicate);
            Predicate<int> origOrFalsing = orig.Or(falsing);

            Assert.IsTrue(orig(t1));
            Assert.IsTrue(origOrNew(t1));
            Assert.IsTrue(origOrFalsing(t1));
        }
    }

PHINUG November Tech Sharing: Taste testing C# 3.0′s New Language Features Source Code

Friday, November 30th, 2007

Last Wednesday I presented the topic for the Philippine .NET Users Group Tech Sharing for November, it was entitled "Taste Testing Visual Studio 2008: C# 3.0's New Language Features".

Using Visual C# 2008 Express Edition I demoed the use of the following language features:

  • Automatic properties
  • Implicitly-typed variables
  • Anonymous types
  • Object initializers
  • Collection initializers
  • Relaxed delegates
  • Extension Methods
  • LINQ
  • Lambda Expressions

All using the tuna sandwich ingredients I posted earlier.

You can download the source code for the PHINUG November Tech Sharing: Taste testing C# 3.0’s New Language Features by clicking on the link.

UPDATE: Patrick blogged about the PHINUG November Tech Sharing at the PHINUG blog. :)

PHINUG November Tech Sharing and Visual Studio 2008 Release

Tuesday, November 20th, 2007

Coinciding with the touchdown of .NET 3.5 and Visual Studio 2008, the Philippine .NET User's Group will be conducting its November Tech Sharing on Wednesday, 28 November 2007 at the Microsoft Philippines offices, 16th floor, 6750 Ayala Ave., Makati City.

The topic to be discussed is entitled Taste Testing Visual Studio 2008: C# 3.0's New Language Features to be conducted by yours truly. There might also be a similar presentation on Visual Basic 9's implementation of these language features.

You may register for the November Tech Sharing event by clicking here.

You might also want to download the Visual Studio 2008 Express Editions, which are available absolutely for free.

Hope to see you there!

Making a tuna sandwich out of C# 3.0

Wednesday, October 31st, 2007

A few weeks back I've been experimenting on a recipe of tuna sandwich that has mustard instead of mayonnaise, at around the same time I volunteered for a PHINUG November Tech Sharing to show off C# 3.0's newest language features using Visual Studio 2008 Express Beta 2.

Mixing it up one morning the idea hit me, why not make a small program that accepts recipe ingredients as inputs?

First part of the task is to think of a way to abstract a list like this:

  • 1 can Tuna chunks in water
  • 6 slices whole wheat bread
  • 2 tbsp mustard
  • 1/2 piece red or green bell pepper, sliced to strips
  • 1/2 cup celery, chopped
  • 1/4 cup green onion, minced
  • 1/2piece green onion, sliced into rings
  • 2 tbsp capers
  • 2 pieces medium tomatoes, sliced
  • lettuce leaves
  • black pepper, freshly ground

Nothing fancy here, but it'd be a great way to demonstrate the new language features.