Cuidado com os tigres
June 15, 2008
Mais uma excelente talk do Steve Yegge.

Scala, now, is the tiger that’s going to kill Java. Because their [type-talisman] argument now has become a paradox, similar to the Paul Graham Blub Paradox thing, right? Because they’re like, “Well, we need static typing in order to engineer good systems. It’s simply not possible otherwise.”
The Scala people come in and they go: “Your type system suuuuuucks. It’s not sound. It’s not safe. It’s not complete. You’re casting your way around it. It doesn’t actually prevent this large class of bugs. How many times have you written
catch (NullPointerException x) ...in Java? Our type system doesn’t allow [things like] that.”Our type system does what you said your type system was doing.
So, therefore, you should be using it! ∴
And the Java people look at it and go: “Wehellll… (cough cough)… I mean, yeah, I mean… (*ahem*)” (running finger under collar, as if sweating profusely) They say, “Welllll… you know… it’s awfully… cummmmmbersome… I…”
“We can actually get around the problems in practice that you guys say your type system is solving through Good Engineering Practices.”
(laughter begins to grow)
HA!!! (I point accusingly at the audience, and there’s more laughter)
Yeah.
So Scala is creating a real problem for [Java's] static typing camp now. Because their last little bastion of why they’re using it, the whole tigers argument, they’re like, “Ah, well… we… we keep shotguns in our house.” [This is what they've been reduced to.]
OK? Yeeeeahhhh…
So back to dynamic languages!
Java 6 for Mac OS X Leopard is here!!
May 1, 2008
In the most impressive development of the week I have just discovered that Java 6 was finally released for Mac OS X. I’m in complete disbelief.
Now I almost believe that IBM DB2 Express-C for mac will be released in less that a month. :P

Qual deve ser a linguagem de programação que serve de introdução ao seu curso superior de informática? Para mim a resposta não podia ser mais evidente: Haskell.
Pelo que sei no ISEP a primeira coisa que se aprende é Java, o que acho chocante. Afinal o paradigma de programação orientada aos objectos é vastíssimo e ensinar alguém a programar em Java sem estes conhecimentos por trás parece-me de uma irresponsabilidade incrível. Isto após uma reestruturação que ocorreu o ano passado! Pode-se alegar que o ISEP tenta formar profissionais que sejam absorvidos o mais rapidamente possível pelas empresas, que não se pretende formar investigadores. Mas, na minha opinião pessoal, existem coisas que são base para um licenciado em informática. Têm que conhecer os paradigmas de programação que existem pelas valias que eles oferecem e não pelo facto da sua sintaxe ser mais ou menos acessível. Como me parece evidente que qualquer informático deve saber estruturas de dados e algoritmia. São as ferramentas base com que trabalhamos diariamente e por muito que as empresas queiram monos lá a trabalhar a “chapar” código têm que existir algo que diferencie esse mono de um pedreiro. Senão para que o canudo?

Mas e porque Haskell?
- É uma linguagem funcional. Os problemas são entendidos como problemas matemáticos, o que permite aos alunos quebrar com a pre-formatada ideia que programar é deve ser seguindo o paradigma imperativo.
- A maneira de pensar nesta linguagem é diferente. Dijkstra disse que “It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”. Aposto que ele diria o oposto sobre Haskell. É difícil ensinar mal alunos que começam por aprender/gostar de Haskell.
- Ao aprender os vários paradigmas o aluno torna-se mais versátil. Começando por Haskell certamente que não vai ver todos os problemas de uma forma imperativa. Esta forma diferente de pensar vai-lhe permitir, no futuro, a mais valia de saber escolher o método mais apropriado para resolver um problema que se depare no futuro. Pode na altura não usar Haskell mas vai-se lembrar dos mecanismos que aprendeu e da forma, correcta, que aprendeu para resolver problemas.
- As outras vantagens do Haskell: Esquema de recursividade extremamente simples, Strongly Typed, Lazy Evaluation, Elegância do código.
Atrevo-me até a dizer que podem dizer mal do Haskell em tudo que quiserem menos que é mau como ferramenta de ensino. Para isso, é simplesmente divinal.
Se quiserem ver uma melhor resposta a esta pergunta Why Haskell podem ler este artigo no Good Math, Bad Math. E caso queiram espreitar um pouco de código podem visitar (e rir-se um bocado com) este The Evolution of a Haskell Programmer.
Crescimento do emprego em Ruby
January 26, 2008
As coisas em Portugal costumam demorar a chegar ao ponto que estão nos states. Basta ver que a maioria das propostas que vejo por cá são em Visual Basic (hein?). De qualquer forma convido-os a ver estes gráficos a tirarem as vossas próprias ilações:

Ruby on Rails, PHP ou ASP.NET?

Será que alguma vez as empresas de portugal iram estar um passo a frente em vez de vinte passos atrás? Não me parece mas, uma pessoa pode sempre sonhar!
Creating a User Interface for XML Schema using xForms
January 5, 2008
We use XSLT all the time to convert a XML document into another format. XML Schemas are XML documents and I think it would be interesting to create the user interface and model for that specific schema using xForms. This would drastically decrease development time and would allow a quick view on what that XML Schema is all about. In other words, this would do for xForms what JAXB does for Java.
Why xForms? xForms is W3C recommendation for creating user interfaces and it’s based on the MVC pattern. This is enough to convince me, I’m all for standards.
While researching I found some works on this subject [here, here] but they are mostly on conference proceedings and therefor I thought no one had really implemented a Generic Schema to xForms transformation engine. Before giving up I asked Vítor Rodrigues about this, as IBM is know for their XML Alphaworks. Guess what? Now I have the solution.
Here’s what you need create an xForm from a Schema:
- Download Eclipse WTP
- Open Eclipse and browse to Help > Software Updates > Find and Install
- Click New Remote Site
- Name: Emerging Technologies Toolkit (ETTK) Updates
URL: http://awwebx04.alphaworks.ibm.com/ettktechnologies/updates - Select it and click Finish
- Now select Emerging Technologies Toolkit (ETTK) Updates > Emerging Technologies Toolkit – Technologies > Visual XForms Designer
- Click next.
- Accept the license, install the software and restart eclipse.
Now for the Visual XForms Designer I made a little screen-cast. Just click here to see it.
From Ubuntu/Windows to Mac OS-X Leopard
December 25, 2007
I just got my first brand new MacBook and, as one would expect, some problems emerged by leaving my usual OS combo (Ubuntu/Windows) for Mac OS X Leopard. I’m still undecided whether to install Ubuntu or use VMWare Fusion to use Linux. As for Microsoft Windows as long as I don’t need to use .NET I don’t think I’ll install it. Not even with the free licenses Microsoft provides University of Minho students.
First I had to decide what to install:
- Firefox
- del.icio.us UNSAFE add-on for Firefox
- Portuguese Dictionary add-on for Firefox
PidginAdiumNeroToast Titanium- Office
- Photoshop
- TextMate
- Ruby on Rails
- Java SDK
- Netbeans
- Glassfish
- GHC
- Erlang
- MacTex
- oXygen
- BookPedia
- DB2 (will IBM make it available for mac anytime soon?)
The question you are probably asking is why Firefox instead of Safari!? Because the damn unsafe add-on for del.icio.us is just that: del.icio.us! I just can’t live without it. Maybe if the guys over there worked the basics of security we could say that it’s both excellent and safe! And don’t say there’s a add-on for Safari as well. I’ll only accept it if the add-on is as good as the one provided by Yahoo.
Now we go for the fun part. The problems and solving them. Your attention please, this is only fun for me when I do it on my computer so it won’t be pleasure if you ask me to fix your computer! Joana this one is for you, I know how your mind thinks.. Almost as badly as mine. Oh well, we are related aren’t we? :\ Please release those crazy Christmas photos to the world! :X
I’ll start with a small OS free tip and then go for the Q/A part. If you are Portuguese like myself you just hate all the results that google gives you from .br domains. Most of the results are overrated and most of the times you just wish that they weren’t there. If this is the case just do your normal search in google but write -br in the end. Just test this, go to google and type governo brasileiro -br. It works ;)
-
How do I get my mouse to behave like a normal one by removing this dreadful acceleration?
Easy. Check Rúben’s blog @ http://blog.0×82.com/2007/12/mac-os-and-usb-mouse.html
-
What’s wrong with the encoding on TextEdit? The automatic descovery does not work and even when I specifically tell him to use this encoding it won’t work. The Where is ISO 8859-15 dilemma.
Still don’t know. Anyone? If you want to test the bug just do this (from here):$ echo é > ~/a.txt
$ cat ~/a.txt
é
Open a.txt with TextEdit and get:
ÈCracked it! At least I have a partial fix for Migrating documents from Ubuntu to Mac OS X Leopard:
cmd + space terminal enter
{go to the directory where the file is}
bash$ iconv -f ISO-8859-15 -t UTF-8 {filename} > UTF8-{filename}For me it was:
bash$ iconv -f ISO-8859-15 -t UTF-8 Pam.tex > UTF8-Pam.tex
And yes PAM is as in Pluggable Authentication Modules. So I have a latex work on that :P
-
Where is type-a-name application? It’s not on the dock.
Just press cmd + space and type what you are looking for. This is called spotlight. Either this or open Finder and go to applications.
-
Why doesn’t it show my dashboard when I go to the left/whatever corner?
Have you even configured your mac? Common.. Click the apple on the top left corner and go to System Preferences. Exposé and Spaces. And now that you are there take a look around and configure all the other things that you neglected.
-
This computer is always underlining the words in red. (when the spelling is right :P If not you are a dumbass for asking this!)
Just press cmd + mouse and change the language. Thanks Nuno Veloso from Apple Tech Team for this tip.
-
How can I see the right mouse button menu?
crtl + mouseclick
-
PageUp/PageDown!?
fn+ up
fn + down
If after this you still feel like reading about Mac OS for rookies – like myself – you can check this section in Arun Gupta’s Blog or check this extensive list of Keyboard Shortcuts. Have fun!
Now let’s get back to work, something almost impossible when your doing a report on LaTeX and the encodings are never right.
One final touch: ctrl + alt + cmd + 8. Merry Christmas! :)
Ruby on Rails vs Java
December 18, 2007
Com a popota é uma risota
December 16, 2007
Bem lá vou eu ver como é o mundo do glassfish. Depois de uma não tão boa experiência com o JBoss, onde os ficheiros de configuração parecem milhares, talvez desta vez corra melhor. Fiquem então com a diva do natal, popota.
[EDIT: Podem ver este Free Java EE Course. Parece porreiro.]
E ignorem a parte do modelo :P
Ornatos Violeta – Deixa Morrer
December 10, 2007
Para quem estava interessado no tema anterior deixo-vos as sources do livro Beginning Cryptography with Java. Pelo menos usa bibliotecas de uso livre (bouncycastle). Quando acabar o trabalho disponibilizo-o neste post. É com muita pena minha que tenho que comunicar que o livro não está disponível na biblioteca da Universidade do Minho.
[EDIT: Código fonte disponível aqui]
E agora a minha música favorita de uma banda que muita falta faz no panorama musical português. Ornatos Violeta, claro!
Não nos deixei mentir e agora tanto faz. Vou dar o mundo a quem!?
Diffie-Hellman Java Implementation
December 2, 2007
Diffie-Hellman is a cryptographic key agreement algorithm that allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure communications channel. This key can then be used to encrypt subsequent communications using a symmetric key cipher.
![]()
We were asked at cryptography classes to develop such algorithm using the core java libraries. I made a little test – I think they call it jUnit – to prove that both famous Bob and infamous Alice share the same dirty little secret.. :)Source: http://nunojobpinto.googlepages.com/diffie-hellman.zip[EDIT: As Ruben pointed out Diffie-Hellman is vulnerable to man-in-the-middle attacks. This is a purely academic work and - despite the brilliance of the response - is not intended to be used as is. If you want to learn more about this maybe you should read about station-to-station and certificates. In Portuguese you can use the resources given to cryptography masters students at University of Minho]Also if your using Netbeans IDE 6 you are probably noticing that the themes SUCK. I don’t even mean this as it’s not eye-candy, I really mean they hurt the eyes and I am already using glasses due to the overwhelming amount of time I spend at my laptop.To surpass this I advise you to download these files:
- http://mediacast.sun.com/share/tor/org-netbeans-modules-ruby-themes.nbm
- http://www.ibrasten.com/com-superruby-netbeans-themes-fadetogrey.nbm
Now open your very own Netbeans IDE – wait 10 minutes for it to start – and then go to:
- Tools -> Plugins -> Downloaded -> Add
Now add the two files you have just downloaded and change the theme in Tools -> Preferences and you are ready to go.
As voltas com os estudos
November 14, 2007

Acho que já se notou que não andava muito feliz com o mestrado. Como se costuma dizer, quem está mal que se mude. Foi o que fiz.
Troquei a unidade curricular de especialização de Análise e Concepção de Software pela de Criptografia e Segurança de Sistemas de Informação.
Primeiro aula (para mim claro) andamos as voltas com o JBoss. A conclusão que cheguei foi que no meio de tantos xmls de configuração qualquer um se perde e mais vale usar o Apache Tomcat! Será que não aprendem com o Ruby on Rails? Convention Over Configuration! :P Não gostei muito da forma como se criam estes webservices. O facto de termos que andar com ficheiros de configuração para trás e para frente (cliente/servidor), sermos quase obrigados a programar em Java. Era bem mais fixe se estes webservices servissem xml como respostas a pedidos, por exemplo, e que depois fossem enclapsulados numa classe de forma a responder para cada linguagem de programação. Não que perceba nada disto, ainda estou muito verdinho.
De qualquer forma fica um pedido. Se alguém conhecer um bom guia para iniciantes em JBoss diga qualquer coisa. A gerência agradece!
Life on the rails
September 23, 2007
I found Ruby in a talk with one of my friends. We were talking about how a problem that can be solved in Haskell in one line of code, could take hundreds to do so in Java or C#. It was obvious that, for some specific problems, Haskell was simpler and adequate.
Want a sample? Code permutation with n levels in C.
perms xs 0 = [[]]
perms xs n = [ p : ps | p <- xs, ps <- perms xs (n - 1)]
And like this he introduced me to Ruby on Rails. I was very thrilled to see a language that is dynamic, object oriented and adequate for web developing. I immediately thought about learning it, I just love learning new languages.
Today I checking my feeds and found a post about seven reasons to switch back to PHP (from Ruby).
It seems Ruby is like Haskell: the code looks greats and promises a lot, but it still doesn’t get where imperative languages do. (I’m still going to learn it, I just can’t resist it)
For now I’m waiting for a language that joins all that is good from imperative, functional, logic and object oriented paradigms.
If you know such programming language leave it as a comment.
|
PHP $61,000 |
|
|
Ajax $76,000 |
|
|
Ruby $70,000 |
|
|
Java $77,000 |
|
|
C# $78,000 |
|
|
Haskell $52,000 |





