3 ms·
always been interested in learning a stack based language, but have been unsure about what sort of programs are interesting to build with this.
by rtpg 12y ago
always been interested in learning a stack based language, but have been unsure about what sort of programs are interesting to build with this.
- gre 12y agoFactor is general-purpose and you can write most anything you want at this point. Here's tar in Factor: https://github.com/slavapestov/factor/blob/master/extra/tar/tar.factor https://github.com/slavapestov/factor/blob/master/extra/tar/... For untarring the linux kernel, Factor tar beats /usr/bin/tar on my Mac by 1s, but 30s vs 6s on Linux for some reason. Could be SSD vs spinning disk, or worse i/o code on Linux. Funnily, there are about 10 files that differ in case only, and Mac file system is case-insensitive by default, so you can't even untar the linux kernel correctly. Here's host using the dns client library: https://github.com/slavapestov/factor/blob/master/extra/tools/dns/dns.factor https://github.com/slavapestov/factor/blob/master/extra/tool... https://github.com/slavapestov/factor/blob/master/extra/dns/dns.factor https://github.com/slavapestov/factor/blob/master/extra/dns/... I wrote it because gethostbyname is blocking and Factor has nonblocking i/o for everything else. There's a cross-platform disk usage tool that outputs the same stuff as df but works on Windows too: https://github.com/slavapestov/factor/blob/master/basis/tools/files/files.factor https://github.com/slavapestov/factor/blob/master/basis/tool... USE: tools.files file-systems. There's a high-level library for doing whatever you want with unix users/groups: https://github.com/slavapestov/factor/blob/master/basis/unix/users/users-tests.factor https://github.com/slavapestov/factor/blob/master/basis/unix... effective-user-name [ ] with-effective-user effective-user-id [ ] with-effective-user all-users https://github.com/slavapestov/factor/blob/master/basis/unix/groups/groups-tests.factor https://github.com/slavapestov/factor/blob/master/basis/unix... effective-group-name [ ] with-effective-group effective-group-id [ ] with-effective-group all-groups Graphics demo--raytraced spheres using GLSL on a checkerboard pattern, spheres each play their own music: https://github.com/slavapestov/factor/tree/master/extra/gpu/demos/raytrace https://github.com/slavapestov/factor/tree/master/extra/gpu/... https://github.com/slavapestov/factor/blob/master/extra/gpu/demos/raytrace/raytrace.factor https://github.com/slavapestov/factor/blob/master/extra/gpu/... The main file that sets up the world and loads the shaders and sound is 130 lines and reuses the game library.
- chipsy 12y agoI remember playing with the JS "Cat" interpreter[0] in college to get my feet wet. but for myself, the fun is in writing a toy concatenative language. The parsing difficulty borders on non-existent, making it easy to skip to thinking about semantics. once you actually try to implement programs within concatenative syntax, you will surely run into its main pitfalls: there are too many valid programs that produce wrong results, and there are whole new classes of errors introduced through having to maintain stack state yourself. writing code in this style can develop into a complex puzzle very quickly, although it's beautiful when it does work. [0] http://www.cat-language.com/interpreter.html http://www.cat-language.com/interpreter.html
- deleted 12y ago[deleted]
- astrobe_ 12y agoThe interesting thing about stacked based languages is not what you can build with them; it's the fact that you can build them yourself. The whole idea of picking a Forth or another concatenative language off the shelf is spoiling 3/4th of the concept. The point of stack languages is that they are very easy to implement. So don't learn a stack based language, make one and grow it until you can actually use it to make useful tools.