O documento discute diferentes linguagens de programação, comparando suas características de poder expressivo, concisão e outras qualidades. Vários pontos de vista são apresentados sobre o que buscamos em uma linguagem ideal e como as necessidades variam de acordo com o contexto. A conclusão é que não existe linguagem perfeita e as ferramentas mudam com o tempo.
14. Java
List<Categoria> categorias = new
ArrayList<Categoria>();
for(Produto p : produtos)
categorias.add(p.getCategoria());
for(int i=0;i<categorias.size();i++) {
Categoria c = categorias.get(i);
if(categorias.lastIndexOf(c)!=i) {
categorias.remove(c); i--;
}
}
double total = 0;
for(Produto p : produtos) {
total += p.getValor();
}
15. Java
List<Categoria> categorias = new
ArrayList<Categoria>();
for(Produto p : produtos)
categorias.add(p.getCategoria());
for(int i=0;i<categorias.size();i++) {
Categoria c = categorias.get(i);
e,
t
if(categorias.lastIndexOf(c)!=i) {
n !
categorias.remove(c); i--;
e s
m ai
}
} l
a m
double total = 0;
e e
r d
for(Produto p : produtos) {
}
total += p.getValor(); é
29. Java
Set categorias = new HashSet();
for(Produto p : produtos) cat.add(p.categoria());
double total = 0;
for(Produto p : produtos) total += p.valor();
91. def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
fonte pequena?
92. def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
agora sim? fonte 16
94. 23...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
95. 23...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
96. mas e se... 23...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
97. mas eese...
mas se... 23...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
98. mas eese...
mas ese... 23...
mas se...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
99. mas eese...
mas ese... 23...
mas ese...
mas se...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
100. mas eese...
mas ese... 23...
mas ese...
mas ese...
mas se...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
101. mas eese...
mas ese... 23...
mas ese...
mas ese...
mas se...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
102. mas eese...
mas ese... 23...
mas ese...
mas ese...
mas ese...
mas se...
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
value = @attributes[attr_name]
unless value.nil?
if column = column_for_attribute(attr_name)
if unserializable_attribute?(attr_name, column)
unserialize_attribute(attr_name)
else
column.type_cast(value)
end
else
value
end
end
end
120. ‘Quando quebra o projeto em vários,
fica mais fácil de ver que para uma
parte do projeto
uma
linguagem é
mais
interessante’
Alberto (oderski) Souza
121. require "sinatra"
require "json" interestie
Sequel.connect ENV["DATABASE_URL"]
require "interest"
get "/" do
interest = Interest.new params[:interest]
interest.save ? ok_response params : error_response params
end
def ok_response(params)
respond_with params
end
def error_response(params)
respond_with(params, {
errors:["unable to set up interest"]
})
end
def respond_with(params, json_data = {ok:"ok"})
"#{params["callback"]}(#{json_data.to_json})"
end
122. require "sinatra"
require "json" interestie
Sequel.connect ENV["DATABASE_URL"]
require "interest"
get "/" do
interest = Interest.new params[:interest]
interest.save ? ok_response params : error_response params
end
def ok_response(params)
respond_with params
end
def error_response(params)
respond_with(params, {
errors:["unable to set up interest"]
})
end
def respond_with(params, json_data = {ok:"ok"})
"#{params["callback"]}(#{json_data.to_json})"
end