I do NOT plan to introduce CoffeeScript or sell you CoffeeScript like a used car salesman! Instead, breeze through VS 2010 setup, review some code examples and provide a list of resources ( web casts, books, blogs, and tools ) to help educate and convince yourself CoffeeScript is meaningful. I will briefly explain what CoffeeScript is and list a few benefits. In a future post I will discuss what IcedCoffeeScript brings to the table.
What is CoffeeScript?
Advantages of CoffeeScript
- Repeatability and consistency
Disadvantages of CoffeeScript
- Learning curve?
- Difficult to debug?
Visual Studio 2010 Setup
- Download the plug-in here
- Ensure you are not running Visual Studio 2010. If so, close the IDE.
- Double click the Mindscape.WebWorkbench.Integration.10.vsix file you downloaded in step 1
- Open Visual Studio 2010
- Navigate to Tools –> Extension Manager
- You should see Mindscape Web Workbench.
- Open Visual Studio 2010.
- Create a new blank solution called coffeeScript.demo
- Add a new ASP.NET MVC 3 project to the solution
- Click on the Scripts directory
- To add a new text file press Ctrl+Shift+A
- Select Text File
- Rename the file to demo.coffee and create
- In the Solution Explorer expand the demo.coffee file and observe the demo.js file
- Open the demo.coffee and demo.js files
- Paste the following code
- Save demo.coffee file
- Notice demo.js now contains the code below.
1 2 3 4 5 6
- Write in CoffeeScript
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
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 35 36 37 38 39 40 41 42 43 44 45
Feast your eyes on this beautiful code! The formatting, spacing, perfectly placed curly braces, semi-colons, tabs, and no extra white spaces. There is no mixed up tabbing, spacing or extra white space. This code will be perfect every time! While you could argue with the meat of the code you can not with the formatting.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
Where To Next?
In a future post I will talked about IcedCoffeeScript.
IcedCoffeeScript is a fork of CoffeeScript. It is superset of the CoffeeScript language. The iced interpreter is a drop-in replacement for the standard coffee interpreter since it will interpret all existing CoffeeScript programs.
For now review the web casts, books, blog articles, and tools reference for your convenience below.
- Listen to our Herding Code interview: Herding Code 114: Trevor Burnham on CoffeeScript
- Head over to Tekpub Meet CoffeeScript from PeepCode.com
- The Little Book on CoffeeScript
- Case For Using CoffeeScript
- Exploring CoffeScript Part I- And Then There Was Coffee
- CoffeeScript Intervention
- Vriables and Functions
- Classes in CoffeeScript
- Scott Hanselman talks in detail about Mindscape Web Workbench
- JQuery UI Examples in CoffeeScript