TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Forth haiku is an attempt to mix math, art and Forth

47 pointsby pointfreeover 10 years ago

5 comments

evincarofautumnover 10 years ago
This is awesome and really shows off the beautiful compactness of Forth.<p>It took me a moment to figure out what to actually do. Basically you just write a little program that produces three floating-point values from 0.0 to 1.0, and these are used as the R, G, and B channels of each pixel in the output. For example, an all-red image is:<p><pre><code> 1 0 0 </code></pre> And a blue-cyan-magenta rectangle is:<p><pre><code> x y 1 </code></pre> You get the x and y of the current pixel with the “x” and “y” words, and you get the current time with the “t” word in order to make animations. Here’s one that continually oscillates between black and white:<p><pre><code> : r 5 ; : sin&#x27; sin 1 + 2 &#x2F; ; : t&#x27; t r * sin&#x27; ; t&#x27; t&#x27; t&#x27; </code></pre> (You can change the value of “r” to make it oscillate faster or slower.)<p>Looking at the glossary[1] and cannibalising other examples is really helpful.<p>[1]: <a href="http://forthsalon.appspot.com/word-list" rel="nofollow">http:&#x2F;&#x2F;forthsalon.appspot.com&#x2F;word-list</a>
评论 #8312094 未加载
评论 #8311195 未加载
ANTSANTSover 10 years ago
See also IBNIZ, a livecoding environment with a language inspired by (and even more terse than) FORTH.<p><a href="http://countercomplex.blogspot.com/2011/12/ibniz-hardcore-audiovisual-virtual.html" rel="nofollow">http:&#x2F;&#x2F;countercomplex.blogspot.com&#x2F;2011&#x2F;12&#x2F;ibniz-hardcore-au...</a>
amenghraover 10 years ago
<a href="http://forthsalon.appspot.com/haiku-view/ahBzfmZvcnRoc2Fsb24taHJkchILEgVIYWlrdRiAgICAstmWCgw" rel="nofollow">http:&#x2F;&#x2F;forthsalon.appspot.com&#x2F;haiku-view&#x2F;ahBzfmZvcnRoc2Fsb24...</a>
kaoDover 10 years ago
I wondered if the Forth code was being transpiled into JS or GLSL. Inspecting the source reveals it is JS, which seems sensible since it has stacks.<p>That made me wonder, how hard would it be to turn Forth code into imperative GLSL? Seems like a fun exercise and would allow huge canvases.
pkayeover 10 years ago
I seem to remember something similar but used a C like language.
评论 #8311171 未加载
评论 #8311166 未加载