Thursday, September 1, 2022
Show HN: Pith language. JavaScript with a little bit of Python syntax https://ift.tt/gmeoW0Z
Show HN: Pith language. JavaScript with a little bit of Python syntax I've been writing a lot of JavaScript and Python lately. I like Python's syntax, so I created a language called Pith that's JS with some Python-like syntax (but without trailing colons). It's not a full compiler. It really just does search-and-replace, but I find it fun and useful in spite of some sharp edges. I use it on my smartphone to write and run short programs. Here's an example using the HN API: max = 6 ids = await getApi('topstories') for id in ids.slice(0, max) getItem(id) async def getItem(id) const d = document.createElement('div') results.appendChild(d) d.style = 'padding-bottom: 1em;' i = await getApi('item/' + id) ? i.title, '|', i.score u = '//news.ycombinator.com/item?id=' d.innerHTML = i.title.link(u + id) async def getApi(path) u = '//hacker-news.firebaseio.com/v0/' return getJson(u + path + '.json') https://ift.tt/keuA0fH September 2, 2022 at 12:17AM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment