9

Thought provoking!

Comments
  • 10
    No, that would be terrible.

    It takes source code control away from the programmer.

    It assumes that the compiler can figure out exactly what the intent of the programmer is.

    Also, a compiler's job is to exactly translate the source code to target code while preserving meaning, nothing more, nothing less. It can never do anything that can potentially change the meaning of a program.

    You do have linters and realtime code analysis/intellisense/ide tooling that tells you that maybe you want to put a semicolon at the end of a line (eg. Many ides mark invalid code with a red squiggle).
  • 2
    String s = "hello"
    + "wold"

    A compiler would have troubles at guessing where's the missing semicolon
  • 0
    That would be bad... But it could gently ask if you want the compiler to add it for you. Because let's face it, sometime the compiler does get what you're trying to do.
  • 1
    @crisz not really. The next line starts with a binary operator so it must be at the end of the second line. I would not be against a tool that helps you fix such things at compile time (with human supervision of course). It would also establish a baseline for IDE (which could use some common standards).
  • 5
    @Pickman linters and ide error checkers exist for exactly this purpose, many of these programs are specialised compilers that are engineered to try to find errors as fast as possible and also suggest automatic fixes (eg. Visual Studio and IntelliJ suggest automatic fixes quite often).

    Again, it's not the compiler's job. Crashing on error is a good idea when you can't afford to be wrong.

    Btw, there is a common standard for source code analysis and hints and all, check out the language server protocol.
  • 0
    @RememberMe idk what compilers you work with but I hate it when my compiler crashes on an error. I prefer an error message with line number and useful information instead of a crash.
  • 3
    @JustKidding I meant that the compiler just refuses to compile and stops, not that it doesn't give me any useful info.

    If it just fixed stuff and went in compiling I'd get very uncomfortable.
  • 1
    @RememberMe language server protocol? Thanks I will look into it.
    Personally I would not mind if they integrated some features now performed by IDEs into compilers but I understand (and share) your opinion that automatic generation of code can be dangerous.
  • 1
    @RememberMe I was aware of that ;) it just triggered me since sometimes use some experimental features at work which causes the compiler to crash, sometimes even on correct code and that's really annoying sometimes
  • 1
    @JustKidding do you work with numerics and/or templates in C++ by any chance? :p
  • 1
    @RememberMe we're doing formal proofs in SPARK (has nothing to do with Apache Spark) and GCC doesn't like some of the proof annotations.
  • 1
    @JustKidding is that the Ada based thing? Sounds pretty hardcore. I've only experimented with Coq for formal proofs.
  • 2
    @RememberMe Yes, it is, we're also doing Ada ;) we mostly do low level stuff, e.g. formally proven device drivers in SPARK, platform support for smaller uncommon platforms and so on. But on some platforms you don't have the official Ada compiler (which is based on GCC) but only default GCC it can crash sometimes when you add too fancy proof annotations. Fortunately you don't need them to compile so you can comment them out on that target.
  • 1
    Thought provoking!

    Also, already posted just yesterday!
  • 1
    @JustKidding that's pretty damn cool man, keep at it. Hopefully I'll also be working with stuff like that one day.
  • 2
Add Comment