Saturday, February 11, 2012

Lessons from using JSIL to convert C# to JavaScript

So I big reason I am still considering using C# is that there is a tool out there to convert C#/XNA games to JavaScript. This seems like the best of both worlds - game can be maintained in readable JS and I can update code in the language I am most comfortable with. However, JSIL is open-source with zero documentation. Recording my lessons learned here:

Getting Started

Assumptions:

  • You have Visual Studio 2010 and understand how to make .exe files for your programs
  • You have a basic understanding of SCM systems
  • You have programmed before, and are somewhat technical

Getting the source code:

  • Download Git here. Don't worry - we just need the full source
    • On installing, be sure to opt-in for the Command Line client (Windows)
    • Open the command line client. create a folder for the project and navigate there (Linux commands 'cd', 'mkdir' etc. work here)
    • Clone the JSIL repo recursively, including sub-modules:
    • Congratulations! You have the source!

Generating the JSIL .exe file

  • Open the JSIL.sln solution file
  • Rght-click on the solution file in the Solution Explorer
    • Select "build all"
  • the JSILc.exe file will be placed in the bin directory of the project

Using the .exe file to convert C# to JavaScript

  • The JSILc.exe file needs to be run from the bin directory - i.e. you can't move it around (seemingly)
  • Open a command window in this directory
    • Go back one directory, hold shift and right click the folder. You should see an option to open a command window there
    • You will have to run this .exe from the command window.
  • Bring your .exe file that you want to convert into the bin directory
  • "apply" JSILc.exe to your .exe. In the command prompt, type the following (remove the <> signs):
    • JSILc.exe <yourexe.exe> --out=<destination directory>
  • Congrats! You have converted source.

This is where I'm stuck - I get errors when I try to run the .js files that I can't resolve:
'JSIL is undefined'
I also don't really know which .js file to "run" - manifest.js? There isn't much help here.

Things to avoid

  • Do not assume you can download the source from GitHub - you need to do a full recursive clone using Git to get all the right references for JSIL
  • Do not move JSILc.exe around - it seems to fail outside of the build output directory.

Thursday, June 9, 2011

Opening Super Comrade Oriam's casket

He is badly decomposed, but we can rebuild him!

A Redditor recently announced that he developed a C# to JavaScript compiler, and the demo was the tutorial XNA game! This is perfect as JavaScript is cross-platform and easily portable.

In the end, though, if the JavaScript can't work, at least I'll have updated SCO to XNA 4.0, Visual Studio 2010, and Farseer Physics 3.2. There is a great tutorial for converting from Farseer 2.x to 3.2 here.

Monday, April 25, 2011

Regular Expression Search/Replace with IntelliJ

I recently got tasked with reviewing some HTML documentation for my company's product. In the documentation, many instances of the abbreviation "ID" were used. Except, they were being used inconsistently. Sometimes it was "ID", sometimes it was "Id", and sometimes it was "id". Luckily, IntelliJ supports find/replace with regular expressions.

find: id([ .,;!])
replace with: ID$1

The capture group (in the parenthesis) preserves the punctuation if there is any with the "$1" part of the replace.

Sunday, July 18, 2010

Dream Journal

I have had vivid dreams for the last two nights. I used to keep a dream journal and write all my dreams down. They say it helps you remember dreams more easily in the future. I stopped because it was a hassle.

The dream last night started somewhere and had some stuff happen that I don't really remember. One part I was on an island in the sky with others, and we would travel by thrusting ourselves into these long gray dirt tunnels. One of these lead to the Netherlands, and that was one of my companions homelands. This is probably due to a line from Gettysburg, which I watched last night.

I was working for someone who told me to spread around these dangerous, poison capsules. I remember objecting and being told that it didn't matter. There was a lot of small trains on a lot of small tracks around this countryside. There were lanterns on the back hitch of these trains, and I remember a contest to get one. I tried and failed. At one point a train went by and put gravestones down in-between the tracks it was on. apparently, the train could still move over them. The part I remember vividly is an abandoned house. I went into the house alone, and remember it being quite frightening. I then had a companion, though, who I think was a friend of mine named Laura. She told me this is the house she grew up in, and we thought it was haunted. She told me to lay the capsules, which looked like small, wax, orange-syrup filled scimitars, on the table in the dining room. I also had small , round, capsules of butter that I laid around the house. I guess the goal was to get someone to pick them up, one of the haunters.
There was also a small shack across the road from this abandoned house. The house was a three-story house on a hill, will a full basement. We left that place and came back later, and went through the kitchen and the dining room where the table was. The capsules were gone, and instead there were small blue squirt guns in various positions pointing at us. They started firing, but Laura remembered doing this as a child and the way to make them stop was to simply yell "stop!" and point at the gun. We did that and they stopped, and then magically a small girl appeared behind each one and laughed and scurried away.
We then all sat at the dining room table, and then Laura's mother appear with great duress to Laura. she noticed my presence, but not Laura's. She offered me cereal and began talking to me like I was one of her daughter's friends. I remember her telling me she had five daughters and five sons, but the sons never appeared. She seemed to be stuck in a time past. I had a magazine with me, and she commented, "how come I can see your feet through the table?" The magazine was dated 2010. I then realized she could not see anything that was "out of her time," which was about 1996. She seemed troubled by this, and I asked her if she knew anything about mental diseases, or slow degrading of the brain. She said no, but I pointed out the hole in the table which wasn't there, and she started to break down. I told her to follow me. I took her out of the house and across the street, which was now a large, three-story house build around the shack that was once there. Laura's mother told me how her husband lived here, and they were getting separated. I took her to a room upstairs and turned on the light and told her to look around. She seemed to vaguely understand what was happening. I told her to look at the magazine, and asked if she could read the date. "2010..." she said. I told her that that was the current year and time, and she has been stuck in the mental state of fifteen years ago. Slowly she changed and looked around, and fully realized where she was and what was happening. I was very excited to show Laura. I went out into the main living room on the third story of the shack-house. there was a lot of people here, but not Laura. I yelled for Laura, thought I saw her, but it was only someone who looked like her. I then yelled for any Williams sister, and could find none. I panicked and ran back to the mother's room. She was emulating some sort of martial art move that someone was showing her, and she lost her balance and fell on the ground, hitting her head. I then saw a computer diagram that showed an image she had not recognized. There was a date in the corner of this image -- 2010. The image started to disintegrate, starting from the lower right. I yelled "No!" at increasing volumes. The image disappeared and was replaced by one that simply stated, "1996." I was heartbroken, and full of anguish.

The dream ended here, and I awoke with a start. It was a very painful dream, and very interesting to me. I often dream, but the last two nights have been very vivid. They involved doing things under a lot of duress, but were not nightmares. This one in particular is very interesting to me because it contains two things that are not supposed to occur in dreams -- color and being able to turn lights off and on. I don't know what this means or if it is significant. I have had color before in my dreams -- the orange I know very well.

Tuesday, June 15, 2010

How do you think this will end?

I just submitted this question to Rhapsody customer support:

"Long ago, I had an account set up with Musicmatch, using the Musicmatch
desktop application. I purchased quite a few songs for that account, but then I forgot about it for three or four years.
Since Musicmatch was acquired by Yahoo and subsequently Rhapsody, I am afraid my account, and the songs I purchased, have been lost in the shuffle.
I believe the username I was using for the Musicmatch desktop application was "getimoliver".
However, I can't log into Rhapsody using this username. I have also tried using the "forgot your password" link.
Would it be possible to retrieve my old account, or at least the songs I purchased on it? I am able to provide the credit card number I used to purchase the songs, my full name and address, and my old login information.
Thank you!"

I'm not getting my hopes up. Will post the response I receive.
Question Reference #100615-004308

Tuesday, April 13, 2010

Japanese Bowling

The way Japanese people will hold a conversation with each other is very different from the way most Westerners converse. In Japan, a conversation is like a game of bowling. The most respected of the group will bring up a topic, and mention something about it. Then, the next person in line will take a swing at the same subject. Just like we take turns in bowling and do not directly compete.
Western conversation, however, is more akin to a game of tennis. One person will direct the conversation either at one person in particular hoping to elicit a response, or will throw a topic out for the another person to send back.
The Japanese lead a very structured and rules-driven life. It is not surprising that they would hold conversations differently than those of the west. It is also not surprising that the XP practice of Kanban came from the Japanese. Unlike the West who loves to "cowboy code," Kanban presents a very structured and detailed way to accomplish work which (no surprise) works better than the ways of the cowboy.

I think we should consider adopting the Japanese way of conversing for some situations.

I was in a meeting today with another part of our company, discussing integration points. I brought up a very simple question: how detailed do we want an invoice? It took literally 30 minutes to get this question answered. I threw the ball out there to be returned, but instead of it being returned to me it was stolen by my project manager, who went on to play his own game of tennis with other people in the meeting. It was only after no one was playing at all that I had a chance to ask my question again, and stay involved enough to get an answer.

When I go to a meeting I come with a set of a few simple questions that I would like to get answered. Once they are answered, I have no problem casually tossing the ball around to get a better idea of general topics. When I wanted the answers, though, I could not concentrate on what was being said. Instead, I was seeing when I could get the ball back in my possession. There has to be a better way to do meetings.

The military is another place we can see structure. Rank is strictly enforced, but all are given a chance to speak, albeit with respect and with a staunch time limit. The military must be trained to focus and move as a single unit. If they do not, they will fail in their tasks, or at least be much less effective.

Therefore, instead, we try the structured Japanese way of conversing. We all sit in a circle. The highest ranking member brings up a topic, and we all comment on it in turn until there is nothing more to be said about the topic. A time limit of a minute or so is placed on each person. Then the next person in line repeats the process. We do not ping-pong the ball back and forth between two or three people in a meeting of six. Everyone is given equal opportunity to speak, and no one leaves feeling they have unanswered questions. We increase focus and effectiveness.

You may recognize this meeting schedule; It is a derivative of the standup meeting.

Now the only problem is getting people to try it...