I'm just curious about whether any of you have a real-world use for your golfing skills. I'd also be interested to hear if you know of golf-related jobs even if you aren't involved in them, or if you have areas of your life where golfing has been required for practical purposes.
-
14\$\begingroup\$ Does this mean you don't believe the story of carving some code into the limited surface area of a canoe? \$\endgroup\$– GeobitsCommented May 28, 2015 at 1:54
-
3\$\begingroup\$ I don't think there is. But if there isn't, I'm very curious about how does Dyalog, Jsoftware, Kx systems, etc, earns money. (They might be not designed for golfing, but have almost every disadvantage of golfed code.) \$\endgroup\$– jimmy23013Commented May 29, 2015 at 11:32
-
\$\begingroup\$ @user23013: I've wondered that myself. Dyalog seems to maintain that you can use APL for all sorts of crap like web development, but why would you? \$\endgroup\$– Alex A.Commented May 29, 2015 at 16:04
-
1\$\begingroup\$ Of Course!! javascript code obfuscating is atleast to say, a code-golfing with non-esoteric languages, one of the well known effective methods to circumvent source-hacking, not just for a single language but whoever cant prevent his source from being public, golfing/jamming is a brilliant way to make the debugging process last even more than redacting a new analogue from the beginning. \$\endgroup\$– Abr001amCommented May 12, 2016 at 7:12
-
5\$\begingroup\$ Not really enough for an answer, but I for a while made programs for people's TI-83/TI-84s. Most insisted that they be small so they could still have room for whatever else they wanted on there. Nothing really was restricting, except for this one time where I had only around 50 bytes to work with. I think it was a right-triangle side-completing program. \$\endgroup\$– Conor O'BrienCommented Oct 30, 2016 at 3:04
4 Answers
Yes, I do!
I work for Dyalog. Part of my work is "spreading the word", and that officially includes code-golfs. This is from an official internal document pertaining to me:
In fact, when we hire for our APL team, we are more interested in golfers than regular programmers, as the former are more likely to have the right mindset. This community has already given us both an intern and employee after employee.
-
\$\begingroup\$ Why would anybody use APL in practice though? What's the real advantage of using it over all the other stuff like R or python+numpy? \$\endgroup\$– mromanCommented Nov 23, 2018 at 12:49
-
\$\begingroup\$ @mroman APL can be very fast — sometimes faster than carefully hand-written C/C++.. It can also cut down development time and number of programmers needed, and lessens the risk of bugs by simply doing more with less code. Try it and see that it can be fun rather than tedious! \$\endgroup\$– AdámCommented Nov 23, 2018 at 13:02
-
\$\begingroup\$ Since I'm the lunatic behind The Burlesque Programming Language I found that short-code doesn't really translate to performance as high-level concepts are usually also very costly. You can express problems for example in terms of set operations on subsets, rotations, permutations and you can do this with very few instructions but computing all subsets/permutations/rotations etc. is just much, much slower than a more direct approach using low-level/more verbose concepts. \$\endgroup\$– mromanCommented Nov 23, 2018 at 13:07
-
\$\begingroup\$ For example the challenge "Most Common Multiple". The high-level way is to actually create a multiplication table and then pick the most common element but there's some significant overhead in this compared to just nesting two for-loops for example. \$\endgroup\$– mromanCommented Nov 23, 2018 at 13:08
-
\$\begingroup\$ @mroman Lets continue this conversation in chat… \$\endgroup\$– AdámCommented Nov 23, 2018 at 13:09
I don't.
Quite the opposite actually. The code I write for work has to be readable, understandable, and usable by folks with a very limited programming background. I have to err on the side of extreme verbosity in my code, otherwise I'd have to spend a lot of extra time explaining it to others. (As an aside, this is probably why I'm not so good at golfing.)
Much like the mentality of code golf challenges on PPCG, efficiency must often be sacrificed. However, in my case it's sacrificed for the sake of readability, not for saving a byte of length. Unlike PPCG code, though occasionally inefficient, my code must finish executing before the eventual heat death of the universe.
Note that this is not my preferred programming style, but it's what's expected of me in my current position.
I think you'll find that golfed code is not well received by folks in a professional environment who have to deal with it, at least in my experience.
I'd also be interested to hear if you know of any golf-related jobs...
Ever heard of Tiger Woods? He golfs for a living, and I hear he's pretty good at it. Haven't seen him around PPCG in a while though.
-
1\$\begingroup\$ Don't really understand the downvote, but it's meta so whatevs. \$\endgroup\$– Alex A.Commented May 28, 2015 at 15:21
-
5\$\begingroup\$ Oh, that's mine. I assumed that negative ("I don't") answers could be posted by way too many people to be useful. Kinda like answering "None of my posts have contributed" on this question. \$\endgroup\$– GeobitsCommented May 28, 2015 at 15:35
-
1\$\begingroup\$ @Geobits: Oh you. ;) Yeah, I see what you mean and I agree, but I figured at least one would be useful here so that people who generally agree with my sentiments could upvote or comment. \$\endgroup\$– Alex A.Commented May 28, 2015 at 15:58
-
\$\begingroup\$ My language of choice is PowerShell, which is pretty far from golfing. With code here, I can do stuff like
|%{?_
which, while perfectly valid PowerShell, is not the sort of thing that's easily readable for code-reuse elsewhere in my organization. It's refreshing to twist the same language in a different direction. \$\endgroup\$ Commented Oct 2, 2015 at 15:31 -
\$\begingroup\$ It is sacrificed too error check, and without that the golfing programs can not be ok out of here \$\endgroup\$– user58988Commented Apr 17, 2017 at 17:57
Sort of
Some low cost micros have very resource constrained. eg
PIC10F200
Program Memory (KB) 0.375
RAM Bytes 16
While I'm not actually using any quite that small - even larger chips can run out of space quickly when you don't have space for libraries to lean on.
There's also a bit of golfing used for protocols over the mobile networks (M2M)
-
17\$\begingroup\$ Wait, sixteen bytes of RAM? \$\endgroup\$ Commented Jun 8, 2015 at 16:40
-
2\$\begingroup\$ what do you do on such micrichip? \$\endgroup\$ Commented May 5, 2016 at 20:03
-
1\$\begingroup\$ @lirtosiast Yes. PICs are that bad. \$\endgroup\$ Commented Mar 13, 2017 at 17:13
-
\$\begingroup\$ @lirtosiast: I've done microcontroller programming before too. The smaller the RAM, the cheaper the microcontroller. I tended to use microcontrollers with ~100 bytes of RAM, but it's certainly believable that someone would use a smaller one if that's all they needed. \$\endgroup\$– user62131Commented Mar 15, 2017 at 15:50
Today I tasked my (physics) students with something along the lines of:
- Write a function that does X.
- Use your function from Task 1 to do X.
Now, I wanted to provide students with some solution to Task 1, so that if they failed to do it, they could do Task 2 nonetheless. Obviously, I also did not just want to give them any plain hints on how to do Task 1. Giving them anything compiled would risk portability issues or my students not knowing how to use it.
Fortunately, the vast majority of golfing tricks also obfuscate your code, so I found it easy to give my students something which would take longer to reverse-engineer into some human-readable solution than solving the exercise as intended.
-
\$\begingroup\$ Interesting approach. I'd be interested to hear whether this encourages any of your students to golf their own solutions... \$\endgroup\$ Commented Oct 29, 2018 at 20:34