r/programming • • Jun 05 '18

Code golfing challenge leads to discovery of string concatenation bug in JDK 9+ compiler

https://stackoverflow.com/questions/50683786/why-does-arrayin-i-give-different-results-in-java-8-and-java-10
2.2k Upvotes

355 comments sorted by

View all comments

Show parent comment

11

u/Pazer2 Jun 05 '18

Hey guys! Check out my groundbreaking new scripting language for code golfing! It just happens to interpret a blank input file as "output executable code for the solution to this particular problem".

7

u/adrianmonk Jun 05 '18

This trick is also used in data compression contests by people who want to be irritating.

7

u/nakilon Jun 05 '18

There was a cool contest two years ago. You had to make a classifier that would tell if the word is from the dictionary (exact "English words" dictionary was given) of 4 megabytes. The whole solution (code + data) had to fit into 48 kilobytes. https://habr.com/company/hola/blog/282624/
IIRC guys who won with amazing accuracy (mine was only 71%) were using Bloom filter.

3

u/zenflux Jun 06 '18

I usually see those kind contests score the sum of output size and decoder executable size. Or maybe I'm only seeing these contests after someone decided to be cheeky with storing the file in it's path and they made the rule.

2

u/bitofabyte Jun 06 '18

I think that they (stack exchange golf people) have a rule that you can only use a language (maybe language version) that was published before the problem, specifically to prevent this.