SOAB IDEA

I was preparing a sketch-of a solution for the assignment I’m going to give to the students in OOP. It’s a Java program, so I used IntelliJ IDEA. The following piece of code had a warning sign on it:

System.out.printf("0, %s, %s, %s, %d\n",
  reg.getUsername(), reg.getFirstName(), reg.getSurname(), reg.getSalary());

The warning was: “format string does not match the types of its arguments.”

The reason: “getSalary()” returns float, not an integer, so the last arg should be “%f” and not “%d”.

Son Of A Bitch! That cocky IDE watches over my format strings!

The next logical step, I suppose, is to do SQL syntax check to query strings, and then warn against SQL injection attacks (a.k.a “Little Bobby Tables“), and then write code instead of us, retarded humans.

The question is: If an IDE can do that – Why it cannot be a language feature? Why doesn’t the compiler steps in?

Posted Tuesday, May 12th, 2009 under Programming.

Tags: ,

9 comments

  1. Actually IDEA does check your SQL, or at least if you have the right plug-in.

    There was a proposal some time back (http://www.jroller.com/scolebourne/entry/enhancing_java_multi_lingual_blocks) to have annotations for different languages and have compiler type-check them according to each language rules. I am not a fan though, I generally prefer the embedded DSL solution. In the mid-term I think IDE is the right place for such stuff, IMO IDE should be integral part of a decent language, just like compiler.

    Cheers
    Yardena.

    P.S. I’ve been reading your blog for a while, I really like it.

  2. “The question is: If an IDE can do that – Why it cannot be a language feature?”

    I’m afraid that it’s one of the questions that the sanest answer to them is “Because!”. Anything different would either defy the laws of formal logic or be disconnected to the real life.

  3. IDEs being an integral part of the language is pretty undemocratic, isn’t it?

    The fact that milti-lingual blocks in the middle of Java code looks ugly and can clutter code – with incorrect programming – doesn’t mean a handicap on those who can write better code with it has to be enforced.

  4. Davitt – any program can do what another program does. Should it? that’s a different question. Compiler transforms a program into executable format, that’s what it should do and not much more. You can add static analysis, spell checking and endless list of other features – they are very useful perhaps, but it does not mean they necessarily belong with the compiler.

    Moshe – why is that undemocratic? Having an integrated IDE does not mean that somebody can’t build another. It’s much easier when platform is IDE friendly from day 1, unlike in Java, for example, where every IDE essentially reverse-engineers the compiler to provide its features.

  5. It’s undemocratic in the same way Microsoft bundling Internet Explorer with windows is undemocratic (and monopolistic).

    You’ve completely ignored my =important= argument in the last post.

  6. Hi Moshe,

    M$ is undemocratic because (a) it charges money for its software and a free platform would not have the same issue (b) M$ is closed-source and it inserts “hidden hooks” into the operating system that prevent fair competition, versus platforms that openly provide their full APIs/sources and enable competition. (BTW it’s not just M$, most companies do this, except for Sun “hippies” who played relatively fair and ended up broke :-/)

    As for your argument – democracy has 2 sides, and the other side is that pushing more features into the compiler puts a handicap on the guy who only wants simple and quick Java compilation, because now you require javac to have these other 1000 features. Democracy means modularity – everybody can choose modules to run. People can create their own plug-ins: if you want to type-check SQL inside Java program you can have it without bothering the other guy, and the other guy does not put a “handicap” on you. IDE is a natural facilitator for such extensibility IMO.

  7. Compiler flags are natural facilitators for such extensibility IMO.

  8. And there are no “simple and quick” Java programs. Java has too much clutter and is wayyyyy too verbose.

  9. Hey, I am glad to see we do agree on some things :-)

Leave a Reply

Security Code: