Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa

Friday, October 30, 2009

38th Kansai Ruby Workshop

http://jp.rubyist.net/?KansaiWorkshop38 (in Japanese)

I attended 38th Kansai Ruby Workshop today and make a presentation there. The workshop was ustreamed.

My Presentation "Hacking parse.y"

I have made the same title presentation in Vancouver.rb so far. I also have two other opportunities to make the same title presentation in Kansai Open Forum and RubyConf2009. All presentations are different because of the difference audience. Kansai Ruby Workshop is the most casual place of them, so my presentation today was be the most casual one.

The agenda was the following:

  • Brief self introduction
  • What is Ruby Core
  • What is Ruby's parser
  • Understanding colons
  • Adding literal
  • (cont.)

Note that this presentation isn't for super Ruby programmers. I think all ruby commitors already know all of what I'll talk tomorrow.

Slides, Handouts and Record

Slides are available here(slideshare).

Handouts are availabble here(pdf).

Record is available here(ustream). (in Japanese)

Wednesday, October 14, 2009

GRE Exam

Today I took the GRE exam.

The result was too crazy to write here. I think something must be going wrong.

Thursday, October 8, 2009

RubyGems on Ruby 1.9

This blog post is a note of a report about the current RubyGems 1.3.5 on Ruby 1.9 for myself (including both 1.9.1 and 1.9.2) without any good reproductions or the solutions.

When I did rake192 spec on a directory which contains a Rakefile that uses jeweler, I met an enormous errors (The suffix means the Ruby version on my machine.) I've heard that anyhow gem192 uninstall update-rubygems can solve the problem, so I did it. But after that, the rake192 started to cause segfault!

The segfault is caused by a 1.9.2 marshal's bug which is already reported but not fixed yet. I gave up using 1.9.2, and then I decided to use 1.9.1 instead.

On 1.9.1 the results were exactly same except that it didn't cause a SEGV.

Downgrading RubyGems (failed!)

According to baroquebobcat,

$ gem uninstall rubygems-update
$ gem install -v x.x.x rubygems-update
$ sudo update_rubygems

does downgrade rubygems itself. So I did them with some trivial changes, but it failed again. The following is the result:

$ update_rubygems191
<internal:gem_prelude>:344:in `method_missing': undefined method `bin_path' for Gem:Module (NoMethodError)
        from /Users/ujihisa/rubies/bin/update_rubygems191:19:in `<main>'

hmm...

Friday, October 2, 2009

What's Your View?

When I was a student, my supervisor often asked me the question. It confused me, which meant that I didn't understand what I was talking.

Although the relationship between understanding the contents and grasping the view is bi-directionally, it is worth trying to grasp the view of a given research first, then understand the remains. This strategy is easier, particularly for me. Never forget to look for the author's viewpoint. Ask myself: "What's the view of the research?" Now I must be able to find the goal of the research easily.

Programming Language as Human Interface

5 Reasons Why People Use This Language

There are a lot of programming languages both in the real world and in the academic experimental world. Everybody knows the common function which Professor Turing defined among the languages. Although almost all programming languages which are used as a production can be ultimately written in a single language, we tend to use specific languages for some reasons.

  1. Our project has used this language.
  2. Our project needs a specific library written in this language.
  3. We're excel at this language.
  4. A specific functionality of this language is absolutely effective on our project.
  5. The syntax of this language is good.

This order means the order of impact. Yes, unfortunately the syntax matters the least.

Note that only (3) and (5) are independent on a specific project, and (3) can be said a consequence of (5). Therefore it is deducted that (5) is worth studying.

Human Computer Interaction

According to wikipedia, human computer interaction, also known as the study of human interface, is defined as the study of interaction between people and computers. In other words, human computer interaction is the combination of computer science, behavioral sciences, design and several other fields of study. The goal of HCI (Human Computer Interaction) is to improve the interactions between users and computers by making computers more usable and receptive to the user's needs.

I think that the biggest challenge of this field is how to evaluate the goodness of a given hypothesis. We cannot deductively prove the new theory certainly makes a system more usable easily. We cannot numerically measure how the new theory certainly improved the usability easily.

Programming Language as Human Computer Interaction

Remember the conclusion of the reason why we use a specific programming language, which is previously described: "because the syntax of this language is good." Here we have to consider how to evaluate the goodness of the language. It is difficult for language designers and users to objectively explain how good their language syntax is. This circumstance is highly similar to the issue of HCI.

For example, some people agree the following example: Ruby is better than Java because of the simple "Hello, world!" sample obviously.

# Ruby
puts 'Hello, world!'

/* Java */
class HelloWorld {
  public static void main(String argv) {
    System.out.println("Hello, world!");
  }
}

It is easy for me to disagree the opinion. I don't think I have to declare the reasons here because you can presume easily.

So, how can we evaluate the goodness of language syntax without any controversial counterargument? What points of view are desirable for the purpose? This issue is worth studying.

Conclusion

Programming language has aspects of the study of human computer interaction. I showed only the importance of syntax as one of aspects, but there are some other features include being able to complete by editors and type system for human aid. It turns out that it is good to improve it with the similar ways of previously used in HCI studies.

Other Miscellaneous Comments

According to ACM, HCI is defined as "a discipline concerned with the design, evaluation and implementation of interactive computing systems for human use and with the study of major phenomena surrounding them." In short, HCI is for implementation of interactive computing system. Whereas my view on this entry is for implementation of implementation of interactive computing system. It can be said as higher order HCI.

Thursday, October 1, 2009

Google Earth In Canada

Google Maps in Canada is sometimes insufficient. Information on the map in Canada isn't as rich as in Japan or in the US. The satellite is outdated.

Today I installed Google Earth on my MacBook Air and viewed my neighborhood. I surprised that Google Earth is absolutely greater than Google Maps regarding to the contents.

vpl1

http://home.graffiti.net/rec_images01:graffiti.net/nutcrew/7th20/Vancouver_public_library_vancouver_british_columbia.jpg

This is my nearest public library.

In Google Earth,

vpl

It's amazingly real.

Monday, September 21, 2009

Beautiful and Functional English Writing Software

These days I am concentrated in improving my English skill; particularly in listening and writing. Actually now I'm under increasing pressure because the score of the result of my last TOEFL exam was bad rather than insufficient. So I decided not to code programs too much as my hobby, but to write English essays more and more. I have less time to do all things what I like than usual.

To write English essays more efficiently, I wish such editors:

  • Beautiful rendering with proportional fonts
  • Rich functionalities

When I mentioned about "rich functionalities" in the context of text editing, it stands for Vim. But unfortunately Vim doesn't support proportional fonts but supports only monospaced fonts. Monospaced fonts are beautiful in programming languages, but in natural English language, they aren't.

So I wrote a patch for supporting proportional fonts on MacVim.

1

Building MacVim with my patch

First of all, fetch the MacVim source and build plain Vim.

$ git clone git://repo.or.cz/MacVim.git MacVimUjihisa
$ cd MacVimUjihisa/src
$ ./configure --enable-gui=macvim
$ make

Create the following patch file on a.patch:

diff --git a/src/MacVim/MMTextStorage.m b/src/MacVim/MMTextStorage.m
index 0d272b2..0327a8f 100644
--- a/src/MacVim/MMTextStorage.m
+++ b/src/MacVim/MMTextStorage.m
@@ -656,12 +656,8 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
         cellSize.width = ceilf(em * cellWidthMultiplier);

         float pointSize = [newFont pointSize];
-        NSDictionary *dict = [NSDictionary
-            dictionaryWithObject:[NSNumber numberWithFloat:cellSize.width]
-                          forKey:NSFontFixedAdvanceAttribute];

         NSFontDescriptor *desc = [newFont fontDescriptor];
-        desc = [desc fontDescriptorByAddingAttributes:dict];
         font = [NSFont fontWithDescriptor:desc size:pointSize];
         [font retain];

@@ -680,21 +676,18 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
         boldFont = [[NSFontManager sharedFontManager]
             convertFont:font toHaveTrait:NSBoldFontMask];
         desc = [boldFont fontDescriptor];
-        desc = [desc fontDescriptorByAddingAttributes:dict];
         boldFont = [NSFont fontWithDescriptor:desc size:pointSize];
         [boldFont retain];

         italicFont = [[NSFontManager sharedFontManager]
             convertFont:font toHaveTrait:NSItalicFontMask];
         desc = [italicFont fontDescriptor];
-        desc = [desc fontDescriptorByAddingAttributes:dict];
         italicFont = [NSFont fontWithDescriptor:desc size:pointSize];
         [italicFont retain];

         boldItalicFont = [[NSFontManager sharedFontManager]
             convertFont:italicFont toHaveTrait:NSBoldFontMask];
         desc = [boldItalicFont fontDescriptor];
-        desc = [desc fontDescriptorByAddingAttributes:dict];
         boldItalicFont = [NSFont fontWithDescriptor:desc size:pointSize];
         [boldItalicFont retain];
     }
@@ -714,32 +707,25 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";

         float pointSize = [newFont pointSize];
         NSFontDescriptor *desc = [newFont fontDescriptor];
-        NSDictionary *dictWide = [NSDictionary
-            dictionaryWithObject:[NSNumber numberWithFloat:2*cellSize.width]
-                          forKey:NSFontFixedAdvanceAttribute];

-        desc = [desc fontDescriptorByAddingAttributes:dictWide];
         fontWide = [NSFont fontWithDescriptor:desc size:pointSize];
         [fontWide retain];

         boldFontWide = [[NSFontManager sharedFontManager]
             convertFont:fontWide toHaveTrait:NSBoldFontMask];
         desc = [boldFontWide fontDescriptor];
-        desc = [desc fontDescriptorByAddingAttributes:dictWide];
         boldFontWide = [NSFont fontWithDescriptor:desc size:pointSize];
         [boldFontWide retain];

         italicFontWide = [[NSFontManager sharedFontManager]
             convertFont:fontWide toHaveTrait:NSItalicFontMask];
         desc = [italicFontWide fontDescriptor];
-        desc = [desc fontDescriptorByAddingAttributes:dictWide];
         italicFontWide = [NSFont fontWithDescriptor:desc size:pointSize];
         [italicFontWide retain];

         boldItalicFontWide = [[NSFontManager sharedFontManager]
             convertFont:italicFontWide toHaveTrait:NSBoldFontMask];
         desc = [boldItalicFontWide fontDescriptor];
-        desc = [desc fontDescriptorByAddingAttributes:dictWide];
         boldItalicFontWide = [NSFont fontWithDescriptor:desc size:pointSize];
         [boldItalicFontWide retain];
   }

Then apply it:

$ patch -p2 < a.patch
$ xcodebuild

Then run it:

$ open build/Release/MacVim.app

Then fix its font config.

Known Bugs

  • In insert mode, the location of cursor is far from correct location.
    • a
  • Vertical split is broken.
    • b
  • Handling screenwidth. Now Vim wraps in a strange position.

Now I don't have time to fix the problems.

Followers