Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Tuesday, June 19, 2007

Erlang Vs Object Oriented

I think that in the future the functional programming community will be at peak. currently I think that the functional communities are too small to beat the Java community.

the functional is easier to any person. any one can write a functional code. Erlang for example has a light VM that can make profit of multiprocessors availability. this doesn't depend on certain compiler that enables parallelism in Java or C.
if you don't care about performance, think about parallelism as simpler way to structure software in a domain where there is a lot of natural concurrency.

I read a paper "Structured Programming Using Processes" in which the author tried to prove that the Erlang was capable to support a personal accounting software application. Maybe you can take a look to it later.

also, I like to point to Yaws, Yaws is a HTTP high performance 1.1 webserver particularly well suited for dynamic-content webapplications. I ma really amazed by its performance.

well, but why Erlang is not widely used till now?
Well the world likes Java. the type safe language. Security in distributed Erlang is “all or nothing,” so when a node is authenticated to another, it can perform any operation.
process isolation is not complete, a process can flood another process with messages, or it can steal all the CPU cycles by entering into an infinite loop.

Saturday, March 31, 2007

RJS Templates for Rails

Ruby on Rails has excellent support for Ajax baked right into the framework. Remote JavaScript (RJS) templates build upon the Ajax support offered by Rails, allow to easily update multiple page elements.
This is a quick start to work with RJS.
$ rails RJS_Example

Create your controller:

RJS_Example> ruby script/generate controller Examples
exists app/controllers/
exists app/helpers/
create app/views/examples
create test/functional/
create app/controllers/examples_controller.rb
create test/functional/examples_controller_test.rb
create app/helpers/examples_helper.rb


Let's modify the default controllers now:
class ExamplesController < ApplicationController 
def index
end
def display
@statement = params[:statement]
end
end

Now, we should go to create our views.
Create in the $RJS_Example/app/views/examples create your index.rhtml
In the header include this tag
    <%= javascript_include_tag :defaults %>

The :defaults helps to add all the Scriptaculous visual effects and controls.

In the body, add this code.
    <%= form_remote_tag :url => { :action => 'display' },
:html => { :id => 'display-form' } %>
<%= text_field_tag 'statement', nil, :size => 40 %>
<%= submit_tag 'submit statement' %>
<%= end_form_tag %>

We use the form_remote_tag() helper instead of the form_tag().
:html option helps to reset the form after completion.
:url option specifies the controller action that receives the form data.
Finally the empty "div id=statement",The id provides a way to reference the element from the RJS template.

Create partial template app/views/examples/_example.rhtml
<%=h example %>

Create the RJS template: app/views/examples/display.rjs
page.insert_html :bottom, 'statements', :partial => 'example'
page.visual_effect :highlight, 'statements'
page.form.reset 'display-form'

The page object is an instance of the Rails JavaScriptGenerator.
the partial template app/views/examples/_example.rhtml is rendered, and the resulting content is inserted into the bottom of the statements div.

Friday, March 30, 2007

Globalize on Ruby-On-Rails

The Globalize is an internationalization and localization plugin for Rails application.
  • Translates both db content and view text.
  • Supports automatic selection of an alternate, localized template for each view.
  • Built-in localization and translation of strftime, numbers, and currency formats.
  • Supports pluralization.
  • All based on three automatically migrated database tables.
It is the best solution to support multi-languages for your rails application.
The globalization wiki is not yet complete. But I think the "Get Started" part is fair enough to help you out making your globalized application, it provides very helpful external links.
  1. Sven’s Globalize Writeup – has many times been refered to as “the best documentation available for Globalize” .
  2. Example Application – takes you step by step through the process of creating a Globalized example application.
  3. Unit-tested Example – a walkthrough using a test-driven approach by Josh Harvey.