Metacircular thoughts

September 4, 2008

Enjoy the power of Linux from the safety of Windows with VMWare

Filed under: Lunix, Prolog, The Dark Side, Virtualization — metacircular @ 11:10 pm

I’ve been a fan of Linux for a very long time. I’ve sworn off Windows at least a dozen times — but each time I came crawling back, because there was always something I couldn’t figure out how to configure or get to work: in the past it was usually printing, video, audio, or multimedia-related.

With the rise of Ubuntu, most of those things just work by default. But still, having to give up Windows gaming, Photoshop, and other proprietary crap I can’t kick the habit of will always force me to keep Windows installed. I think this is the best of both worlds: I have Ubuntu running under VMWare Workstation running on one monitor (at 1680×1050, too, thanks to VMWare Tools) and Windows on the other. I can, for instance, do web development on the Linux screen and test it on Safari, Google Chrome, Firefox and Internet Explorer in Windows.

In the screenshot above you can see me drafting this post in Windows on Chrome while listening to crappy dance music in iTunes and, meanwhile, tinkering with Emacs, git and Prolog under Linux. Good times.

This way, I can make use of both monitors without having to figure out Xinerama or tinkering with stupid drivers in order to make use of my video card in Linux. It takes away a lot of the hassle and if you’ve been wanting to try an alternative operating system but haven’t been able to move out, this is a good compromise.

October 20, 2007

Generics in VB 2005

Filed under: The Dark Side — metacircular @ 5:19 pm

So, generics in .NET 2.0 let you make functions and classes generic over types.

They also let you maintain type safety by constraining the type, e.g. making it implements a certain interface.

For example, you could define a general function to find the minimum element in a list. In VB, the data structure of interest is System.Collections.Generic.List(Of T). Now, we have to be able to compare on these objects, and the .NET interface for this is IComparable. So, we can define the function as follows:


Imports System.Collections.Generic

Public Function FindMin(Of T As IComparable(Of T))(ByVal data As List(Of T)) As T
   Dim minval As T = data(0)

    For Each value As T In data
        If value.CompareTo(minval) < 0 Then
            minval = value
        End If
    Next

   Return minval
End Function

The As IComparable(Of T) bit constraints T to implement IComparable. Visual Studio complains with highlighted source code until we add this constraint about the call to CompareTo; it statically determines the type safety of what we've produced with respect to constraints and interfaces and tells us promptly, which is nice.

Then you can test this out as follows:


Dim numdata As New List(Of Integer)
numdata.Add(1) : numdata.Add(3) : numdata.Add(-5) : numdata.Add(4)
Console.WriteLine(FindMin(numdata))

Dim stringdata As New List(Of String)
stringdata.Add("first") : stringdata.Add("second") : stringdata.Add("last")
Console.WriteLine(FindMin(stringdata))

This outputs -5 and "first", respectively, as you'd expect.

Pretty straightforward, really.

Whoda thought a BASIC dialect could be a respectable albeit underwhelming programming language?

October 16, 2007

Notes on learning the .NET framework

Filed under: Language pissing matches, Life, The Dark Side — metacircular @ 11:23 pm

What’s good, peoples? It’s been a while since I rapped at ya.

Because of my job, I’ve been learning VB.NET and the .NET framework.

I have yet to find anything really retarded. These are some notes mainly for my own purposes.

  • And and Or still don’t shortcircuit. You have to use AndAlso and OrElse. Lame!
  • Boxing and unboxing (converting between a primitive type and an object) can definitely affect performance if called many times. This isn’t surprising, but it bears remembering and repeating. Consider the following code snippet:
    
    Option Strict On
    
    Module BoxingTest
        Public Sub NoBoxing(ByVal i As Integer)
            If i = 5 Then
                Console.WriteLine("omg!")
            End If
        End Sub
    
        Public Sub DoBoxing(ByVal i As Object)
            If CType(i, Integer) = 5 Then
                Console.WriteLine("omg!")
            End If
        End Sub
    
        Sub Main()
            Dim n As Integer = 300000000
            Console.WriteLine(Now)
            For i As Integer = 1 To n
                NoBoxing(i)
            Next
            Console.WriteLine(Now)
    
            Console.WriteLine(Now)
            For i As Integer = 1 To n
                DoBoxing(i)
            Next
            Console.WriteLine(Now)
        End Sub
    End Module
    

    On my machine, the boxing function takes about 10x longer than the one that's directly with value types. Something to keep in mind if you're working on a performance-sensitive application with tight inner loops.

  • Generics and the other collections are nice. Generics seem to be really fast, faster than normal collections?
  • The specialty collections, such as BitArray are efficient and nice (I can twiddle 10 million bits in under a second on a 2.8 Ghz machine).
  • Visual Basic 2005 is C# in clown shoes.

July 9, 2007

How to ace a tech interview

Filed under: Politics, Pop culture, The Dark Side — metacircular @ 6:32 pm

In this article, I’m going to help you whiz through those dastardly technical interview questions. Ever wonder why manholes are round? Read on.

Let’s start with an easy one. This one is called “The Rope Bridge“.

Four people need to cross a rickety rope bridge to get back to their camp at night. Unfortunately, they only have one flashlight and it only has enough light left for seventeen minutes. The bridge is too dangerous to cross without a flashlight, and it’s only strong enough to support two people at any given time.

Each of the campers walks at a different speed. One can cross the bridge in 1 minute, another in 2 minutes, the third in 5 minutes, and the slow poke takes 10 minutes to cross. How do the campers make it across in 17 minutes?

Solution: Who gives a shit? Who asks retarded questions like this?

This one is called “Wanna Play?” (hint: No!):

i offer to play a card game with you using a normal deck of 52 cards. the rules of the game are some fucking arbitrary bullshit that make this bullshit mental masturbation way harder than it needs to be. if you can’t figure it out in 45 seconds, i’ll assume you can’t produce code and work on a team, regardless of any free software projects you may have participated in (in fact i couldn’t look at open source code you’ve written if i wanted to, i’d get fired), regardless of any nice code samples you have to show me, regardless of how quickly you can pick up new things, and so on.

Solution: Are you getting the point? Jesus christ, no fucking wonder companies who use these kind of questions can’t ship anything.

June 26, 2007

Someone please make the bubble die

Filed under: Life, Politics, RIAs, The Dark Side, Web development — metacircular @ 11:38 pm

OK, we’re now deep in 1998-1999 territory with respect to Web 2.0 bullshit. Like the real estate crash, if you don’t see what’s going to happen in about 8-24 months coming a mile away you’re living under a rock.

Look at what’s on the top blogs, mang. Remember all those experimental psychology papers you’ve seen which make a pretty convincing, fairly scientific argument that people aren’t effective at multitasking? Disregard that and embrace meaningless phrases like connected mode: do stupid shit faster! That’s right. All the old facts (who has time for facts anymore?) are irrelevant. It’s different this time. Smug dipshits who can’t produce code wearing ironic t-shirts gather at parties and rub each other’s balls in a circlejerk of self-congratulatory praise. We are so awesome. We’re wiseguys. Everyone outside our incestual Valley echo chamber is a sucker.

Somehow, human nature has changed in the last three years: cool office + caffeine + slave labor = startup success! Or, alternatively: MacBook Pro + Rails + Ajax todo-list app = startup success!

Another forgettable blog proclaims non-chalantly: “…as businesses … get more productive to remain competitive…” The same message is everywhere: no one (an absolute) has time to do anything: (another absolute) read books (except masturbatory productivity ones), write coherent essays, or learn new things that don’t involve Javascript. The same people using motherfucking PHP talk about increasing productivity without a hint of irony in their high-pitched voices! Unfuckingbelievable!

OK, so proprietary vendor Z wants to lock users in to new platform C, which garners significant mindshare from developers busy locking people in to platforms A and B from proprietary vendors X and Y, and I’m supposed to be impressed? Ignore the fact that you can’t link to a single fucking thing in this RIA widget shit Z is pushing, and you can’t increase the size of the text, or use Firefox extensions on it, or do most of the things a web browser is currently useful for. Nevertheless: game-changing!

TechCrunch is a sea of forgettable names: PopSugar, Meebo, Cellfish, Jobster, Topix, Kiptronic, PicLens, Pixoh, Snipshot, Cumshot, Gazeebo, Dildo, whatever. That sinking feeling in your stomach and glaze in your eyes as you read those names is the knowledge that this has all happened before (and that it doesn’t have to be like this). Yes, it’s not as insane as it was during the first bubble. But there are still millions of dollars going after companies that can’t possibly actually have, you know, customers, revenue, the stuff that actually sustains business. This Valley-blog-startup-TechCrunch-iPhone-Digg bullshit is not indefinitely sustainable. Like Sarah Connor stuck in her Armageddon nightmare, you can pound against the fence and scream all you want, but the mushroom cloud is coming, man.

Look, you little Bay Area-dwelling, public transportation-using, podcatching, bespectacled too-cool-for-cool circlejerk pricks: calm the fuck down. Chill the fuck out and read a computer science textbook. Learn a functional/concurrent/logic programming language. Read Steve Yegge. Face the fact that your startup, rather than being “game-changing,” is boring and banal, just like most businesses; what matters is whether revenue - expenses > 0 or not. Learn how code generation in a modern compiler works. Make a toy operating system. Learn how the CLR in .NET works by reading books, documentation, and examining IL bytecode. Tinker with OpenBSD and write a solid technical article about what Mac OS X/Linux users could learn from it (crypto? firewalls? there has to be something). Do something real for once, for fucks’ sake! Do something a bright teenager could grasp the outcome of but when asked how he’d do it would scratch his head and say, “uh… hm.” REAL! And I’m not talking about robotic toys that don’t do anything interesting from a science/engineering perspective! And no data center/sysadmin shit that only applies to web hosting companies who are hosting 50 terabytes of data, nor something a smart 15 year old kid could do in a weekend in between Bangbus marathons. You’re driving me nuts. Less TechCrunch, more Fog Creek. OK?

(Am I just jealous I’m not on the gravy train? Uh, obviously.)

May 14, 2007

What do you get in a commercial Common Lisp implementation?

Filed under: Lisp, Politics, Prolog, The Dark Side, Web development — metacircular @ 8:44 pm

Commercial Common Lisp implementations like LispWorks and Allegro Common Lisp cost thousands of dollars. What do you get in them which isn’t included in SBCL or something, which costs $0?

  • ACL has AllegroCache, a true object database which has ACID transactions and scales to billions of objects. It is used transparently and integrates seamlessly with CLOS, Common Lisp’s ridiculously powerful object system. Depending on the project, this alone could be worth thousands of dollars.
  • LW and ACL have fast embedded Prolog compilers which seamlessly integrates with everything else in the distribution, including AllegroCache. LW actually gives you a full-blown expert system IDE (which is LW’s distinguishing feature as it doesn’t have an object database). In the ’80s, the kind of expert system functionality LW provides costed thousands of 1980s dollars.
  • Good cross-platform support so that you don’t run into the kind of problems the reddits had when working between Mac OS X and FreeBSD.
  • Libraries for web programming: XML/SOAP/WSDL/yadda yadda parsers, HTML parsers, a Lispish web application server and HTTP server, and easy libraries for all major networking protocols bundled in.
  • Cross-platform GUI libraries which are good enough for prototyping “programmer interfaces”.
  • Database libraries: ODBC, MySQL, Postgresql, Oracle.
  • Excellent foreign function interfaces for C libraries.
  • ACL provides OLE/COM linkage and examples of things like creating a simple CLOS layer for working with Excel.
  • Linkage to Java and/or .NET (e.g., jLinker and full support for RDNZL), which, together with the C FFI, means you can easily use code written in all the most popular languages.
  • Native threading (I guess you don’t get this), Unicode, and other oft-neglected but essential stuff.
  • Abundant working examples and comprehensive, helpful documentation for all of this.
  • All these libraries are bundled in, they work, they’re efficient, and they are supported.

All Common Lisp distributions give you efficient implementations of CLOS, a metacircular multiple-dispatch multiple-inheritance object system with an amazing metaobject protocol, as well as mini-languages for pretty-printing and iteration. SBCL, LispWorks, and ACL all have optimizing native-code compilers that give you performance somewhere between C and Java. SLIME, LW, and ACL provide IDEs matched only by Squeak in power.

Clearly if you pay $3,000 or however much, you’re getting a helluva lot more than just an implementation of a spec from 1984.

February 20, 2007

Microsoft’s bullshit “Shared source” license

Filed under: The Dark Side — metacircular @ 1:03 am

Microsoft’s Shared Source license is proof that you can give away access to source code and still not have free software.

Here are some choice excerpts from the License for F#.

You may not use or distribute this Software or any derivative works in any form for commercial purposes, except as follows: [bullshit exceptions follow]

In return, we simply require that you agree:
That if any of the Software is in binary format, you will not attempt to modify such portions of the Software, or to reverse engineer or decompile them, except and only to the extent authorized by applicable law. … That Microsoft is granted back, without any restrictions or limitations, a non-exclusive, perpetual, irrevocable, royalty-free, assignable and sub-licensable license, to reproduce, publicly perform or display, install, use, modify, distribute, make and have made, sell and transfer your modifications to and/or derivative works of the Software source code or data, for any purpose.

Emphasis is mine. So basically you only have access to the source but can’t really use it for commercial purposes as you see fit (e.g., you couldn’t fork off a language and then do commercial stuff with that). And no matter what you do, Microsoft automatically has the right to a slice of your action.

Fuck Microsoft.

Here’s the biggest reason to use Scala rather than F#: Scala isn’t distributed under a fascist asshole corporate-greed license.

February 19, 2007

A funny code snippet from the ThoughtWorkers

Filed under: Java, The Dark Side — metacircular @ 12:32 am

This is from a unit test in the source to CruiseControl.NET:

public void WhenTheConfigurationDoesNotContainDirectivesRelatingToShowingBalloonsItDefaultsToTrue()
...
public void CanProvideASetOfProjectStatusMonitors()
...
public void CreatesAnEmptySettingsFileIfTheConfigFileIsNotFound()

That’s auto-completion for you, I guess.

February 16, 2007

Some guy from Microsoft gave a talk about IronPython today

Filed under: The Dark Side — metacircular @ 5:18 pm

Today a Microsoft employee, Mahesh Prakriya (you can see him in a Channel 9 video here) gave a talk at my university about IronPython and other .NET scripting languages. Being a .Net language, with IronPython you get Python along with all the .Net libraries, which is even larger than I had thought. If you already knew .Net/COM stuff I guess you could be super-productive. The IronPython REPL is nicer than the default one from CPython and the integration with Visual Studio is nice if you’re willing to suffer Visual Studio.

The biggest weakness appears to be unit testing.

Basically all the good stuff in IronPython is proprietary Microsoft, Windows-only stuff that seems like it could be arbitrarily obsoleted by MS at any time. IronPython is substantially faster than CPython.

He avoided my questions about Microsoft’s lame “shared source” licenses and DRM in Vista. He politely told me that Microsoft doesn’t care about small emerging markets. They didn’t care about web applications or the Internet in general and they’ve been playing catchup against J2EE and LAMP ever since, so I don’t see why they’d still have that hubris.

I got tons of free pizza and soda, though.

Blog at WordPress.com.