Last week, I was feeling sort of frustrated and stuck. This week, I was volunteering at a summer camp, so I didn't have time to be stuck! I taught kids Scratch and pretended Minecraft is educational. It was fun. :D

I'm writing this from Hac Boston, a Haskell hackathon. I didn't realize that the hackathon would be more about hacking ON Haskell libraries, rather than making stuff WITH Haskell/Haskell libraries. It says "you don't even need any Haskell experience at all" on the event page but I should know by now that is always misleading. "You don't need any Haskell experience to attend -- but count on sitting at a table alone feeling dumb because you don't understand even the explanations that other attendees make obvious are super dumbed-down" would be more accurate.

So this weekend I learned that all the stereotypes about Haskell users are totally true, I was just protected from reality by the cool people at #nothaskell, Lambda Ladies, Recurse Center, and now TLC. :)

Despite this, this hackathon has helped me get unstuck on my KiSS set viewer project! I mentioned that I was trying to use Snap for my web framework, and several people noted that Snap was "over-engineered", so that made me feel better about not understanding it. I switched to Scotty and made immediate progress!

The website I'm making will to allow users to upload a KiSS set and play with it in the browser. Here's a sample set. KiSS sets are image files called "cels", color palettes, and a configuration file, all bundled into a compressed archive. So, my app needs to decompress the files, convert the cels with a palette, and parse the configuration file. Then it needs to serve up the set as HTML, CSS, and JavaScript.

I already had the conversion and parsing completed, so I just needed put it all on the web. That's what I'm working on this weekend!I'm going to try to explain what I have so far so I can understand it. )
I posted my weekly checkin to the TLC mailing list last night, but it was mostly whiny complaining about how I didn't get anything done, so I'm not going to repeat that here.

Instead I just want to talk about something in JavaScript that confuses me. (Maybe just because I'm not used to imperative programming.)

So, I want to represent some comics and comic book characters. So I make some objects.
var tony = { name: "Tony", job: "billionaire playboy philanthropist" }
var pepper = { name: "Pepper", job: "CEO of Stark Industries" }

and I say that those are the characters:
var characters = [ tony, pepper ]

and then I make up some comics:
var ironMan = { title: "Iron Man", characters: characters };
var pepperAdventures = { title: "Adventures of Pepper", characters: [pepper] };

The only problem is, Pepper isn't CEO of Stark Industries in (not real comic) "Adventures of Pepper". It's an Alternate Universe where she is a Professional Adventurer. But that's easy to fix, right?
pepperAdventures.characters[0].job = "Adventurer";

And if I look at pepperAdventures now, I see that Pepper's job is correct!
> pepperAdventures
{ title: 'Adventures of Pepper',
  character: { name: 'Pepper', job: 'Adventurer' } }

But this is where I get confused -- because Pepper is now an adventurer in Iron Man too!!
> ironMan
{ title: 'Iron Man',
  characters: 
   [ { name: 'Tony',
       job: 'billionaire playboy philanthropist' },
     { name: 'Pepper', job: 'Adventurer' } ] }

This is not good!! Stark Industries is sure to go bankrupt without Pepper!

I guess I just find this confusing because I'm not able to alter values like this in Haskell. This is what something similar might look like in Haskell:
data Character = Character { name :: String, job :: String }
data Comic = Comic { title :: String, characters :: [Characters] }

tony = Character "Tony" "billionaire playboy philanthropist"
pepper = Character "Pepper" "CEO of Stark Industries"
characters = [ tony, pepper ]

ironMan = Comic "Iron Man" characters
pepperAdventures = Comic "Adventures of Pepper" [ pepper { job = "Adventurer } ]

This results in the expected:
>pepperAdventures
Comic {
  title = "Adventures of Pepper", 
  characters = [
    Character {name = "Pepper", job = "Adventurer"}]}
>ironMan
Comic {
  title = "Iron Man", 
  characters = [
    Character {name = "Tony", job = "billionaire playboy philanthropist"},
    Character {name = "Pepper", job = "CEO of Stark Industries" }]}

That's because pepper {job = "Adventurer"} creates a new and different Character that's the same as pepper except that the "job" field is "Adventurer". It doesn't change the original pepper at all.

So it's constantly surprising when I run into these side effects in JavaScript and I find them kind of hard to understand. HOWEVER I can see how this could also be super useful and make things easier than what I'm used to!!
So I joined The Learning Collective and one of the things we do is a weekly check-in. I've already done a couple, but I just thought, this could be something for my own blog too! And this thing has been inactive for waaaay too long.

I missed last week's check-in because I was a little confused about what was going on.

Last week:


I spent a lot of time on my KiSS doll viewer. KiSS dolls are a format that was invented in Japan in 1991 to display pixel-based drag-and-drop dress-up dolls. KiSS sets have their own special scripting language and image format. The challenge I gave myself was to find a way to convert these sets to something that can be viewed in the browser. I used C to convert the image format, Haskell to parse the configuration file into JSON, and vanilla JavaScript for user interaction.

I did manage to convert a single doll, "Aurora" by Punky, to a browser-based set. You can play with it here.

Once I got to that point, I was very excited, but the project is barely started. I still need to implement a lot more of the earliest KiSS spec, let alone the many later upgrades.

Before I got any deeper into the project, though, I needed to add a test suite to make it easier to test the parser. This is where I ran into trouble.

Today, I worked with Steve McCarthy on my Haskell game. We decided to implement a really simple feature: listing all the game files (files ending in "exp") in the current directory. I want to share how we tackled this problem because it shows a lot of the steps in learning how to reason about Haskell when you're a beginner.

Lots of fun TDD and types behind the cut! )
(blogging from Write/Speak/Code)

A few months ago I started talking to other developers about something super exciting and wonderful I had just learned about. It had totally changed how I thought about writing code, so I was excited to learn what others thought about this super interesting thing. “I just learned about test-driven development guys! How cool is that!?”

*crickets*

Apparently I'm a bit behind the TDD times. A lot of people seem to think it's pretty boring and old-hat. It's too slow and dogmatic. It's something you have to do for work, not something you would worry about with a personal project. Also, why am I bothering anyway, when I'm writing in Haskell? A statically-typed immutable language doesn't need tests. “The types are your tests.”

I learned about TDD by attending Code Retreat, which is a day-long event during which you partner with other programmers in an attempt to implement Conway's Game of Life in a single hour, *while* writing passing tests. Some people who attended –like myself – weren't comfortable with TDD, and some pairs kinda fudged the requirements in order to get closer to a working product. But a working product wasn't the point. It was about learning to work with others – and learning to test. I paired with other beginners as well as senior developers.

I was amazed how the red-green-refactor process clarified and structured the process of making the game. The game is pretty simple, but not trivial. Different teams came up with different places to start. But I noticed, the teams who started with tests and didn't try to fudge that aspect, they were able to find a small, manageable place to start and work from. Teams that didn't would often bite off more than they could chew. Then at the end of the hour, their code wouldn't run at all, while the TDD pairs could at least say, "It's not done, but we implemented cells and a grid, and we have a solid base to work from."

I took that approach into Haskell, and decided to use TDD while making a text adventure game engine. There's not a lot of good how-tos on getting started with TDD in Haskell and some of it is outdated. Still, I found the process very worthwhile. Using TDD helped me choose what parts of the engine to work on first (“well, what would be easy to test?”). It also helped when I made big refactoring changes. Haskell is great because the compiler will yell at you if the types don't match up, but unfortunately, even in Haskell types aren't always perfectly expressive. The tests sometimes caught problems that the compiler missed and often helped me pinpoint places where my logic wasn't sound.

When I started studying Python recently, I found the increased expressiveness and flexibility of the language both exhilarating and a bit scary. I was amazed how I could come up with a function, just off the top of my head, and it would run! The only problem is when a function runs, but doesn't do what I thought it would do. I feel very insecure compared to Haskell. How do I know if what I'm doing is the RIGHT way to do it? One solution has been to learn more about design patterns and Python conventions, but TDD is what really gives me a security blanket. Even when my code is ugly or un-Pythonic, with tests I can feel more certain it will at least do what I expect.

In anything, fresh eyes can cause you to appreciate something that more experienced people just take for granted. Testing is not just something boring that has to be done for boring work projects. It's a whole way to think about writing programs! I'm really glad I went to Code Retreat and learned how even my small personal projects and learning exercises can benefit from tests.
A few things I've learned about my ADHD after 29 years:

1) Use large text, at least on the screen. I have an awesome high-resolution screen and my sight is fine, so I can read very tiny text. However, I have a very difficult time concentrating on any text that is smaller than about a 1/4 inch high on a screen. It appears very blurry and is tiring to read. I have to blow up the text on most websites, and the text in my console is cartoonishly large. When working with others on programming, I have to ask them to increase the text size. I use the excuse of "my eyes aren't good", but when I take ADHD medication, the blurriness of small text goes away, so it's definitely not my eyes. (Weirdly, I've never had this problem with books -- but just now as I'm typing I've realized that's because I hold my books about 6 inches from my face! This has a side benefit of blocking distractions from my peripheral vision. :)) Large text is probably the number 1 ADD hack I use every day.

2) Speeding up most lecture/talk videos to 1.5x or 2x lengthens my attention span enormously. Usually I take breaks every 10-15 minutes when watching a long lecture. Breaks help prevent daydreaming or zoning out, but impair my ability to follow a long train of thought in a talk. Sometimes when I return from a break, I've forgotten what the speaker was saying and have to backtrack or even restart the video. And there's always the risk that I'll get distracted by something during my "break" and never get back to the original video. By speeding the video up, I can usually watch an entire 1-hour video in a single sitting and retain at least as much understanding. I suspect this may work for audiobooks as well, but I can read faster than I listen, so I've never tried.

3) Write things down! EVERY. SINGLE. THING. In one place! EVERY. SINGLE. DAY. This is so hard. Good habits are so difficult to create and so so so easy to break. I've gone months when I kept track of journal. Those months are always easier on me and everyone around me, more productive, I would even say happier! I can "remember" important events and appointments, seem more responsible and organized, and also have a lovely written record of all the awesome things that have happened. Despite all these positive outcomes, I still occasionally lose a planner or go on vacation and decide I can do without my planner for a few days. Just a few days is all it takes. I lose the habit and it can take months to relearn it, during which my life is back to utter chaos. It's never "just this once", self. Use your planner!!
From [personal profile] metaphortunate:
When you see this, make a post in your journal or in a community. It can be anything: a crosspost something you've posted on Tumblr, a few words about the last thing you read/watched, or just a "Hi, how is everyone?" Then go read your f-list and leave at least one comment.


This is a nice idea. Dreamwidth is a lot quieter than the last time I tried out journalling/blogging. :)

I'm procrastinating on my Haskell text advenure game engine because the next thing to do is add some sort of inventory/object system. But that's a huge task, so it's a bit scary and overwhelming. I'm going to try to break it down so it's not so big ans scary. Maybe just the player has inventory, but you can't do anything with it and it never changes. :) Useless, but definitely do-able!

I've been reading Anna Anthropy's Rise of the Videogame Zinester for inspiration and it's really good.
Yay, my exploration game works now! I call it a "text exploration game" because it's inspired by Infocom games like Zork or Hitchhiker's Guide, but so far you can only explore a map but not interact with it so it's not really much of an adventure. It's still exciting to finally get it to work, because it was really difficult to find resources for making games in Haskell. Games are very "stateful" -- you have to keep track as things in your game change. Haskell has immutable state, though. So nothing in a Haskell program can change! How do you reconcile these things? Answer: I don't really know. But I do know a way to fake it!

I will definitely write up a big tutorial about my game once I've worked out the kinks. :D

I really need a better name than "exploration-game" though...
Last week, Mel Chua gave a talk a couple talks about learning styles. In one of them, she asked us to place ourselves on various spectrums of learning traits. They were: Active/Reflective, Visual/Verbal, Sensing/Intuitive, and Sequential/Global.

This talk was illuminating for me.

I was first diagnosed with ADHD in 6th grade, although my teachers had suspicions of it earlier. I was an underachiever and didn't work to my potential. Words to that effect could be found on every report card and heard in every parent/teacher meeting.

On the spectrums, I placed myself as very a very Active learner (I learn best when I just try things out instead of researching), moderately Visual, very Inuitive (I like to just try what "feels right" and I'm cool with it if I don't know right away if something is correct), and somewhat Global (harder to explain).

Do I have these learning styles because I have ADHD, or do is ADHD just how people with these learning styles are labeled? It's the age old question.

Mel encouraged us to work with people who's learning styles differ from our own so we can see what it's like.

I think I like computers because they're a good foil for my own tendencies towards fuzzy and disorganized thinking. And when it comes to programming, I like strict typing and TDD because it works against my weaknesses.

I love Vim!

Jan. 8th, 2015 02:36 pm
I started using Vim because of Vim Adventures, which teaches you how to use Vim while you play a game. It's super cute and fun and made Vim less intimidating.

Right now I'm trying to learn just one or two tricks at a time and accepting that I'm not doing everything in the most efficient way possible. But every day I learn something new, whether it's a new shortcut or a cool plugin. Today I learned a nifty trick in the NERDtree plugin, that by hitting "i" instead of "enter", the new file will pop up in a pane. I also learned how to switch between panes with CRTL+W+direction. So cool!
In my text exploration game project, I'm using HSpec to test my game. Why test? I first learned about test-driven development a couple months ago during Code Retreat in Pittsburgh. I'd never done any TDD before that. But over the course of the day, I found I really enjoyed process of writing small tests and making them pass. Most of the day, I was working with people who were very experienced with testing, but in other languages like Java, Scala, Clojure, or Python. The last session was the only time I worked with another Haskeller, and neither of us new how to test Haskell with anything but types and visually checking output. He was satisfied with that, but I really wanted to to fully learn TDD. That's why I added it to my project.

Adding tests to my code helped me reason through a lot of problems. I realized that a lot of the way that I had structured my program at first didn't make much sense and was really hard to test. For example, putting too much in one IO function. Now I think my code is more modular.

I still have a lot to learn about TDD in Haskell. I have a really hard time keeping to the red -> green -> refactor thing. I tend to either forget about the refactor part or go from refactoring to writing a bunch of new stuff without testing first.
Last night I got a bit confused by the Staten Island bus system and didn't get home until 11pm. I had collapsed on the bed, ready to pass out from exhaustion, when I got a text from my dad. "We are at ER Your mom will be getting her gallbladder out tonight"

So I didn't sleep very well.

Mom got through the surgery just fine and she'll leave the hospital tomorrow, but I still had trouble concentrating today.

I worked a little more on C. I fixed my atoi with Marin's help, and that was really cool. Now I'm trying to implement my own strcpy, which copies a string to another string. I'm not sure what that even means, which may be part of the problem. Maybe I've gone too far down the functional rabbit hole, so it's hard to remember how to do stuff imperitively. Pointers are really confusing to me as well.

I'm also working still working on my text adventure game in Haskell. I've trying to use TDD with Haskell, and there's really not enough tutorials on how to do that. I guess most people just use the types as their tests? Maybe I need to look at real projects with tests. I think that's what I'll do tomorrow.
I don't want to think too much about my third day in NYC, much less write about it. Exhausting. I'm living in a nice house in Staten Island now, though.

SO on to my first day at Hacker School.

Hacker School is awesome! Everybody is super nice and friendly!

Today was mostly spent learning C. A bunch of us signed up to be randomly paired with others for pair programming. I misread my email and thought my partner was Marin, so I talked with him a bit and found out he is very good at C. He offered to teach me some. The first thing we worked on was learning how the standard output, standard input, and standard error work. Then, he helped me write an attempt a implementing my own atoi. atoi turns strings into integers.

Warning: C code behind the cut! )
Delicious bagels for breakfast, natural history museum, curry, then getting horribly lost trying to figure out where Hacker School is, and finally dinner at a Russian restarant for Gene's birthday.

A good day. :)
My dad and I left my parents' house in Moundsville, WV at 5 am and traveled an hour to Gene's house in South Hills, where his mom took us to the Amtrak station. Gene and I always have a long-distance relationship because he's in Pittsburgh and I'm in Moundsville, but since we aren't likely to see each other for the next 4 months and it's his birthay next week, he came with me for my first weekend in New York.

I love taking Amtrak and take it whenever I have the time and money but Gene had never tried it. He was won over pretty quickly. Amtrak is way more comfortable than a bus or plane or (IMHO) driving yourself. His mom packed little Russian meat and cabbage handpies (don't know what they're called) and they were really good. The train was on time and didn't get delayed by freight traffic, so we got to the city at about 5pm.

Every time I visit any city, I'm blown away by the number of people I see just walking around, but of course this was a whole 'nother level. I also had to figure out how to use the subway which really wasn't that bad. We got to the hotel all right anyway.

The hotel we stayed at was one of the cheapest I could find online in Manhattan, and I chose it mostly based on the price (it was like 40% off regular price). So I was very pleasantly surprised how nice it was! This is probably the fanciest hotel I've stayed in, besides the one Con.Txt was held at last summer. Maybe that's just not saying that much because I'm usually a Day's Inn sort of person. :)

Gene decided he wanted to try Ethiopian food, so we went to a really nice restarant and had a vegetarian sampler. It was really good! Then we only got a little lost trying to get back to the hotel. Subways are confusing, y'all! Then we watched Thor on his laptop and fell asleep exhausted.

Pretty good first day in the city. Today, sightseeing. Gene insists on doing tourist things, I don't really care, so why not?
Happy New Year to me! And this is likely to be an exciting one. I'm going to Hacker School in New York City. I want to make a journal to keep track of trip and everything I learn.

Some things I would like to write about, or am likely to write about:
  • the Amtrak trip
  • Hacker School experiences
  • culture shock (I'm from a small town in West Virginia)
  • food
  • functional programming, especially Haskell
  • creating a text-based game in Haskell
  • creating my first OpenGL game in C
  • learning C
  • felt doll-making
  • NAND to Tetris
  • roller skating
  • ... lots of other things
Page generated Jun. 18th, 2025 08:52 am
Powered by Dreamwidth Studios