Remix.run Logo
Panzerschrek 6 hours ago

I am developing my own programming language, but I have no specification written for it. When people tell me that I need a specification, I reply that I already have one - the source code of the language compiler.

ozozozd 5 hours ago | parent | next [-]

You are not wrong. But, they are not wrong either.

I feel like if you’re designing a language, the activity of producing the spec, which involves the grammar etc., would allow you to design unencumbered by whether your design is easy to implement. Or whether it’s a good fit for the language you are implementing the compiler with.

The OP also correctly identifies that thoughtful design takes a back seat in favor of action when we start writing the code.

naruhodo 5 hours ago | parent | prev | next [-]

The source code does what it does, including bugs.

So unless you want bugs to be your specification, you actually need to specify what you want.

lunar_mycroft 4 hours ago | parent | next [-]

A corollary to the linked article is that a specification can also have bugs. Having a specification means that you can (in theory) be sure you have removed all inconsistencies between that specification and the source code, but it does not mean you can know you have removed all bugs, since both the spec and the source code could have the same bug.

Panzerschrek 3 hours ago | parent | prev [-]

A bug is a difference between specification and its implementation. In no specification exists, there is no bug (strictly speaking). In a more wide sense a bug is a difference between some implementation and user's expectations, but such expectations may be considered to be some sort of non-formal specification.

Antibabelic 3 hours ago | parent | prev | next [-]

A programming language is not the compiler. A programming language is, in fact, not software.

antonvs 5 hours ago | parent | prev [-]

Maybe this is your point, but the source code of any non-toy compiler is not a usable specification for the language it compiles.

If you want a specification from source code, you need to reverse engineer it. Although that’s a bit easier now, with LLMs.

Panzerschrek 3 hours ago | parent [-]

What do you mean "usable specification"? Usable to produce another compiler implementation for the same language? This IS possible (like clang was designed to match GCC behavior).

Pure specification itself is useless without actual implementation (which does the job), so, trying to write such specification (in a natural language) has no practical sense.