Earlier quoted context omitted.
Was / is Forth good and useful? Bonus; is it fun?
It's fun to learn, and one of the first interpreted environments. What it enables is quick development on platforms with modest resources! Instead of compiling and executing you could develop quickly! Haven't used it for anything more than to do some examples in some tutorial. One thing that's nice about the language is that it's the simplest language you can implement on your own without going insane!
Show HN: Forsh – A Unix shell embedded in Forth
11–20 of 23 posts
Re: Show HN: Forsh – A Unix shell embedded in Forth
#12Didn't the old Sun workstations boot into a Forth interpreter?
Was / is Forth good and useful? Bonus; is it fun?
I've written a couple of intepreters for the language, in Perl, in C, and used it on cheap ESP8266 chips, but its something that's more of a fun diversion than a practical/useful thing for me.
So in short "Yes, it is fun", but I'm not so sold on it being "useful", except that learning new things is almost never a mistake.
Re: Show HN: Forsh – A Unix shell embedded in Forth
#13Didn't the old Sun workstations boot into a Forth interpreter?
Was / is Forth good and useful? Bonus; is it fun?
Concatenative programming exposes you to a new style of thinking—IMO it’s the perfect marriage of imperative and functional programming, because you can reason about your code either way: as a “pipeline” composition of functions, or as a sequence of imperative operations on the data stack. In terms of PL theory they have a bunch of elegant algebraic properties too.
Re: Show HN: Forsh – A Unix shell embedded in Forth
#14Earlier quoted context omitted.
Was / is Forth good and useful? Bonus; is it fun?
It's fun to learn, and one of the first interpreted environments. What it enables is quick development on platforms with modest resources! Instead of compiling and executing you could develop quickly! Haven't used it for anything more than to do some examples in some tutorial. One thing that's nice about the language is that it's the simplest language you can implement on your own without going insane!
Re: Show HN: Forsh – A Unix shell embedded in Forth
#15Earlier quoted context omitted.
Was / is Forth good and useful? Bonus; is it fun?
It’s very fun as low-level languages go. I like gforth[1]. If you want modern high-level languages in the same family, look into “concatenative programming”. In particular, Factor[2] is a cool Smalltalk-like object-oriented concatenative language with a nice interactive environment. It’s still under somewhat active development, but they could really use more users to drive progress. Concatenative programming exposes…
Re: Show HN: Forsh – A Unix shell embedded in Forth
#16Earlier quoted context omitted.
Was / is Forth good and useful? Bonus; is it fun?
It’s very fun as low-level languages go. I like gforth[1]. If you want modern high-level languages in the same family, look into “concatenative programming”. In particular, Factor[2] is a cool Smalltalk-like object-oriented concatenative language with a nice interactive environment. It’s still under somewhat active development, but they could really use more users to drive progress. Concatenative programming exposes…
Re: Show HN: Forsh – A Unix shell embedded in Forth
#17Earlier quoted context omitted.
Yes they did.
As did various offerings from Apple, IBM, and several others, once upon a time: https://en.wikipedia.org/wiki/Open_Firmware
Re: Show HN: Forsh – A Unix shell embedded in Forth
#18Earlier quoted context omitted.
It’s very fun as low-level languages go. I like gforth[1]. If you want modern high-level languages in the same family, look into “concatenative programming”. In particular, Factor[2] is a cool Smalltalk-like object-oriented concatenative language with a nice interactive environment. It’s still under somewhat active development, but they could really use more users to drive progress. Concatenative programming exposes…
Is Factor still being maintained? I seem to remember that the 0.97 release came out some years ago, and it's worrisome (in terms of investment of time in learning a new language) to think it might be frozen pre-1.0 release.
It seems to be useful & stable enough for real work, although I have an ulterior motive as well. I work on Kitten, a statically typed concatenative language (Factor : Smalltalk/Lisp :: Kitten : OCaml/C), and I’m hoping to (finally) get out an initial release soon. So I have an incentive to tell people to use Factor, to get more people interested in the paradigm so they go seeking other offerings if they find it interesting/useful but Factor isn’t a good fit.
Re: Show HN: Forsh – A Unix shell embedded in Forth
#19Earlier quoted context omitted.
It’s very fun as low-level languages go. I like gforth[1]. If you want modern high-level languages in the same family, look into “concatenative programming”. In particular, Factor[2] is a cool Smalltalk-like object-oriented concatenative language with a nice interactive environment. It’s still under somewhat active development, but they could really use more users to drive progress. Concatenative programming exposes…
Since you bring up concatenative programming in general, I recently came across https://concatenative.org and think some people here might like it.
[1]: irc://freenode.net/#concatenative
Re: Show HN: Forsh – A Unix shell embedded in Forth
#20I did a Forth-like Unix shell in college (mid 90s) as a class project [1]. The differences I see from mine are: 1) I made Unix commands a first-class variable type. You could create a single Unix command and store it into a variable. You could also set up several commands as a pipe, and save that into a variable. 2) redirection and pipes are more Forth in style. Much like adding two values: 2 3 + To create a pipe, yo…
There is nothing stopping Forsh from being used that way. The convenience words from the README use a global variable to tell them where to build commands and overwrite the memory for every new command because the common case is that you as a user don't really care much about having arbitrary history (In any case, gforth already uses readline, so I get history for free). The words underneath all take that location as an argument on the stack. You could write some words that allocate space for each new command without changing the underlying libraries.
The key to thinking about pipe words in Forsh is that they execute a given command and consume and/or leave a file pointer to a command's stdout on the stack. This is why there are multiple pipe words. They have different stack effects.
`>|` (begin pipeline) only leaves a file pointer. `|` (continue pipeline) consumes and leaves a file pointer. `|>` (end pipeline) only consumes a file pointer.
This allows the pipe words to interoperate with any file I/O words in gforth.
If you want to "save a command to a variable", you just use a regular Forth word. [bracket] words make things work in compile mode.
`: hack [c] echo [p] hack! $ ;`
Executing hack will then build and execute the command. This also works with arbitrary pipeline fragments.
I did my best with syntax, but existing shells have already aggressively minimized typing for short commands. The most I could do was have people type `l ` instead of `--` for long options and `s ` instead of `-` for short options. However, I find quoting much improved over existing shells. You specify the quote character when you type the command, so there is no escaping. You just pick a character that doesn't exist in the string. You are ok as long as your string does not included every printable ASCII character.