hy/docs/quickstart.rst

55 lines
1.3 KiB
ReStructuredText
Raw Normal View History

2013-04-05 16:30:12 -04:00
==========
Quickstart
==========
.. image:: _static/cuddles-transparent-small.png
2013-06-01 22:02:52 -04:00
:alt: Karen Rustard's Cuddles
(Thanks to Karen Rustad for Cuddles!)
2013-06-01 22:02:52 -04:00
**HOW TO GET HY REAL FAST**:
2013-04-05 16:30:12 -04:00
1. Create a `Virtual Python Environment
<https://pypi.python.org/pypi/virtualenv>`_.
2. Activate your Virtual Python Environment.
3. Install `hy from GitHub <https://github.com/hylang/hy>`_ with ``$ pip install git+https://github.com/hylang/hy.git``.
4. Start a REPL with ``hy``.
5. Type stuff in the REPL::
2013-04-05 16:30:12 -04:00
=> (print "Hy!")
Hy!
=> (defn salutationsnm [name] (print (+ "Hy " name "!")))
2013-04-05 16:30:12 -04:00
=> (salutationsnm "YourName")
Hy YourName!
etc
6. Hit CTRL-D when you're done.
2018-03-26 22:47:12 -04:00
7. If you're familiar with Python, start the REPL using ``hy --spy`` to check what happens inside::
2018-03-26 20:56:11 -04:00
=> (+ "Hyllo " "World" "!")
'Hyllo ' + 'World' + '!'
2018-05-15 23:29:07 -04:00
2018-03-26 20:56:11 -04:00
'Hyllo World!'
2013-04-05 16:30:12 -04:00
*OMG! That's amazing! I want to write a Hy program.*
2013-04-05 16:30:12 -04:00
2018-03-26 20:56:11 -04:00
8. Open up an elite programming editor and type::
2013-04-05 16:30:12 -04:00
#! /usr/bin/env hy
(print "I was going to code in Python syntax, but then I got Hy.")
2013-04-05 16:30:12 -04:00
2018-03-26 20:56:11 -04:00
9. Save as ``awesome.hy``.
10. Make it executable::
2013-04-05 21:27:30 -04:00
chmod +x awesome.hy
2013-04-05 21:38:18 -04:00
2018-03-26 20:56:11 -04:00
11. And run your first Hy program::
./awesome.hy
2018-03-26 20:56:11 -04:00
12. Take a deep breath so as to not hyperventilate.
13. Smile villainously and sneak off to your hydeaway and do
unspeakable things.