• About
  • About

Steve Cooper's Personal Blog

  • SonicFileFinder for Visual Studio

    December 16th, 2008

    For those of you who use Visual Studio all day, can I suggest that you install [SonicFileFinder][sff]?

    [sff]: http://jens-schaller.de/blog/2008/12/15/295.htm

    This lovely little addin by Jens Schaller gives you a way to find files in your current solution with a few keypresses. Invoke it, and you see a dialogue like this;

    Sonic File Finder

    Type in a fragment of a filename, and you’ll get a filtered list of files matching that fragment. Choose a file, hit ‘return’, and the file opens in the code editor.

    Basically, if you know the name of your file, you no longer need to use the Solution Explorer. As codebases get bigger and bigger, this addin gets more valuable as the Solution Explorer gets worse.

    Highly recommended, plus it now works with F#, C#, and VB.NET projects.

    Advertisement
  • Twittering

    December 1st, 2008

    Now twittering on [http://twitter.com/stevecooperorg](http://twitter.com/stevecooperorg). Feel free to follow. If I can tell who the hell you are, I’ll follow you back.

  • FxCop rules for functional programming

    October 20th, 2008

    Languages like C# 3 have come on great leaps and bounds when it comes to allowing a functional programming constructs. However, they are at heart imperative languages. I wonder whether you could use FxCop/Code Analysis rules to try to bully yourself into correct behaviours, like using immutable variables.

    I have no idea how to go about doing this — particularly, I don’t really understand what the rules should be — but I think it would be interesting to develop a C# project with a set of rules promoting a functional style; it might be easier than, say, learning [F#](http://msdn.microsoft.com/en-us/fsharp/default.aspx?ppud=4).

  • Using speech synthesis to improve your writing

    September 24th, 2008

    I’ve just discovered a fancy-pants new way of helping me with my fiction, and I thought I’d share. The idea is to use a speech synthesiser to listen to parts of your writing. By listening, you hear problems that aren’t so obvious on the page.

    I recently bought a copy of [Cepstral’s][cepstral] text-to-speech software, buying one of their voices for $30. This lets you do some very nice things. Originally I just intended to listen to web pages using the [Click, Speak][] firefox extension. Rather nice; visit a web page, choose ‘speak selection’ from a menu, and hear the web page. Neato.

    But I’ve found it more useful when editing fiction. Select a sentence or paragraph and have it spoken back to you. As you listen, awkward phrases will jump out at you. Sentences that flow badly become more obvious. Good writing seems satisfying when you hear it read out.

    So how can you go about it? Well, [Cepstral][] do a free demo download of their voices. I’m using Cepstral Alison. Cepstral do their own text editor called _swifttalker_. Just cut and pastie text into the editor and click the play button. Until you buy it comes with a prefixed message about licenced, but if you purchase it’ll go away.

    If you are more technically inclined, and are comfortable writing scripts for your word processor (say, macros for MS Word, or python for [Sublime Text][st], or lisp programs for [emacs][]) then you can use the `swift.exe` program that comes with a Cepstral voice, piping selected text into the executable. That’s what I’m doing, and it’s great.

    [cepstral]: http://cepstral.com/
    [Click, Speak]: http://clickspeak.clcworld.net/
    [st]: http://www.sublimetext.com
    [emacs]: http://www.emacswiki.org

  • Ira Glass on storytelling

    July 8th, 2008

    A great series of short videos on storytelling.

    On the basics;

    On finidng great stories;

    On good taste;

    On two common pitfalls;

  • podcast recommendation; The Intercontinental

    June 20th, 2008

    Pop yourself over to [The Intercontinental](http://www.jessekaminsky.com/intercontinental/) to hear an amazing mix of music from around the world.

    This isn’t ‘World Music,’ not some terrible folk music. It’s a vast array of different styles from around the world — hip hop, prog rock, surf rock, whatever — stuff you don’t usually hear just because it’s not in your language. The [playlists](http://www.jessekaminsky.com/intercontinental/playlists/) mention;

    * Moroccan hip hop
    * North African, international flutes and more Cambodian music
    * French Psychedelic
    * Ethiopian synths
    * Burkina Electric
    * Korean psych guitar
    * Yugoslavian Mariachi (Meksikanski)

    Anyway, it’s a weekly show, about two hours, and it’s available [as a feed](http://feeds.feedburner.com/TheIntercontinental). Download it, love it.

  • My story, “No Tomorrows,” now available on Pseudopod

    June 20th, 2008

    Dear all,

    Can I invite you to listen to a story?

    A short while ago, I sold my horror story, No Tomorrows, to Pseudopod. Pseudopod, for those of you who don’t know, is the world’s most popular horror podcast. A podcast, for those of you who don’t know, is an audio magazine dishing up weekly MP3s that you can listen to on your iPod or PC.

    Anyway, it went live today, and is narrated by the rather Excellent Alasdair Stuart. It clocks in at about 24 minutes.

    There are several ways you can get the story;

    – You can [listen to the file](http://pseudopod.org/2008/06/20/pseudopod-95-no-tomorrows/) in your web browser.
    – You can [download the MP3](http://media.rawvoice.com/pseudopod/media.libsyn.com/media/pseudopod/Pseudo096_NoTomorrows_Audible.mp3), and play it on your PC.
    – If you have iTunes, you can [subscribe to the weekly show](itpc://feeds.pseudopod.org/Pseudopod).

    Anyway, enjoy!

  • The Black Oven; death metal baking.

    June 11th, 2008

    From [The Black Oven](http://theblackoven.blogspot.com/). How can you not love it?

    > **Where the Chocolate Beats Incessant**
    >
    > As far as I am concerned, brownies are one of the truest manifestations of metal in the scope of baking. Nestled inside their dark, viscous hearts lies a sickening world of decadence. The following recipe is no exception. Try baking them, and consider the fact that the mastery of brownies is parallel to the mastery of the occult.

  • Meme: First Lines Of Stories.

    May 29th, 2008

    First line of the last story completed:

    Jord stood at the gates of Odin’s hall, and rapped the knuckles of her
    callused hands against the ancient black-oak door. — Thorsday Teatime

    First line of the story you’re supposed to be working on right now:

    “Oh fortune, who hath served me wine like the rust of empires and the ichor of angels, who hath fed me ash and bone and the flesh of lions, rejoice!” — Modus Operandi

    First line of the last story you sold:

    Six months ago, it was all sugar and no shit. — No Tomorrows

    First line[s] of the last story published:

    If there’s one thing they really drum into you at medical school, it’s this: if you’re having a seizure, don’t stick an eight-inch lumbar-puncture syringe in your own eyeball. — Brainfish.

    Five first lines of unfinished stories without titles:

    “With tuthkth like thethe, you think it’th eathy to dithpenth advithe?”

    “I didn’t so much lose my faith,” said Danny, “as much as, well, choose another provider. Like mobile phones. I got a contract with another company.”

    Farisa emptied the backpack onto the restaurant kitchen’s central table. “Not a good haul tonight, Nat. Just what I could get from that last condo up on Seventh and Temple.”

    I think I became aware of what I could do when I was about three years old.

    Albert Von Hagen was the first passenger to arrive on the Titanic, a full forty hours before it sailed.

  • A lisp macro virgin tells all

    April 12th, 2008

    I finished my first lisp macro, and I want to tell the world.

    I’ll talk about what a lisp macro is, and what makes it unique in the world of programming, how it’s a technique only possible in lisp. I’ll then take you through an example.

    So firstly, what’s a lisp macro, and why would you want to write one?

    So, you may have seen lisp programs before, and you’ll recognise them instantly — Larry Wall, the inventor of [Perl][], said they had all the aesthetic appeal of a bowl of porridge mixed with toenail clippings;

    (defun accumulate (combiner lst initial)
    (let ((accum initial))
    (dolist (i lst)
    (setf accum (funcall combiner accum i)))
    accum))

    He has a point. They are butt-ugly. But hell, the best he came up with is [Perl][], so he can `$_@++` right off. (I’m pretty sure that’s valid Perl, too 😉 )

    It’s ugly, in an aesthetic way, but it’s amazingly practical. It’s got an engineering beauty to it. If you look at that snippet above, you’ll notice that the whole program is made out of exactly three types of symbols;

    * open parenthesis: `(`
    * close parenthesis: `)`
    * symbols, like `defun`, `accum` and `setf`

    All simple lisp programs are like this. Just brackets to group stuff together, and stuff that needs grouping. Compare that with C#, where you might find;

    * parenthesis for;
    * function calls; `print(“hello”)`
    * special forms; `using(OdbcConnection con = …)`
    * semi-colon to end statements; `int x = 1;`
    * curly brackets for;
    * code blocks; `{ /* code block */ }`
    * array initialisers; `string[] words = { “hello”, “world” };`
    * square brackets for array indexing; `x[3] = 4`;

    and the list goes on. I gave up because there are too many to list.

    So lisp has this seriously small syntactic footprint. You can have a thing, or a group of things in brackets. It’s simple. It’s *so* simple that you can start doing crazy stuff in lisp that you just can’t do otherwise. That crazy stuff goes by the name of macros.

    I can write a program that takes a chunk of lisp (remember, just a thing or a list of things), cuts it up, and reassembles it. That creates new lisp code.

    So imagine you do a lot of work on three-dimensional arrays. You find yourself, over and over, writing nested loops that say;

    for x in range(100):
    for y in range(100):
    for z in range(100):
    # do something to matrix[x,y,z]

    And frankly, you’re bored of typing it over and over. What you really want to do is something like;

    for {x 100, y 100, z 100}:
    # do something to matrix[x,y,z]

    You want a brand new bit of syntax for multiple-value looping. Can you add it to python? Nope. C? Nope. Java? Nope.

    But now look at the lisp version;

    I could, theoretically, write this

    (domanytimes (x 100 y 100 z 100)
    body)

    and, because it’s just a list of stuff, I can chop and change that into this new bit of lisp;

    (dotimes (x 100)
    (dotimes (y 100)
    (dotimes (z 100)
    body)))

    I’ll show you how in a second, but notice what’s possible — I can write my own looping construct (`domanytimes`) and lisp will rewrite it into many simpler looping construct (the built-in `dotimes`).

    Is that particularly special? Well, yeah. I’ve written new syntax. I’ve defined a new way of looping that is no different from the standard loops. I’ve basically added something new to the language. Lisp is now better at dealing with multi-dimensional loops. Try adding a new loop to ruby, or javascript. Make python understand

    for x in range(100), y in range(100), z in range(100):
    # body here

    and you’ll find you can’t.

    So I’ve made my version of lisp a bit better at handling loops. If I were writing database code, I could make lisp better at writing SQL statements or data access layers. C# recently got built-in DAL logic with [LINQ][], and it’s great, but only the C# team can write it. Whereas a lisper could write this sort of code;

    (sql-select (ID NAME) from PROJECT where (DUEDATE > TODAY))

    and it’s do basically the same thing as [LINQ][].

    So that’s the why’s and wherefores. Here’s the how of the `domanytimes` macro.

    `domanytimes` takes two parts; the loop variables `(x 100 y 100 z 100)` and whatever body you want to execute. We’re going to write a program that skims two elements from the front of the loop variables (say, `x` and `100`) and uses them to write a built-in `dotimes` loop; so a program which converts

    (domanytimes (x 100 y 100) body)

    into

    (dotimes (x 100)
    (domanytimes (y 100) body))

    and then again to give you

    (dotimes (x 100)
    (dotimes (y 100)
    body))

    Here’s the `domanytimes` macro, in all it’s eye-bleeding horror;

    (defmacro domanytimes (loop-list &body body)
    “allows you to write (domanytimes (x 10 y 10) …)
    instead of (dotimes (x 10) (dotimes (y 10)) body ))”
    (if (eq (length loop-list) 0)
    ;; we have our form to execute
    `(progn ,@body)
    ;; we have more loops to arrange
    (let ((fst (car loop-list))
    (snd (cadr loop-list))
    (rst (cddr loop-list)))
    `(dotimes (,fst ,snd)
    (domanytimes ,rst ,@body)))))

    There. Wasn’t that fun? 😉

    It looks nasty, I know. All lisp looks nasty. But it’s actually created something new in the language. As far as I understand it, lisp has survived for fifty years basically because the macro system lets you write macros which can add any new kind of syntax you like. You can write knock up a set of macros to [implement OO][clos], and suddenly lisp is OO. You can know up macros for manipulating lazy lists, and suddenly lisp has a [lazy evaluation][lazy]. You can knock up data access layer macros, and it’s got a version of [LINQ][linq]. There seems to be nothing you can’t hack lisp into being.

    And if you want to know how the hell that works, I’d recommend [Practical Common Lisp][pcl], which is online and free.

    [linq]: http://msdn2.microsoft.com/en-gb/netframework/aa904594.aspx
    [lazy]: http://en.wikipedia.org/wiki/Lazy_evaluation
    [clos]: http://en.wikipedia.org/wiki/CLOS
    [perl]: http://www.perl.com/
    [pcl]: http://gigamonkeys.com/book/

←Previous Page
1 … 3 4 5 6 7 … 18
Next Page→

Blog at WordPress.com.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
 

Loading Comments...
 

    • Follow Following
      • Steve Cooper's Personal Blog
      • Already have a WordPress.com account? Log in now.
      • Steve Cooper's Personal Blog
      • Edit Site
      • Follow Following
      • Sign up
      • Log in
      • Report this content
      • View site in Reader
      • Manage subscriptions
      • Collapse this bar