What is a Codebyte?
A Codebyte is a new way to easily write, share, and edit executable code blocks directly in the Codecademy Forums.
Features:
- Embed executable code directly in a Forum post or reply to get feedback, support, or to share your code snippet with the Codecademy community
- No setup required. Write, share and run code directly in Codecademy Forums, right from your browser in the same look and feel of the Codecademy IDE.
- Read, Write, and Edit code in Python 3, JavaScript, and Ruby
What languages are supported?
We currently support the following languages:
- Python 3
- C++
- C #
- Javascript
- PHP
- Go
- Ruby
- Scheme
How do I create a Codebyte?
In the topic / reply composer, select a topic from the drop-down box and then click the Codecademy logo in the toolbar to insert a Codebyte.
Your Codebyte will appear in both the editing and preview panes of the composer. In the editing window, your Codebyte will appear as text between tags, and you will see the actual Codebyte preview in the preview pane.
Once you’ve inserted the Codebyte, you will be prompted to select your language, and then you can begin editing your Codebyte. By default, you will see two panes after selecting a language - you can edit your code on the left and see the output on the right.
Edits to the code in the editing window will automatically update the code in the preview pane. However, edits to the code in the preview pane will not save to your post until you click the “Save to Post” button.
To remove your Codebyte, simply delete the tags.
Clicking “Run” in the preview pane will run your code and show you your output.
How do I interact with a Codebyte on the page?
If you see a Codebyte pop up on a forum post / reply, you can interact with multiple elements of it:
- You can edit any Codebyte on the page, and any changes you make will be reflected when you click “Run”
- Clicking “Run” will run the code and display the output
- Clicking “Copy Codebyte” will copy the markdown text for that Codebyte, which you can then paste into your own post or reply on the Codecademy forums
- Clicking the “<” and “>” symbols will collapse / uncollapse that pane of the Codebyte
FAQs
- Can I insert multiple Codebytes into a post?
-
- Yes! You can add as many Codebytes as you want to your post (although we recommend you try to be as efficient as possible)
- Do Codebytes work outside of the Codecademy forums?
- Codebytes don’t currently work outside of the Codecademy forums
- Do changes I make to Codebytes in other people’s posts / replies persist?
- Your changes don’t affect the underlying Codebyte, so edit away!
- Do Codebytes work on mobile?
- Similar to our Codecademy learning environment, we recommend you use Codebytes on a desktop as Codebytes are not optimized for mobile.
- How do I switch languages in Codebytes?
- Unfortunately, we don’t currently support switching languages, but you can do one of two things:
- Manually change the language in the tags from your current language to another supported language
- Copy your code, remove the Codebyte, insert a new Codebyte with the current language, and paste in your code
- Unfortunately, we don’t currently support switching languages, but you can do one of two things:
- Can I put a Codebyte inside another Codebyte?
- Unfortunately not - Codebytes cannot be nested