Showing posts with label ECMAScript. Show all posts
Showing posts with label ECMAScript. Show all posts

Tuesday, October 16, 2012

SublimeText syntax definition file for TypeScript and for F#

(1) For TypeScript

  1. Download zip file from here
  2. Unzip to "%APPDATA%\Sublime Text 2\Packages"
In here, syntax file for vim and for Emacs also exist.

(2) For F#

  1. make and change directory to "%APPDATA%\Sublime Text 2\Packages\FSharp"
  2. git clone http://github.com/hoest/sublimetext-fsharp .

Thursday, October 11, 2012

TypeScript's interface looks like F#'s record

TypeScript is a superset of ECMAScript5 by Microsoft. And Microsoft is aiming to make some TypeScript syntaxes as ECMAScript6 specification (check the specification document). Like as coffee script syntax is similar to Ruby syntax, TypeScript syntax is similar to C# syntax. But, its interface syntax is similar to F# syntax, not C# one.

TypeScript's interface
interface Person {
    firstname: string;
    lastname: string;
}

function greeter(person : Person) {
    return "Hello, " + person.firstname + " " + person.lastname;
}

var user = {firstname: "Jane", lastname: "User"};

document.body.innerHTML = greeter(user);

F#'s record
type Person =
    { firstName : string;
      lastName : string }

let greeter (person:Person) = sprintf "Hello, %s %s" person.firstName person.lastName

let user = {firstName = "Jane"; lastName = "User"}

greeter user |> System.Console.WriteLine

Of course, these are entirely different classses and types. These just looks like similar.

Friday, October 21, 2011

make unobtrusive CoffeeScript on AWDwR 4th beta chapter15

On Agile Web Development with Rails 4th edition beta chapter15 (Internationalization), there is one more stuck point not-related with internationalization. In this chapter, JavaScript sample is not unobtrusive one. So I try to rewrite the sample with unobtrusive CoffeeScript.

application.js and application.html.erb

In this tutorial, we should use CoffeeScript only store.js.coffee. So we can omit to use another *.js.coffee files.
  1. In application.js file, delete the line //= require_tree ..
  2. In application.html.erb file, add the line <%= javascript_include_tag "store" %>.

make unobtrusive

In store.js.coffee, write the code for erase submit button and execute the action when drop down list is changed.
$ ->
  $('.locale input').hide()
........
$ ->
  $('#set_locale').change ->
    $(this).parent('form.locale').submit()
so that we just write the drop down list in layouts/application.html.erb like below:
    <%= form_tag store_path, class: 'locale' do %>
      <%= select_tag 'set_locale', options_for_select(LANGUAGES, I18n.locale.to_s) %>
      <%= submit_tag 'submit' %>
    <% end %>

Tuesday, October 4, 2011

Two .js templates in Rails 3.1

In Rails 3.1, there are two JavaScript templates - the one is 'app/views/**/*.js.erb', the other one is 'app/assets/javascripts/*.js.coffee'. What are these? And how different are these?

In short, 'app/views/**/*.js.erb' is bare jQuery with ERb template, and 'app/assets/javascripts/*.js.coffee' is CoffeeScript file.

In more detail, 'app/views/**/*.js.erb' is written for the response of Ajax request, both with bare jQuery and with ERb. 'app/assets/javascripts/*.js.coffee' is written for another scripts with CoffeeScript when the page is loaded. And then, 'app/assets/javascripts/*.js.coffee' is compiled to jQuery by server-side JavaScripts (e.g. node.js).

Saturday, September 17, 2011

AWDwR 4th beta is ready for Rails 3.1

As you may know, Agile web development with Rails(a.k.a. AWDwR) becomes ready for Rails 3.1. In other words...
  • Now the edition of AWDwR is 4th beta. And its e-book becomes ready for Rails 3.1 and Ruby 1.9.x.
  • It's good entry book for starting Rails 3.1 with Ruby 1.9.x.
  • It's also good book for starting Sass and CoffeeScript.

Of course, I'm reading this e-book.

Monday, September 12, 2011

Two tips for installaing Rails 3.1

About two weeks ago, Ruby on Rails 3.1 had been released. I found there are two tips for installation - compared with the previous version.

You should install node.js

Ruby on Rails 3.1 needs server-side ECMAScript because some gems of Rails 3.1 need it - CoffeeScript and sass. So you should install node.js. Especially, I recommend it for windows user because node.js provides windows binary.

You could uninstall abstract gem

Ruby on Rails 3.1 needs erubis 2.7.0, And this version of erubis is noe depending on abstract gem despite erubis 2.6.x depends it. So you could uninstall abstract gem if you upgrade Rails from 3.0.x.

Saturday, December 19, 2009

Qt 4.6's ECMAScript

I forgot to write about ECMAScript changes in phosphorescence: Qt Conference - Tokyo 2009.

Until Qt 4.5, QtScript and QtWebkit have each implementation of ECMAScript engine. But from Qt 4.6, these are unified to QtWebkit's one - JavaScriptCore from Webkit.

Tuesday, October 20, 2009

Gestalt and Moonlight

I learned 'Gestalt' recently - that is browser-side Ruby/Python/XAML scripting (instead of ECMAScript) driven with jQuery and Silverlight. Is that the product only for Windows? No! Gestalt supports not only Silverlight but also Moonlight.

I try to run sample bundled with Gestalt onto the Firefox on the my openSUSE.
  1. Install Firefox add-on of moonlight from here
  2. Download the zip of Gestalt from here
  3. Uncompress the zip of Gestalt
  4. Open the XAML sample files Gestalt/samples/getting.started/03_xaml.html, Gestalt/samples/getting.started/04_animation.html and Gestalt/samples/getting.started/05_final.html
If Gestalt/samples/getting.started/03_xaml.html succeeded, Firefox renders like below:

But samples of Ruby or Python didn't work in intact. I guess it's suspicious that Moonlight on the openSUSE 11.1 is 1.0, not 2.0 even though Firefox add-on of moonlight is 2.0 beta.