I've never done code golf before, but it looks fun. I have some questions though. Should I learn some golfing languages, or just try some challenges out with the languages I know? (I know C# and Python) Are there any types of challenges I should try first, or should avoid until I'm better? Are there any things that are generally known to be disallowed? Is there anything I should keep in mind while golfing? Are there any general tips for golfing? Answers to any or all of these questions would be greatly appreciated, along with anything else I should know.
I don't really know what's best specifically for you but I'll share my short experience over the past year here.
I started out golfing in Java, probably the worst possible language to golf in. However, despite never having won a single challenge in Java, people almost always commented on my answers, offering support and suggestions. So, the key thing to take away from this part of my experience is: "The more common the language, the more people can appreciate the cool tricks you've learned in your experience." Say you've been golfing in python and C# for 5 years, you may actually teach some users here a few neat tricks they're not seen before. I find that rewarding on its own.
After golfing and losing for a few months in Java, I started using Groovy and a few other langauges I wanted to learn more but never did. In the course of about a month my Groovy skills had sharpened to the point of knowing Groovy on Grails and I started web development! Pretty fun to golf in a new language then apply that knowledge to a career advancement or personal skill advancement. Maybe start golfing in C# to hone your ASP.NET skills and learn to become an Enterprise website developer! Kinda what I did.
Lastly, and most recently, I've been messing with a langauge named 05AB1E. I feel like this is a great way to ease into understanding esolangs. When I first looked at Jelly I was a little overwhelmed by all the monads and dyads. I still am overwhelmed by them. But I'm slowly learning by paying attention to the masters. However, 05AB1E uses a fairly straightforward command system and a stack-based memory system. You can write a program simply by looking at this:
You basically pick the tiny building blocks you want and go from there. Sure, understanding what it's actually doing will take you some time. However, I've never picked up a language easier than I have 05AB1E. If you have any questions feel free to hit me up or join the 05AB1E Oasis chatroom. Adnan is the original creator of the langauge and Emigna has some of the best (and FGITW) answers I've ever seen.
The main takeaway from all that crap would be: Read other people's work, enjoy the effort they've taken and always learn something new; you don't need to be the best to compete.
P.S. Use this link if you have a specific language in mind to get language specific tips and tricks:
A few thoughts, from a fairly-newbie:
- Collaborate with others: help them improve their solutions, and incorporate their suggestions about your own.
- Don't submit ungolfed solutions - make a reasonable effort before you post.
- Don't copy other people's solutions without attributing them.
- If you have an idea for a new challenge, post it to the sandbox for feedback first.
- Read other people's solutions to learn from them. Personally, I prefer to attempt the challenge first before I do this.
Golf for fun, not to win!
Post your answer even if someone else has already posted a shorter answer in the same language!
Yes, you can learn from other people's answers, but learning by doing is in my experience much more effective.
It's likely that other's will have posted submissions in your language before you are finished writing yours. And it's likely that their submissions are shorter than what you managed to write. Post your solution anyway! People will likely give you advise based on what you have done, and you'll learn.
Have a look at what happened with this Java-submission by a new golfer ("not for the win but for the fun :)"). The user has about 500 Java-answers on SO (so the user has written quite a bit of Java-code), but got help from 4 different users to golf his/her score quite a lot.
Sometimes a win is getting your code about the same length as everyone else's.
I recently started golfing in Swift, which is probably one of the worst languages to use because the strict typing causes you answer to be about twice as long as everyone else's.
Unless there is a limitation that breaks your code online, post a link so people can test it.
When you post a solution, the OP will most likely want to test it him/herself. You can find online playgrounds fairly easily, but TIO is most commonly used around here.
Learn what your language does well and what it is terrible at.
Pick a language you want to use, and start learning its loop-holes, pitfalls (Swift still doesn't have a 'by-the-power-of' operator, AKA
**), built-ins, and strengths. You can easily gain this knowledge over time as you try to solve challenges:
Hmmm, I should be able to make this shorter.
Ah, never knew about that language feature!
*Lose 10 bytes from your solution.*
What if your language doesn't cut it but you love the syntax?
If you want to get crazy, write a new language or a transpiler and open-source it, then use that to write your solutions.
First of all: Welcome to Programming Puzzles & Code Golf!
The vast majority of challenges here are code-golf, and the golfers are very welcoming and supportive. There are various other challenge types here too:
You are not expected to know everything before you start, so just go ahead and jump in, and people will link to any applicable rules on Meta as they come up. If you want a head start on this, start from the FAQ page and browse through whatever sections are relevant. Many of the rules will only come up rarely, so don't worry about memorising them all up front. You'll pick them up as you go (and no doubt contribute to proposing new ones/changing old ones in time).
As long as you are aware that there are rules out there, and take it as a positive thing when people point them out to you, all should be well. The fact that you are asking this question suggests you already have the right attitude...