Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Meta

Comments on What are the rules of programming language compliance?

Parent

What are the rules of programming language compliance?

+5
−0

Code Golf seems like a fun idea to me, since I'm a programmer by trade and "language lawyer" nerd as a hobby.

But every time I checked the code golf site on SE, I dismissed it as nonsense, because the vast majority of all programs that were posted & highly up-voted there won't even compile on the most basic, compliant compiler for that language.

That kind of defeats the whole point of code golf, since anyone can just post some random incomplete snippet which can't even execute - then claim that they reduced the amount of characters quite a bit by doing so.

Obviously the site needs some set rules for this. Could someone illuminate this part to a newbie:

  • What are the rules in general for programming language compliance?

  • What are the specific rules for individual programming languages and where can one find those?

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+4
−0

Regarding

because the vast majority of all programs that were posted & highly up-voted there won't even compile on the most basic, compliant compiler for that language.

Code Golf allows functions as answers.

For example, this could be a Java hello world program, even though it obviously does not compile:

()->"Hello World!"

This is an anonymous lambda which returns the intended output. To actually run it, you would have to wrap it in code that looks something like this.

P.S. According to rules established on SE, the above could be golfed to a->"Hello World!" to save a byte by taking in an unused argument, but that's not the point of this answer.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

General comments (6 comments)
General comments
Lundin‭ wrote about 4 years ago

With that rationale, what prevents me from just posting a stuff() function call as an answer to everything and claim that the implementation of that function is found in another part of the project? Because a single function containing nothing but a function call to another function is very valid in pretty much any programming language.

Quintec‭ wrote about 4 years ago

@Lundin I don’t follow. Your code needs to contain all the code it references otherwise it won’t be able to run. If you use stuff(), you must define stuff().

dzaima‭ wrote about 4 years ago · edited about 4 years ago

@Lundin this answer is only about the specific problem of allowing functions as answers. My answer deals with the requirements for the actual language - you have 2 "places" where stuff() could be defined - your answer code whose bytecount you count, and the language you're answering in (whose size you obviously ignore). One of those must define stuff() to do what you want it do, and if that's not your answer, it's the language, at which point you stop competing with other C answers.

Lundin‭ wrote about 4 years ago

My point is - your lambda won't run as-is, you need to wrap it in some other code not present. How is that different from calling a function not present?

dzaima‭ wrote about 4 years ago · edited about 4 years ago

@Lundin A function is just allowed as a form of an answer (as an alternative to a full program). e.g. otherwise you are restricted to only a single string I/O (stdout/stdin) which is often extremely limiting (e.g. you'd need to have a JSON parser equivalent to take, as an input, an array of arrays of arbitrary strings, which is just purely stupid). A discussion about what are valid "programs" should be another meta question, but is mostly unrelated to this one.

Quintec‭ wrote about 4 years ago

@Lundin Wrapping a function in other code is only an I/O bridge, not code that actually affects how the function would run and what it would return.