14
\$\begingroup\$

If we want to prevent having ridiculous answer for Code-Golf with esoteric language that are made up just for the challenge, we need to define what are the acceptable programming language.

The boundary I would think of are the following (note that those are just up there as an example):

  • Does the programming language have at least 10 page of documentation about it ?
  • Does the programming language can do anything else than the challenge for which it's made up.
  • Can you find at least a project using that language on the web ?
\$\endgroup\$

closed as off-topic by Mego, Cyoce, PhiNotPi, GamrCorps, Rɪᴋᴇʀ Mar 4 '16 at 16:46

  • This question does not appear to be about Programming Puzzles & Code Golf Stack Exchange or the software that powers the Stack Exchange network within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ Where do languages like HQ9+ fall in? \$\endgroup\$ – Nathan Osman Feb 21 '11 at 0:26
  • \$\begingroup\$ They fall out, I guess? \$\endgroup\$ – Rei Miyasaka May 1 '11 at 22:55
  • \$\begingroup\$ How about something like "100 point penalty for the following languages: APL, J, K, golfscript, ..." \$\endgroup\$ – Braden Best Feb 11 '14 at 4:06
  • 3
    \$\begingroup\$ I'm voting to close this question as off-topic because complaining about usage of languages designed for golfing never contributes positively towards the site. \$\endgroup\$ – Mego Mar 3 '16 at 0:57
  • \$\begingroup\$ @Mego considering the most upvoted answer to this question has since became our main rule for code golf, I think this should remained at least for historical reasons. \$\endgroup\$ – plannapus Mar 4 '16 at 9:55
  • 1
    \$\begingroup\$ @plannapus I would agree with a historical lock, but that is not mutually exclusive with closing this question. \$\endgroup\$ – Mego Mar 4 '16 at 9:57
31
\$\begingroup\$

I think that as long as a compiler was released before the question was asked, it is a valid language. This removes stupid answers such as "I created language X with this command Y that solves this in one character".

\$\endgroup\$
  • 2
    \$\begingroup\$ I suppose GolfScript to be a language created to solve golf tasks with one command. I'm against it ) \$\endgroup\$ – Nakilon Jan 27 '11 at 22:10
  • 11
    \$\begingroup\$ @Nakilon Then what about J, for example? It's difficult to draw the line. I prefer the idea of just not voting golfscript answers up unless they really are good. \$\endgroup\$ – marcog Jan 27 '11 at 22:14
  • 4
    \$\begingroup\$ @marcog, 1) J wasn't invented to solve golf, so it's normal. Let it win where it is suitable. 2) I think questions will be voted up just like always at SO — in 99% cases by solution size. When you are pro in Perl or Ruby or C, made such a cool code without sleeping for 3 nights, and some kid spends 10 minutes to beat you using golfscript... it at least demoralizing and kinda trolling ) \$\endgroup\$ – Nakilon Jan 27 '11 at 22:32
  • \$\begingroup\$ @Nakilon I understand your point, but I disagree. If golfscript does the job well, so why not let it win where it is suitable too? I personally avoid ever up-voting golfscript solutions on SO. It might be the case even more-so here as people get bored seeing illegible golfscript solutions with no explanation. \$\endgroup\$ – marcog Jan 27 '11 at 22:36
  • \$\begingroup\$ @marcog, my position is that golfscript breaks two rules (recommendations) at once: 1) language can't be invented for just solution this task - it's invented just for golfing; 2) language must be used in world practice - golfscript invented and suitable only for golfing. \$\endgroup\$ – Nakilon Jan 27 '11 at 23:05
  • 8
    \$\begingroup\$ @Nakilon: Being invented to be good at code golf is different from being invented to solve the problem at hand. Yes, some language golf better than others. Too bad. Either learn a good golfing language, or (what I do) resign yourself to not "winning". For me the win is in the process. \$\endgroup\$ – dmckee Jan 28 '11 at 19:39
  • 1
    \$\begingroup\$ Either eat steroids, or loose to Arnold \$\endgroup\$ – Nakilon Jan 28 '11 at 19:48
  • \$\begingroup\$ Either break windows with stone, like I do, or be a mommy's boy \$\endgroup\$ – Nakilon Jan 28 '11 at 19:50
  • 4
    \$\begingroup\$ @Nakilon: It's a game. There isn't some pure Platonic, ideal to live up to here. Surveying the code-golf questions on Stack Overflow I estimate the GS wins about 1/2--2/3; J wins about 1/5; perl, python, ruby, dc and rebmu win from time to time. Mathmatica, c, c++, befunge, and rebol show well but rarely win. And I sometimes write my solutions in fortran 77---heavily golfed, to make the shortest fortran solution I can---but I know I'm not going to "win". Such is life. \$\endgroup\$ – dmckee Jan 28 '11 at 20:07
  • 3
    \$\begingroup\$ @Nakilon: What makes it a cheat? The stack nature? How about forth? The powerful single character operators? What about APL? GS doesn't do anything new, it just collects the good golfing features in one place. \$\endgroup\$ – dmckee Jan 28 '11 at 20:23
  • 5
    \$\begingroup\$ @Nakilon: We're debating rules. You don't get to assume the ones you want without defending them. \$\endgroup\$ – dmckee Jan 28 '11 at 20:37
  • 1
    \$\begingroup\$ @Nakilon: GolfScript cannot solve golf problems "with one command"---it's actually a general-purpose programming language. You should learn GolfScript before you bitch further about it. GolfScript also has things it does not do well or with brevity. Floating point comes to mind. \$\endgroup\$ – Chris Jester-Young Jan 30 '11 at 4:12
  • 4
    \$\begingroup\$ @Nakilon: Regarding your claim that GolfScript is useful only for golfing, I beg to disagree. On a couple of occasions, I've found myself using it to do a few practical non-golfing tasks. Could I have used another language? Sure. But GolfScript was the most convenient for the occasion. \$\endgroup\$ – KirarinSnow Jan 30 '11 at 19:36
  • 5
    \$\begingroup\$ I disagree that golfscript is purely designed to win codegolf. Firstly it has some really long keywords such as "while" and "base" which should surely be abbreviated to single chars. Golfscript stands up as an interesting language to learn and in a few hours you can really stretch your brain. There has certainly been times when I have spent 3 days trying to beat a perl or J solution with golfscript. I think only people who have learned the language can appreciate the answers properly. Everyone else seems to think we bash the keyboard randomly for 10 mins and the program writes itself \$\endgroup\$ – gnibbler Feb 1 '11 at 13:49
  • 3
    \$\begingroup\$ @gnibbler -- It says right on the GolfScript site: "GolfScript is a stack oriented esoteric programming language aimed at solving problems (holes) in as few keystrokes as possible." Just because it can be used for general purposes (any Turing-complete language can), and occasionally can be used effectively, doesn't mean it's been designed for anything other than to win golfs. \$\endgroup\$ – Rei Miyasaka May 1 '11 at 23:00
8
\$\begingroup\$

I was thinking about this a lot, since the esoteric languages like APL, GolfScript, J, ... always win and suck out the enjoyment out of CodeGolf.

  • It's not fair because these languages were created just for the challenge.
  • In many cases, they use non-ascii characters to "compress" source code (Sclipting, APL)
  • For me it's fun is to see a surprisingly short code or a trick in language which I use for serious things, not a squeezed code of some esoteric language, even if it's shorter, because that's not surprise - you already expected it, the language was created for that.

So I think it makes perfect sense to make specific challenges for non-esoteric languages only. It could bring the enjoyment back!

Back to the definition. Basicly, esoteric language is a language that is not normally used for any real bussiness and was created just for challenges. More objective criteria for what esoteric language could be:

  • It is listed in Esoteric language list - with the exception of PERL and perhaps other mistakes.
  • It doesn't have a tag on StackOverflow with at least 2000 questions.
  • Is not part of any standard OS release (meant as an exception for small standard tools like awk, sed, dc etc. even if they don't have enough questions at SO).
  • Uses non-ASCII characters.
  • Yours "Can you find at least a project using that language on the web?" is a very good idea, but there might be very alternative and very esoteric projects too...
  • You can also name specific languages you are sure you want to exclude just to prevent finding a hole in the rules :-)

Other ideas to develop (just brainstorming):

  • Is not used for teamwork programming of products that other people use.
  • Is not used for products other people pay for.
  • Majority of operations use postfix notation and take operands implicitly from a stack.
\$\endgroup\$
  • 5
    \$\begingroup\$ APL, and its descendants J and K, were not created for the purpose of code-golf. They just happen to be pretty good at it for a certain set of problems. \$\endgroup\$ – Gareth Feb 1 '14 at 19:16
  • \$\begingroup\$ @Gareth, thanks for the note. Not pure code-golf in all cases, but the briefness of the language could be one of the authors priority. But certainly we can say that these languages are not applied for real programming. \$\endgroup\$ – Tomas Feb 1 '14 at 19:25
  • 1
    \$\begingroup\$ I disagree. I personally only use it for code-golf except on rare occasions, but the J website lists a number of companies and institutions that use J: Cognos · Bayesian Enhanced Strategic Trading · Fax Focus, Inc. · Hewlett Packard · Intel · Korea Telecom · Luen Thai · Maple Partners · Microsoft · Niagara Mohawk Power · Nikko Securities · Novell · Okada Denki Co. Ltd. · Pivotal Technologies · Syngenesis, Inc. for example. It seems unlikely that these are using it for golfing purposes. \$\endgroup\$ – Gareth Feb 1 '14 at 21:09
  • 1
    \$\begingroup\$ They say. But what does this actually mean? Can you link actual project made using J? Seriously, if you look at github, there's no serious project written in J, only few golf-like examples. \$\endgroup\$ – Tomas Feb 1 '14 at 21:28
  • \$\begingroup\$ This answer is almost exactly duplicated at meta.codegolf.stackexchange.com/a/938/194 \$\endgroup\$ – Peter Taylor Feb 1 '14 at 22:13
  • \$\begingroup\$ @Tomas You aren't seriously arguing that if it doesn't have many projects on Github, it's not a serious language are you?? Instead of arguing that we shouldn't allow these languages, perhaps you might take the opportunity to learn them? I'd never even heard of J before I started using this site, but now I greatly enjoy the challenge of competing against myself as much as against someone else - always trying to express the solution in a better way. Maybe this is easier to do in J and GolfScript? \$\endgroup\$ – Gareth Feb 2 '14 at 20:46
  • \$\begingroup\$ @Tomas Would you also argue that R should be excluded for similar 'not much on Github' reasons? Or does R not concern you because you can beat it with Perl? \$\endgroup\$ – Gareth Feb 2 '14 at 20:49
  • \$\begingroup\$ @Gareth, R has literally thousands of statistical packages shared in a similar way github does. It is very much used in serious projects and in business. And I can beat Perl with R :) \$\endgroup\$ – Tomas Feb 2 '14 at 21:10
  • \$\begingroup\$ @Tomas k/kdb/q is in use in pretty much every top financial institution in the world. I use it daily to create "real" programs. That you don't see many projects on Github for it might have something to do with its exorbitant licensing fees. \$\endgroup\$ – tmartin Feb 6 '14 at 18:37
  • \$\begingroup\$ @tmartin I see only 15 questions tagged k on SO. Can you link any resource, something to support your claim? \$\endgroup\$ – Tomas Feb 6 '14 at 19:05
  • 1
    \$\begingroup\$ @Tomas code.kx.com/wiki/Main_Page . For what it's worth, users of q/k generally wouldn't use SO. They'd use the k4 listbox which is dedicated to the language. It might be niche, but that doesn't make it any less of a programming language than C or Perl or R. Walk into any bank in Wall St and the chances are they'll be using kdb to capture and store their tick data. This obsession you have with online exposure is meaningless. You're barking up the wrong tree. \$\endgroup\$ – tmartin Feb 6 '14 at 21:32
  • 1
    \$\begingroup\$ -1 for the snark about stack-based languages. The reason many golfing languages are stack based is because that obviates the need for grouping operators, shortening the code, but that in no way detracts from the golfing, and is a feature of a number of other languages, e.g. PostScript. \$\endgroup\$ – AJMansfield Oct 6 '15 at 0:07
  • 1
    \$\begingroup\$ In fact, as far as golfing goes, Postscript is actually a really effective language because of its inclusion of binary token equivalents of most of the operators, but has about as much production usage as they come, as it was the standard digital format for printed documents for over 20 years, only dying out as PDF (a PostScript derivative) came to replace it. \$\endgroup\$ – AJMansfield Oct 6 '15 at 0:13
4
\$\begingroup\$

Why do you demand "the language is being used in the real world"? Golfing is not a real word problem. Reducing the size of your program may have been a real world application many years ago. Reducing the size of a program is still an issue for web applications using tons of JavaScript but that process is not golfing. Golfing is about finding the shortest program, not take an existing program and just squeeze (remove white-space, line breaks, only one char identifiers etc.) it.

Can you find at least a project using that language on the web

That one is trivial. I can write webpages in esoteric programming languages, in fact, I've already done things like that.

Does the programming language have at least 10 page of documentation about it

Why would the quantity of documentation matter? Extremely simple languages barely need one page of documentation.

My feeling is that it's best to implement "soft" site-wide policies like not using built-in features of languages that automatically solve the bulk of the problem.

Why not? Golfing is about finding the shortest program in a language. If the language has a function which nearly does the job than that is the shortest way to do it.

The absolute shortest answer is secondary to me, and certainly a very short answer in a tool language that was designed for the domain of the problem isn't that interesting at all.

Again, if that is the case you are not golfing. It's not golfing if you just want some decent looking solution.

Are there two or more web-frameworks for serious use for the language?

That's no way to measure anything. Haskell has many good web-frameworks but is still considered (at least from the java/oop mainstream) to be a silly language nobody would use in production.

To sum up: If you want language agnostic golfing than some esoteric looking languages or even plain esoteric languages will win in some challenges. That's just the way it is. If you look at anarchy golf J kicks ass. It wasn't invented for golfing (probably ;)) but it turns out to be very good at it. Look at it as a sport. You won't set a maximum height for a basket ball player just because some are bigger than others and that turns out to be an advantage in some situations.

Otherwise create code golf problems and judge each language separately.

If you are not interested in golfing but interested in comparing your pseudo-leet-skills then just don't do golfing. Invent something else.

\$\endgroup\$
3
\$\begingroup\$

My feeling is that it's best to implement "soft" site-wide policies like not using built-in features of languages that automatically solve the bulk of the problem. For example, we might disallow using h in GoRuby for a Hello World problem, or using the built-in Easter-calculation functions in PHP for an Easter problem.

That way, you can use an esoteric language if you like---as long as you're not using a built-in function to solve the problem in 1 character.

\$\endgroup\$
  • 8
    \$\begingroup\$ Or people could just stop asking "Hello World" golfs. Just pick a different phrase - there are plenty of them \$\endgroup\$ – gnibbler Feb 1 '11 at 13:43
  • 4
    \$\begingroup\$ @gnibbler His suicide note was in C. printf("Goodbye, World!"); \$\endgroup\$ – Mateen Ulhaq May 3 '11 at 0:13
0
\$\begingroup\$

I suppose I don't mind seeing answers in GolfScript or other similar "made-to-golf" languages -- but I admit that I don't consider them serious answers.

How 'bout this as a test: Are there two or more web-frameworks for serious use for the language?


Update:

Please understand: I wasn't proposing the test as a criteria for "serious language", but as a possible criteria that code-golf questions could use for the languages they'd like to score.

It feels to me like there are roughly four categories of languages in use when answering CodeGolf:

  • Main stream general purpose languages: C, C++, Phython, Ruby, etc...
  • Tool languages, that are generally aimed a certain domain: awk, bash, sed, MatLab
  • Golf languages, aimed at winning code golf but which no one would use in production: GolfScript, etc...
  • Obviously inappropriate languages for code golf, which people use for fun: Cobol, Visual Basic, LabView

Now, of course it is impossible to put hard and fast definitions on these categories. But I think that for a given problem, looking at the shortest solution in a main stream language is interesting, and has merit, separately from shortest overall (which is often in a tool or golf language).

I like code golf, because I like seeing the inventiveness of the answers, and the ways that people find to extract hidden power from a language's features and shortcomings. The absolute shortest answer is secondary to me, and certainly a very short answer in a tool language that was designed for the domain of the problem isn't that interesting at all. (Aside: I love good question design that manages to keep the solution from being solely in a single domain so that all languages have to stretch!)

In light of this, my proposed test (which was certainly cheeky) was for what would constitute a mainstream language. -- Though I have to admit, I've since found at least one web framework for bash on the web!

\$\endgroup\$
  • \$\begingroup\$ I think my language of choice is both fairly suitable for golfing (being able to beat Python, sometimes Perl, rarely even Ruby), yet there is no web framework for the language. Not every language is created equal and you probably won't find a web framework for bash either. \$\endgroup\$ – Joey Mar 1 '11 at 0:52
  • \$\begingroup\$ Are there any frameworks for the language at all? \$\endgroup\$ – MtnViewMark Mar 1 '11 at 3:22
  • \$\begingroup\$ Not that I know of. By your line of reasoning you probably also don't consider awk a serious language or many esoteric ones (Befunge springs to mind which can be fairly short). \$\endgroup\$ – Joey Mar 4 '11 at 10:51
  • \$\begingroup\$ So - I think you are all taking my comment in quite the wrong way... clearly I need to reword it. I wasn't proposing a hard filter - just a possible criteria people could choose use. \$\endgroup\$ – MtnViewMark Mar 4 '11 at 16:14
0
\$\begingroup\$

Edit: I removed the Bash version (it was buggy and I couldn't seem to fix it), and I updated the C/C++ version (now identical) due to a better implementation in the comments. I also added equivalents in several other languages.


I have a list of minified implementations of the greatest common divisor operation in several different languages. Maybe this can influence some of this discussion.

ANSI C/C++:
int a(int b,int c){return c?a(c,b%c):b;}

K&R C: (permits implicit `int` types)
a(b,c){return c?a(c,b%c):b;}

Common Lisp:
(defun a(b c)(if(zerop c)b(a c(mod b c))))

ECMAScript 5:
function a(b,c){return c?a(c,b%c):b}

ECMAScript 6: (uses implicit global)
a=(b,c)=>c?a(c,b%c):b

Forth:
: g begin ?dup while tuck mod repeat ;

GolfScript:
~{.@\%.}do;

Java:
int a(int b,int c){return c>0?a(c,b%c):b;}

Haskell:
g a b=if a > 0 then g(b `rem` a)a else b

So, here's the stats for each of those examples:

  • Common Lisp: 42
  • ANSI C/C++: 40
  • K&R C: 28
  • ES5: 36
  • ES6: 21
  • Forth: 38
  • GolfScript: 11
  • Java: 42
  • Haskell: 40
\$\endgroup\$
  • 1
    \$\begingroup\$ For ANSI C, this would be a little more compact: int a(int c,int b){return b?a(c,b%c):c;} \$\endgroup\$ – Dennis Munsie Jul 14 '14 at 15:25
  • \$\begingroup\$ @DennisMunsie Thank you. Updated. I don't know how I missed that (considering I use ternaries a lot in my pet projects). \$\endgroup\$ – Isiah Meadows Jul 14 '14 at 21:49
  • \$\begingroup\$ The Java is buggy: the condition is back to front. It also includes unnecessary whitespace, and could use <1 or >0 to save another char. \$\endgroup\$ – Peter Taylor Jul 15 '14 at 8:34
  • \$\begingroup\$ @PeterTaylor Thank you for pointing that out. I also noticed bugs in other ones there as well. \$\endgroup\$ – Isiah Meadows Jul 15 '14 at 8:48
  • \$\begingroup\$ I suspect that Haskell can save a few by not using infix rem, but I don't know it well enough to easily test whether that compiles. \$\endgroup\$ – Peter Taylor Jul 15 '14 at 9:11
  • \$\begingroup\$ This isn't really intended to be serious. It's more to help opinions. Plus, this question originated in 2011 \$\endgroup\$ – Isiah Meadows Jul 15 '14 at 9:12

Not the answer you're looking for? Browse other questions tagged .