nunojob:~ dscape/08$ echo The Black Sheep

Posts tagged ‘Java’

Cuidado com os tigres

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!

Advertisements

Wouldn’t ANTLR be better if written in a dynamic language?

I think making a tool like ANTLR is a non-dynamic language is a shot in the foot!

It just makes sense to use dynamic languages to create meta-language tools. Would facilitate the work of the developer and of the ones writing grammars taking away all that java trash that helps in nothing to make out stuff work. ANTLR is great, but all the negative aspects (from end-user point of view) arise from the fact of having all that unnecessary information and needing to declare types and other stuff that ARE NOT NATURAL for a grammar to have. And the way it’s implemented in Java is just a way of copying the way (bad) dynamic languages work.

grammar Expr; 

options {
  output = AST;
  ASTLabelType = CommonTree;
} 

prog
     : ( stat
         { System.out.println( $stat.tree.toStringTree() ); }
       )+
     ;

stat
     : expr NEWLINE -> expr
     | ID '=' expr NEWLINE -> ^('=' ID expr)
     | NEWLINE ->
     ; 

expr
     : multExpr ( ( '+'^ | '-'^ ) multExpr )*
     ;

multExpr
     : atom ( '*'^ atom )*
     ;

atom
     : INT
     | ID
     | '('! expr ')'!
; 

ID
     : ( 'a'..'z' | 'A'..'Z' )+
     ;

INT
     : '0'..'9'+
     ; 

NEWLINE
     : '\r'? '\n'
     ; 

WS
     : ( ' ' | '\t' | '\n' | '\r' )+
       { $channel=HIDDEN; }
     ;
grammar Expr; 

options {
  output = AST;
} 

prog
     : ( stat
         { puts $stat.to_tree }
       )+
     ;

stat
     : expr NEWLINE
     | ID '=' expr NEWLINE -> ^ // mark the root somehow
     | NEWLINE
     ; 

expr
     : multExpr ( ( '+'^ | '-'^ ) multExpr )*
     ;

multExpr
     : atom ( '*'^ atom )*
     ;

atom
     : INT
     | ID
     | '('! expr ')'!
; 

ID
     : ( 'a'..'z' | 'A'..'Z' )+
     ;

INT
     : '0'..'9'+
     ; 

NEWLINE
     : '\r'? '\n'
     ; 

WS
     : ( ' ' | '\t' | '\n' | '\r' )+
       { skip }
     ;

Just wish I had the time to implement it in Ruby and prove my point! Maybe in the masters thesis..

By the way, the ANTLR Book is great. If you want to learn about grammars and creating DSL’s you will love it. But be advised, you’ll hate the java trash that comes with it.

By the way Google changed their icon.

But once again, who gives a fuck? I sure don’t.

Java 6 for Mac OS X Leopard is here!!

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

More on this here.

Primeiro contacto com programação por parte dos alunos do ensino superior

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?

  1. É 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.
  2. 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.
  3. 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.
  4. 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

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, Java ou C#?

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

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

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:

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 ;)

  1. 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.0x82.com/2007/12/mac-os-and-usb-mouse.html

  2. 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

    
    
  3. 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.

  4. 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.

  5. 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.

  6. How can I see the right mouse button menu?

    crtl + mouseclick

  7. 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! :)