Author: C.J. Collier

  • Writing Free Software – Part 2: Makefiles

    Okay, so now we know how to write hello world in C#, compile it and run it. Next, let’s try to automate the build portion a bit. It’s not going to be very much of an improvement to start out with; we’re just replacing the gmcs command with a make command. But it’s laying a framework, so let’s ignore that for the time being.

    Get back to the workspace

    $ cd ~/src/greeting

    Create a simple Makefile

    $ cat > Makefile
    # the first target is the one executed when no target is named
    all: Greeting.exe
    #don't do anything
    
    # running 'make clean' will execute this target
    clean:
    	rm Greeting.exe
    
    # running 'make Greeting.exe' will execute this target
    Greeting.exe: Greeting.cs
    # the same as gmcs -out:Greeting.exe Greeting.cs
    	gmcs -out:$@ $^
    

    Test the Makefile

    $ make
    gmcs -out:Greeting.exe Greeting.cs
    $ make clean
    rm Greeting.exe
    $ make Greeting.exe
    gmcs -out:Greeting.exe Greeting.cs
    $ ./Greeting.exe 
    Greetings, World!
    

    Conclusion

    So, there’s a quick overview of writing a Makefile. If you want to learn all of the nitty-gritty details, I recommend reading the manual over at gnu.org.

    We’ll use these short lessons as building blocks for larger tasks, like creating a distribution using automake and autoconf. Baby steps first :)

  • Writing Free Software – Part 1

    There are a lot of folks who want to learn how to write software, I hear. So I’ll see if I can write something up about it.

    I’m going to assume that the reader has at their disposal an i386-class computer running Ubuntu or Debian. This will all probably work for other operating systems, but it’s what I’ve got, and I’m not going to bend over backwards. :) I’m also going to write it in C#. Get over it. If something doesn’t work for you, if I miss a prerequisite or whatever, you can send me an email and I’ll fix the post.

    Install the C# compiler

    $ sudo apt-get install mono-gmcs

    pretty easy, eh?

    create a workspace

    $ mkdir -p ~/src/greeting

    Also pretty easy.

    Write a simple app

    $ cd ~/src/greeting
    $ cat > Greeting.cs
    // This brings in Console.Writeline, used below
    using System;
    
    class Greeting {
      // This is the program entry point
      public static int Main( string [] argc ){
    
        // A simple operation to confirm that our app is running:
        Console.WriteLine("Greetings, World!"); 
    
        // Well-behaved software returns an int from Main
        return 0;
      }
    }
    ^D
    

    Compile the app

    $ gmcs Greeting.cs

    Run the app


    $ ./Greeting.exe
    Greetings, World!

    Summary

    Okay, so that’s not all that impressive, I know. I’m starting small. I intend to teach folks how to write an autotools package, including support for producing and consuming pkg-config bits (app-name.pc files), internationalization, etc. It’ll be fun, really. Just give me a little while to get it finished. :)

  • autotools help on IRC

    It has come to my attention that there is a lack of autotools (autoconf, automake, autoheader, libtool, etc) help on IRC. If anybody is looking, they might check out #mono on irc.gimp.net; there are quite a few folks there who are familiar with the suite, and if I can ever figure out how to get back on during the day, I’d be happy to help folks out as time permits.

  • To Prebuild or not to Prebuild?

    So… On IRC today, John, Michael and I discussed rolling Prebuild and xbuild into one product. It seems that we’re duplicating effort and competing for each others’ users. It sounds to me like we should converge the codebases, and make Prebuild.exe a wrapper around the innards of xbuild.

    Thoughts?

  • Taking a job at MS

    So… next week, I start a contract with Microsoft in Redmond. I’ll be working on what seems like a fun project. I’ve enjoyed working at CarDomain for the last four months. Fun projects, a cohesive group, neat technology. I’m mostly moving on because a) I’ve been writing web pages for a long time and want to try something else and b) the commute will be much easier and I’ll get to drive in with Hannah!

    I’m looking forward to being able to play with some of the fancy internal toys that I’ve heard so much about. Someone told me yesterday that even the folks who were hardcore MS haters love their job there. I’m certainly not a hater. Perhaps skeptical, but not a hater. I figure I’ll learn a bunch of fun new things even in the worst case scenario.

    Anyway. Now that the various colliertech.org bits are functioning again, I thought I’d write something.

  • The Cretins

    My brother’s motorcycle club, The Cretins, recently had an article published about them in the Seattle PI. They even quoted him. I didn’t realize he was the president of the club. The rumor goes that he missed a meeting, and wasn’t there to defend himself.

  • An update

    I don’t really have anything really exciting to report, so y’all get to listen to me blather. And after all, that’s what blogs are for anyway, right?

    Zelda is turning 11 months old this month. This is still my favorite picture:
    PA111421.JPG

    I have been dishonorably discharged from Amazon. It seems that I am incompetent. It might have had something to do with slipping a note under the CEO’s door, though. But I have no proof of that, so let’s assume it was an un-related event. Being a nutjob doesn’t necessarily get one booted from employment. I think I can prove that.

    My friends were very supportive during my short stint of unemployment:

    
    18:32 <@drgone> how's being fired?
    18:32 < cj_> drgone: I made money by being fired.  isn't that great?
    18:32 <@drgone> rock on
    18:32 <@drgone> gotta love hush money
    20:13 <@btm> cj: where you working now?
    20:56 < cj_> btm: cardomain.com
    

    I went to lunch with a couple of friends from #mono today. That references earns me the right to spam the monologue folks (hi everyone!). benjoldersma, his friend [Ian] and I went to an Indian place in Fremont. I was hoping that RevFry would come, too, but he is lame.

    We talked about the Seattle Mono Users’ Group (all four of us), Prebuild, the DLR, my hopes of getting a gig at Microsoft to implement Perl6 on the DLR, IKVM, GTK#, gtk+, XAML, WPF, Moonlight, Ubuntu, and other stuff, I’m sure.

    I’m working at cardomain.com on contract. It’s fun. The people there seem smart and interested in what they’re doing. Their development infrastructure makes me happy. The fact that their devs do automated testing also makes me happy. The fact that I have LoS to the Westin makes me happy. The parking situation rains on my parade.

    Speaking of the Westin, I let down my friends with whom I co-locate. I was unable to run to the rack when one of the servers needed love and attention. It cost the other folks quite a bit of revenue. Allow me to apologize publicly. I’m sorry folks. I’m doing what I can to reduce the risk of this happening again. I hope I can make it up to you.

    Hannah got a job at Microsoft working on the Surface team.

    And with that, I will select some categories… thanks for tuning in :)

  • does anyone else feel forced to produce crap?

    Management wants MORE RESULTS NOW NO MATTER WHAT THE COST!!!!!

    I feel like the world is telling me to give them more crap, less useful code!

    Does anyone else feel like business requirements are forcing them to produce lots of fluff rather than small amounts of quality content? Should I be concerned? Should I care that the business is focusing on high output in the short term in exchange for low output in the long term?

    I’ve been told to quit trying to fix problems and to focus on what my manager wants, whether or not it means breaking the system for investors. This seems like a self-serving way to look at the world. If I were concerned with my family’s status in the world over the stockholders, I would totally go for it.

    But my conscience is getting in the way. Could someone recommend a way for me to slay my concern for humanity so that I can think like management and care less about the welfare of the world?

    KTHXBI

  • IKVM basics

    So, I’m not much of a java guy, but I need to know how to get at the CLI, given a java interface.

    Let’s assume for brevity that one has an ubuntu machine available:

    $ sudo apt-get install ikvm ikvm-native icepick icepick-gcj
    ....
    $ mkdir hello-ikvm && cd hello-ikvm
    $ cat > hello.java
    class hello
    {
      public static void main(String args[])
      {
        System.out.println("Hello, world!");
      }
    }
    ^D
    $ icepick-javac hello.java
    $ ls
    hello.class  hello.java
    $ jar cvf hello.jar hello.class
    $ ls
    hello.class  hello.jar  hello.java
    $ ikvm hello
    Hello, world!
    

    Okay, now we can run java bytecode on the IKVM virtual machine. yay. So what? On to the interesting bits.

    $ ikvmstub mscorlib
    ...
    $ ls
    hello.class  hello.jar  hello.java  mscorlib.jar
    $ cat > helloCLI.java
    import cli.System.Console;
    
    class helloCLI
    {
        public static void main(java.lang.String args[])
        {
            Console.WriteLine("Hello, world!");
        }
    }
    ^D
    $ ls
    hello.class  hello.jar  hello.java  helloCLI.java  mscorlib.jar
    $ icepick-javac -classpath mscorlib.jar helloCLI.java
    $ ls
    hello.class  hello.jar  hello.java  helloCLI.class  helloCLI.java  mscorlib.jar
    $ ikvmc -reference:mscorlib helloCLI.class 
    $ ls
    hello.class  hello.java      helloCLI.exe   mscorlib.jar
    hello.jar    helloCLI.class  helloCLI.java
    $ mono helloCLI.exe
    Hello, world!
    

    The end. I need to pick up Scarlet now.

  • Perl 6 on the CLI via DLR; A summary

    My goal in attending this year’s Lang.NET Symposium was to determine whether the Common Language Infrastructure (CLI) is a viable platform on which the Perl 6 language can be implemented.  During the talks, I took notes in my blog (Monday, Tuesday, Wednesday) and on my wiki (Monday, Tuesday, Wednesday).

    Since I’ve not historically been much of a compiler guy, and since I don’t know what type of human power is available to perform such an implementation, I can’t say with any level of assurance whether or not targeting the CLI is feasible by the Perl 6 community. However, based on my limited understanding, it seems like it can be done. There has been a lot of work done by the IronPython and IronRuby teams to make implementing so-called "dynamic" languages (interpreted languages, languages with an eval() mechanism) as painless as possible. Based on conversations with Jim Hugunin, the primary developer of IronPython and one of the core developers of the DLR, I believe that the Perl 6 language would be welcomed with open arms by the CLI and DLR development communities, if interest exists in leveraging these technologies.

    Microsoft has published the source to both IronPython and IronRuby, along with the Dynamic Language Runtime (DLR) libraries under the OSI-approved, bsd-style "Ms-PL" license.  The DLR contains implementations of many features common between dynamic languages, and could be leveraged to implementat a Perl 6 runtime on top of the Common Language Infrastructure.

    The open issues remaining involve some questions which had been brought up by Larry Wall prior to the conference:

    [One] interesting question is how hard it’ll be to at least emulate continuations for purposes of pattern matching and logic programming; and whether that forces Perl 6 to keep its own runloop.

    Another interesting question is the extent to which we can make their exception model fail-soft in a way that works well [with] parallel programming.  you don’t want to be unwinding the whole stack merely because one element out of your million element hyperoperation turned out to be undefined….  unwinding the stack should be the last resort, and then only when you already know where you’re unwinding it to.

    Another question is on porting to the CLI is whether it can support STM efficiently.

    Based on my limited understanding of the subject, it seems that continuations, fail-soft exceptions and STM would need to be implemented as extensions to the CLI by way of the DLR.

    According to Larry, “Perl 6 tries to dance right on the edge of requiring continuations without actually doing so, which opens up many opportunities for doing something more efficient than continuations most of the time.” This seems as if it will mesh better with the current DLR users’ world. When speaking with Jim Hugunin, it sounded as if he would prefer to avoid including support for continuations in the DLR. He mentioned that the Ruby spec has removed continuations, which leaves Perl 6 as the only modern language with the feature.

    The way I see it, these features can be implemented in a slow-but-existing manner initially. As common use cases emerge, the system can be optimized. I once visited my friend Eric‘s office when he was on the microsoft.com team. On his wall, there was poster with a message similar to this:

    1. Make it work
    2. Make it work right
    3. Make it work fast

    I’ve found that if developers get bogged down in the details of the later steps before the earlier steps are complete, productivity takes a real hit, and sometimes stops completely. The other implementations of Perl 6 seem to understand this, and are not waylayed (much) by the fact that their systems are on the dog side of slow.