Move over CSS & Javascript – SASS and Coffee-Script are the future.

I’ve been playing around with .NET MVC3 with the Razor engine for work, and I must say it’s really cool. There’s a lot of functionality built in, and it makes developing sites super easy. You get all the benefits of an MVC application, while at the same time, building a website with reusable HTML modules.

One thing I just found for it is the addition of SASS/Coffee-Script. These are basically just higher levels of CSS and Javascript. The format is a little different, but the code is compiled into CSS or Javascript respectively.

So for instance if you take this SASS code snippet (notice how intuitive it is and clear to understand what is going on):

.fakeshadow {
border: {
style: solid;
left: {
width: 4px;
color: #888;
}
right: {
width: 2px;
color: #ccc;
}
}
}

Compiles to the CSS:

.fakeshadow {
  border-style: solid;
  border-left-width: 4px;
  border-left-color: #888;
  border-right-width: 2px;
  border-right-color: #ccc; }

While the above CSS is totally clear, the SASS is just so much quicker to write, edit, and maintain.

If you know Coffee-Script, the code below probably makes sense, but immediately I see so  many benefits and efficiency boosts writing in this language.

list = [1, 2, 3, 4, 5]

square = (x) -> x * x

math =
  root:   Math.sqrt
  square: square
  cube:   (x) -> x * square x

cubes = (math.cube num for num in list)

Which compiles to the Javascript:

list = [1, 2, 3, 4, 5];
square = function(x) {
  return x * x;
};
math = {
  root: Math.sqrt,
  square: square,
  cube: function(x) {
    return x * square(x);
  }
};
cubes = (function() {
  var _i, _len, _results;
  _results = [];
  for (_i = 0, _len = list.length; _i < _len; _i++) {
    num = list[_i];
    _results.push(math.cube(num));
  }
  return _results;
})();

Wow! There’s so much Javascript being created here just by compiling a few lines of Coffee-Script! Imagine having to do all these boilerplate definitions and syntax stuff by hand, and how much time you spend just on that. This is definitely the future for this type of stuff.

Working this into an MVC3 project would totally rock. Imagine a project where you wrote in SASS/Coffee-Script, used MVC3s power to compress/minify CSS/Javascript – you’d have an solution where all you need to do is write the functionality, and compilers and all that take care of syntax, organization, definitions etc, AND compress/minify. When you deploy, the application is efficient, packaged, and optimized, without you having to do any real work.

Code Complete 2 – Review part 1

Since my job requires me to write code, I obviously have to keep my skills honed and always be refining them. One book I just picked up is Code Complete 2 by Steve McConnell. The book isn’t a how-to code book. It’s really more of technique kind of reference manual.

I’m not going through it front to back, but I’ve touched on its pieces on variable usage and a lot of defensive programming techniques (reducing/handling errors). Already, I’m starting to see areas in my code where I could organize my data more efficiently. One example is a section on variable live time; it’s best to create your variable as late as possible until it is actually needed. This is never really a concern on our modern PCs/MACs, but since I’m designing a mobile app, memory usage/battery life are at a premium.

The code samples are very helpful as well, with the majority of them being in C++/Java. Each chapter begins with an outline of what will be covered. At the end, there is a checklist section with a bunch of questions you can ask yourself when working with a related area. I’m thinking this will help to reflect a lot on how I handle and approach my coding. Also at the end are a list of additional resource for the reader to use, as well as a summary of what was covered in the chapter.

If you’re looking for a good all-around coding techniques book, I definitely recommend Code Complete 2. I have two copies, one for work and one for home.

iPhone app status

I’ve been trying to finish up this app I’ve been working on for the better part of 7-8 months. It’s definitely hard when you have a full-time job. Basically my app is a sports trivia game and will ask questions about any specific sport. I know, the idea itself is kind of simple but how I am doing it and the questions I am asking I think are really clever and original – I’ve not seen it done anywhere else. When I get close to releasing it I will elaborate a bit more.

The basic trivia part is finished, a player needs to answer a set of questions and gets more points the faster they answer them correctly. One cool feature is there is the ability to play as a guest, or register and have your progress saved. I may decide later on to limit guest functionality to better promote registration. Right now I’m trying to integrate rewards and social media integration. I’d like to build in Facebook, Twitter, and maybe even an email functionality to challenge your friends or post a status if you set a high score. As for rewards, I don’t know what I would give away, but it would only be available if a player scored high in a trivia round.

One thing I worked on today specifically was making it connection-friendly. What I mean by that is it uses the least amount of data possible, since it is a service-driven app. Every piece of data the app receives comes from an external server. This gives me a lot of flexibility with updates. The app code is fairly straightforward, but the server code is a little more complex. I’m learning alot of compression, code minimization, and data usage. One of my inspirations behind this was being at a stadiums with little to no coverage; I could load up Scorecenter and wait for hours for it to load the massive amount of data it needs to show scores for 4 games. I can do better with this app.

One thing I really need is some graphic design work. My design skills are very minimal – almost MS Paint level. It’s sad I know. But if you’re reading this, and think you could help me out, I’m all ears.

One of my non computer-related interests

So I like to go the gym since I’m tall and have broad shoulders. Into computers AND muscular??? What girl couldn’t resist? Haha.

Currently, I weigh about ~190 lbs, underweight by 10 or 15 lbs so I’m not really picky about what I eat and don’t count calories. Simply adding on weight is easy, just eat a lot, but I want to put on muscle, not fat. About a couple years ago, I joined a gym, got a trainer and he put me on this muscle building plan where I was eating constantly and in conjunction with that, lifting heavy weights.

It was almost systematic how it all worked out and I got major results, but it cost me a lot of money for the trainer. It was definitely worth it, don’t get me wrong here, but it was too much money in the end and I had to cancel it.

I did learn a lot about gaining muscle though. I learned simply eating food wouldn’t do much if you didn’t do the right exercises. I was pushing myself so much at the gym, and eating so much I was constantly full and very sore in the beginning – no pain no gain! On average I was eating upwards of 3800 calories and drinking about 2 liters of water a day. I had a little Excel sheet I developed, tracking the calorie and protein count of everything I ate/drank. After a few weeks, I was so systematic with it. I was having fun!

I haven’t been focused on it so much lately, but I am wanting to get back into it. This time, I want to really document the whole process, not just the exercise scripts my trainer was recording. Maybe I’ll post them up here somehow so maybe others can duplicate any successes I have.

First real post

Ok, so now that I’ve done the obligatory first post, I wanted to post an actual post. I am a somewhat big computer geek. No, I am not a nerd. I do get outside and get dirty/sunburnt/sweaty/sore. I am a software engineer and am currently designing an iPhone application in my spare time while I’m not working or doing other fun things. It’s almost finished, just in the testing phases right now. More to come on that in the future.

I put up this website as a launching platform to express my thoughts and ideas. Using a blog seemed like the most natural progression so here we are, thank you for reading. Maybe there will be other things that I do with this, but at the moment it is what it is, just a blog.

Out of things to write now, back to other stuff.