Hacker News new | ask | show | jobs
by mmh0000 438 days ago
I will start by saying, I completely agree with you!

But, then, I have to behave like a typical computer nerd and say..

Well ackchuallyyyyyy:

  > "This is not a really a problem in "regular" programming languages"
Browsers do stupid: <!--[if IE 8]>

Linux does stupid: #!/bin/bash

C/C++ (preprocessor marcos) do stupid: #ifdef

https://en.wikipedia.org/wiki/Conditional_comment

https://en.wikipedia.org/wiki/Comment_(computer_programming)

2 comments

I don’t think the Linux one is that stupid, but it might be me.

It’s not a “magic comment” because it doesn’t depend on the runtime. It specifies an interpreter to use, regardless of the language of the file.

Eg you can use #!/usr/bin/python for a Python script. I don’t find it worse than the existing alternative of making the file name magic and finding and interpreter based on that.

It is a magic comment though.

It's a comment ignored by the interpreter (bash, python, whatever).

The kernel just says "Hey! You can't execute a text file, you weirdo! I'll just read the very first line of the text file and if it happens to be a comment that points to another executable, I'll run that and pass it this file."

Macros are not comments.