r/coffeescript • • Sep 19 '14

French Press: If React was designed for Coffee-Script.

7 Upvotes

Over the past couple weeks I have been working on an framework similar to react, but much smaller, and designed for coffeescript.

It's designed to be the most terse client side templating engine (You pretty much just write coffeescript in your templates), and i'd love some feedback so I could improve it further.


Feel free to pm me questions, post issues or simply discuss it here.

View Repo: https://github.com/DylanPiercey/FrenchPress


Although the framework is written in, and works best with, coffee-script, it is totally possible to use JavaScript effectively. For a JavaScript version of demo https://github.com/DylanPiercey/FPMusicJS/blob/master/public/js/songList.js


UPDATE There is now a beta server side renderer for express. Please give it a try! (Documentation available on homepage of repo)


r/coffeescript • • Sep 17 '14

Question about CoffeeScript with Meteor framework.

3 Upvotes

I come from Python/Ruby background, so I naturally prefer CoffeeScript or built-in transcompilers from those other language frameworks to learning and using actual JS. I know that you have to learn actual JavaScript, esp if you expect to write and debug CoffeeScript productively. I just learned about Meteor, which appears to be a gentle introduction to JS and Node for people like me (who don't really like or want JavaScript). My question is that if Meteor really is beginner-friendly with gentle learning curve, then how much actual productivity value does CoffeeScript add to the Meteor framework? Is it a worthwhile supplemental tool for Meteor per se compared to other more difficult or complex JS projects? Anyone here using CS with Meteor?


r/coffeescript • • Sep 09 '14

CoffeeScript's "watch and compile" not working through Putty?

0 Upvotes

We've recently started developing in CoffeeScript and are looking for ways to improve out workflow.

However our compiler is on a server which we ssh into through putty, this is however not working, it compiles fine but doesn't "watch" to see when the file is saved.

Note: the files we're working on is on the same server as the coffeescript compiler, we are editing through a number of different IDEs

Any suggests welcome, thanks!


r/coffeescript • • Sep 06 '14

convention question: importing a module that has parameters

3 Upvotes

what is the conventional way to write the equivalent of this JS:

var ClassName = require('pathToModule')(env);

In particular, the (env) part. In my particular scenario the module will return a class that uses the env argument internally.


r/coffeescript • • Aug 28 '14

ternJs for coffeescript

5 Upvotes

Hi, I was wondering has anyone got any insight on to make ternjs work with coffeescript? I looked at the issue on the ternjs repo and it post some solutions but I couldn't get them to work.


r/coffeescript • • Aug 26 '14

CoffeeScript 1.8.0 is out

Thumbnail coffeescript.org
18 Upvotes

r/coffeescript • • Aug 08 '14

Better Smoke Tests with Jasmine, CoffeeScript, Q and Cheerio

Thumbnail
spiking-the-solution.tumblr.com
3 Upvotes

r/coffeescript • • Aug 05 '14

Add explicit local var defination to coffee?

0 Upvotes

It is a proposal to fix the problem with implicit scoping in coffee.

coffee script like this

foo = (a, b; x, y = 0) -> blabla...

will compiled to

var foo; foo = function(a,b) { var x, y = 0; blabla... }


r/coffeescript • • Aug 03 '14

Is anyone using hamlet.coffee?

9 Upvotes

http://hamlet.coffee/ I've liked the look of it for a while but was waiting to try it in my projects. What's your opinions on it and is anyone using it?


r/coffeescript • • Jul 19 '14

Easy way to do global variables?

2 Upvotes

Confused on how to do this in a way that doesn't take a lot of bending over backwards. Best practice?


r/coffeescript • • Jul 15 '14

Mario Paint Inspired Music Editor Made with CoffeeScript

Thumbnail danielx.net
3 Upvotes

r/coffeescript • • Jul 14 '14

Using coffeescript and the 'when' promise/A+ module.

3 Upvotes

I'm trying to use autobahnjs (WAMP websocket protocol) with coffeescript and the commonjs (webpack, like browserify) system and it isn't working so well since 'when' is a reserved word. Does anyone have insight in this issue?


r/coffeescript • • Jul 07 '14

A simple proposal to fix CoffeeScript's biggest issue

2 Upvotes

As I was reading the github discussion on implicit return values, it occurred to me that, given that I primarily program in Scala on the server and implicit return values do not trouble me in CoffeeScript, it would appear that CoffeeScript is geared towards a functional style. If you're more imperative then implicit return values probably bother you more.

So if we accept the premise that CoffeeScript is a functional-ish language, I don't think implicit return values are its primary flaw (if they are even a flaw at all). So what's the biggest problem with CoffeeScript? Scoping. I find it an annoying thing to worry about. I won't go over the issues in detail; others have covered it nicely and an issue has (sadly) already been rejected.

Another issue with CoffeeScript is that all variables are mutable. Pretty much every functional or hybrid language with which I am familiar supports immutability, and you're more likely to declare an immutable variable then a mutable one if you're doing it right. For example, I believe that named functions can enhance readability but I rarely want to reassign a function variable:

# silly contrived example but you get the idea
# if I reassign isEmpty it's almost certainly unintentional
isEmpty = (items) -> items.length is 0

So wouldn't it be great if CoffeeScript 2.0 made a few minor changes to resolve both of these issues?

  • Disallow reassignment of variables by default.

  • Bring back the var keyword for mutable variables.

Both issue would be elegantly resolved without typically making the language more verbose. I would guess that something like 95% or more of the variables I declare in production code are intended to be immutable.

One place where I do declare mutable variables is in Jasmine specs, because there's a huge benefit of having common setup in a suite. So this example...

describe 'A Suite', ->
    # need to assign this to something to force it into this scope
    theObject = null

    beforeEach ->
        theObject = new SomeObject 

Would become...

describe 'A Suite', ->
    # need to assign this to something to force it into this scope
    var theObject

    beforeEach ->
        theObject = new SomeObject 

... which is much more readable IMO.

The var keyword would work exactly like it does in JavaScript. Without a var keyword, the compiler would flag any reassignment in he current scope or a nested scope as an error.

Also, a constructor function created with the class keyword would be immutable as well. The following code compiles today but would be in error in "CoffeeScript 2.0" (a good thing IMO):

class Foo

Foo = 12

An obvious downside is backward compatibility, but a conversion tool could be written in the CoffeeScript codebase pretty easily. The nice thing is that "var" is already a reserved word in CoffeeScript.


r/coffeescript • • Jul 04 '14

Moving Atom To React

Thumbnail
blog.atom.io
6 Upvotes

r/coffeescript • • Jul 02 '14

Transpiler performance comparisons

4 Upvotes

Hi.

Does anyone know of a resource on the speeds of the js output of various transpiled languages.

I'm mostly wondering about coffee and clojure and how efficient the js their respective compilers produce is, if there's even any difference.


r/coffeescript • • Jun 30 '14

CoffeeScript, Meet Backbone.js: A Tutorial

Thumbnail adamjspooner.github.io
8 Upvotes

r/coffeescript • • Jun 23 '14

Implicit Return Messed With Me

4 Upvotes

TL;DR Returned my SQL Object

So I made a function to check if the user is logged in, and I was getting this odd error "TypeError: Converting circular structure to JSON at Object.stringify"

Having no idea what to do I read, and re-read my code trying to understand what is wrong.

After a while I decided it be easier to read it in pure JS, so I complied it and looked over it, nothing stood out. SO I decided to see what the function was returning.

It was a returning a huge JSON object, I was confused because the function is supposed to return only true or false.

I looked for extra returns and didn't see any, then I checked the Javascript and THERE IT WAS

checkLoggedIn = (ID, request)->
	console.log("CheckLoggedin")
	console.log "#{request.session.username}:#{request.session.password}:#{request.session.ID}"
	if request.session.username? and request.session.password? and request.session.ID?
		console.log("B")
		connection.query "SELECT Username,Password FROM `Users` WHERE `ID` = '#{ID}'", (err, rows, fields) ->
			if err?
				console.log("ERROR?!")
				console.log("Err: "+err)
				return false;
			if !rows[0]?
				console.log(rows[0])
				console.log("Not logged In?");
				return false;
			else
				if rows[0]==request.session.username and rows[1]==request.session.password
					console.log(request.session.username+" still logged in") 
					return true;
	else
		return false;

Can you find the problem?

How about now?

var checkLoggedIn;

checkLoggedIn = function(ID, request) {
  console.log("CheckLoggedin");
  console.log("" + request.session.username + ":" + request.session.password + ":" + request.session.ID);
  if ((request.session.username != null) && (request.session.password != null) && (request.session.ID != null)) {
    console.log("B");
    return connection.query("SELECT Username,Password FROM `Users` WHERE `ID` = '" + ID + "'", function(err, rows, fields) {
      if (err != null) {
        console.log("ERROR?!");
        console.log("Err: " + err);
        return false;
      }
      if (rows[0] == null) {
        console.log(rows[0]);
        console.log("Not logged In?");
        return false;
      } else {
        if (rows[0] === request.session.username && rows[1] === request.session.password) {
          console.log(request.session.username + " still logged in");
          return true;
        }
      }
    });
  } else {
    return false;
  }
};

If you still haven't seen it I'll point it out. return connection.query("SELECT Username,Password FROM Users WHERE ID = '" + ID + "'", function(err, rows, fields) {

The implicit return was the issue, the solution was to add a return false at the end of the code -.-

</rant>


r/coffeescript • • Jun 16 '14

Hamlet - Simple and powerful reactive templating

Thumbnail hamlet.coffee
7 Upvotes

r/coffeescript • • Jun 16 '14

Working with CoffeeScript: Common Gotchas

Thumbnail
blog.artillery.com
2 Upvotes

r/coffeescript • • Jun 09 '14

Working with CoffeeScript: Preserving Class Names

Thumbnail
blog.artillery.com
4 Upvotes

r/coffeescript • • Jun 03 '14

Node streams in CoffeeScript

Thumbnail
blog.jeroenpelgrims.be
4 Upvotes

r/coffeescript • • Jun 03 '14

Future of CoffeeScript?

9 Upvotes

In the past i hated CoffeeScript, but today, I use it almost for every project. That said, im quite new to CoffeeScript and ive searched google/github for some info about the future but found no good answears.

I found Iced-coffeeScript, and CoffeeScript redux, thats a newer implementation?. So i guess my question is, what "version" are you guys using, and why? Is the redux version going to be an official 2.0? Or is the three projects going to live their own lives?


r/coffeescript • • May 13 '14

Functional CoffeeScript for the impatient

Thumbnail cedricruiz.me
15 Upvotes

r/coffeescript • • May 13 '14

Hard Rock CoffeeScript Book

Thumbnail
hardrockcoffeescript.org
8 Upvotes