I Love Me Some Coffee

This week I tried something new, roasting my own coffee beans. After trying Philz and Four Barrel’s wide variety of coffee’s I decided it was quite likely the best coffee i’ve had… ever. The only problem is that it can be quite pricey to purchase every day.

I purchased 3 pounds of green coffee beans, an Ethiopian single origin and the #27 - Los Tumulos, a sweet espresso blend. Choosing a variety can be challenging. However, tasting all of Four Barrel’s single origin’s helped, as I knew that I really preferred the sweeter tasting dry processed beans with a lighter roast.

A helpful YouTube video made the process pretty easy. All you need to get started is a cookie sheet, an oven, and 12 minutes. Sweet Maria’s website also has quite a bit of information on home roasting, way more than you need to get started.

Was 12 mins. and $6 a pound worth it?… heck yes. While it’s not as good (or consistent) as Four Barrel’s… for me it beats Starbucks and Pete’s any day of the week.

Img

Img

Introducing RedScript

After writing in Ruby, Python, C, and CoffeeScript I found that there are quite a few things that I miss when writing JavaScript. CoffeeScript comes close to fulfilling this need but there are a lot of things that I don’t like about it (mostly people being t the very least I hope it sparks some interest to make it better.

At the end of the day, I actually like writing JavaScript. That may seem crazy to some, but there’s something nice about it’s Scheme and Self background. Behind the ugly C syntax, JavaScript’s use of lambda’s and prototypal nature can be rather elegant.

My main goal with RedScript is to let JavaScript’s prototypal nature shine through and make it easier to use prototypes and objects instead of the classical constructor function and new keyword. It should be easy to make to objects inherit from each other… without tons of boilerplate (ala ES5).

RedScript also adds in some sugar with things like arrow functions, do/end block aliases, ruby like comparison operators, automatic bracket insertion, bracket-less while/for/if, and some sugar for ES5 objects.

RedScript is also a superset of JavaScript. This means you can paste in any JS code and it will work as planned, assuming it’s not using any of RedScripts reserved keywords (I’ll implement a linter soon to check for this ahead of time).

Another problem with JavaScript is that we currently do not have native modules. AMD and CommonJS are going to be the interim until ECMAscript.next irons out a native solution. AMD is great for the browser, and I love it extensibility with plugins but the syntax is horrible. Luckily preprocessors can help us out with this. RedScript offers AMD module support by default and has a flag to opt-out if needed. If there is enough demand, some CommonJS sugar may make it it, but I find it very pleasant to use as is (I’m using it in the RedScript compiler).

Some features cannot be implemented right now without lexical analysis and I don’t have enough time to implement a proper parser, lexer and BNF. At the moment, the compiler is just using regular expressions to match and replace certain tokens. Due to this, early versions of RedScript will have some limitations.

Star or Fork the project on GitHub : RedScript
NPM Package Page

Syntax Examples

subject to change
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
define module                                                   define(function() {

options = {                                                       var options = {
  moonRoof: true,                                                   moonRoof: true,
  seats: 5                                                          seats: 5
}                                                                 }

getCost = 16899                                                   var getCost = 16899;
wheels = 4                                                        var wheels = 4;

# export literal compiles to a returned object          
export                                                            return {
  getCost                                                           getCost : getCost,
  hasMoonRoof? from options.moonRoof                                hasMoonRoof_q : options.moonRoof,
  getWheels from wheels                                             getWheels : wheels
end                                                               }
                                                                )};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# define an anonymous AMD module and require dependencies
define module
require 'jquery' as $
require './utils/toolbox' as tb

# Vanilla JS
function sayHello () {
  alert('Hello World!');
}

# Arrow function in a callback
fs.readFile('/etc/passwd', (err, data) ->
  if (err) throw err;
  console.log(data)
});

# Alias @ with this.
model.on('change', @render)

# Function expression
func sayHello                            var sayHello = function() {
  alert("Hi!")                              alert("Hi!");
end                                      };

func sayHello(msg)
  alert(msg)
end

# Private blocks
foo = 200
private
  foo = 10
end
alert(foo)  >>> alerts 200

Hello World

I’ve have finally created a blog! I imagine I will mostly be rambling on about programming, the web, and brewing coffee.