Why aren't you using Factor Zig Forums?

Why aren't you using Factor Zig Forums?

factorcode.org/

Sure it's a concatenative language and that's obscure as hell but it turns out using functional composition can lead to a lot of elegance.

USING: kernel sequences unicode ;IN: palindrome: normalize ( string -- string' ) [ Letter? ] filter >lower ;: palindrome? ( string -- ? ) normalize dup reverse = ;

Consider the simple example they use for palindromes.

Without using any variables, and with only function composition it can express a very robust word for finding palindromes. This function will even go as far as finding if
"A man, a plan, a canal: Panama" is a palindrome.

Some of factors main merits:

Fast (SBCL level, which puts it far above many other languages)

Multi-paradigm with an Object System approaching CLOS capabilities.

Introspective and Exception system close to or exceeding Common Lisp

Meta Programming capabilities possibly exceeding Common Lisp

-- Because there are hardly any variables you get to use defmacro as if it were a hygenic macro because there's no variables that can be accidentally captured.

No Cruft and possibly the most beautiful layout of any src directory I've ever seen.

Massive standard library with plenty of stuff to make good applications now.

Hands down one of the greatest C FFI's I've ever seen. (And I've looked at/used many)

Image based development with a fully featured REPL that possibly even rival's slime.

For deployment you can specify exactly what you want to be included leading to the ability to produce extremely small executables. (Unlike most Lisp's where you keep the image and have to lug around a many MB image)

The ability to actually view a closure's contents on the stack. Since you can use quotations like [ 3 + ] to produce a curried lambda function which you can place directly on the stack you get to view [ 3 + ] instead of something like lisp's (Compiled-Closure x03408342) or Haskell's "Sorry can't show that".

And for the final benefit the possibility to implement a linear type algorithm (or uniqueness types) goes pretty hand in hand with concatenative programming which is pretty freaking awesome if you look into it.

Common Lisp is dead. Factor is the new Lisp. So why not give it a shot?

Attached: eb58f7b72ac40771239a5bdb944af43b.jpg (236x301, 18.03K)

Other urls found in this thread:

concatenative.org/wiki/view/Concatenative language
github.com/eteran/c-vector).
oforth.com/
gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blob_plain;f=basis/glib/ffi/ffi.factor;hb=c6f2cbdeaf8cc4a858dc93f0e4858a1f91bf8d58
compilers.iecc.com/crenshaw/
builds.factorcode.org/release?os=linux&cpu=x86.32
factorcode.org/
github.com/factor/factor/issues/2039
github.com/factor/factor/issues/1262
twitter.com/AnonBabble

As a FORTHer, it's nice, but it's so inane to use. The cool features like UI development are awkward to use and impossible to learn (the documentation is too technical), the syntax can be weird, and the fact you have to make sure to be USING: every single minor feature of the language is a huge pain in the ass. And what's the point in being concatenative if your entire language would work better with regular braced syntax? Don't get me started on the ways the compiler can get annoying.

The directory shit is incredibly annoying, the scaffolding tool is shit, "no cruft" is accurate, but it's all replaced with weird inclusions of bloat. Have you actually written anything, as opposed to using examples included in the "My First Program" cookbook? I would recommend Factor over Scheme or Common Lisp. I would recommend Factor over Python to anyone who wasn't already writing Python. But Factor is so awkward to use it's barely worth it. Get Reva Forth or something that compiles executables (Jewish Ron's 8th has a closed source compiler).

I mean, fuck: Retro Forth can do palindromes in four words,
:s:palindrome? (s-f) [ s:hash ] [ s:reverse s:hash ] bi eq? ;'ingirumimusnocteetconsumimurigni s:palindrome?
and if you want i'll give you an equally simple defintion as yours to do sentences.

But to be honest:
IF YOU'RE NOT ALREADY A FORTHer, USE FACTOR!
It's actually alright

*sorry, five words.
To do it, ignoring punctuation:
:palindromic-sentence? (s--f) [ c:letter? ] s:filter s:to-lower [ s:hash ] [ s:reverse s:hash ] bi eq? ;'A_man,_a_plan,_a_canal:_Panama palindromic-sentence?

I don't know why I'm being so hard on Factor. Sorry to shit on your parade, OP, but your post didn't really demonstrate the power of factor, you could've used gadgets to build a palindrome-solving widget in only a few more lines, which is real powerful. Also Factor has native GUIs for each system you run it on. Sequences are really powerful, and the language has massive support for functional programming, including Tail Call Optimisation and Tail Call Elimination on every compiled word.

You can even tell the concatenative paradigm to get fucked when writing Factor, it has the power of optional locals (an example from Rosetta Code):
USING: kernel math locals combinators ;IN: mathfunctions:: ackermann ( m n -- u ) { { [ m 0 = ] [ n 1 + ] } { [ n 0 = ] [ m 1 - 1 ackermann ] } [ m 1 - m n 1 - ackermann ackermann ] } cond ;

The compiler for Factor is actually brilliantly genius. And the guys behind it are, too. There's an emacs mode for Factor which is great, called FUEL-mode.

TRY FACTOR, TODAY!

WHY AREN'T YOU USING C
niggercattle everywhere

It’s all good bro. I appreciate the input as I just started looking into factor last night.

I’ve thought for awhile that the intersection of lisp and forth would be my perfect language and it seems like factor comes pretty damn close to that.

Would it be a good idea to learn Forth more before going to Factor? They don’t have a lot of tutorials so I need to get my concatenative chops down somehow.

Why all the unnecessary symbols? Fuck, why digraphs of all things?


t. nogrammer memester

C is great, and it's great for writing hardware and system-level programs because of the time compilers have dedicated to working on improving C compilation. But C isn't at all perfect. C has really annoying shit you can't work around without cutting features or making a horrible mess. But you don't care, you're not a programmer, just a LARPer.


My only advice is a cardinal rule I had to apply when interacting with Factor: Factor IS NOT Forth. It is a concatenative language, and concatenative is not synonymous with Forth. All concatenative really means is that a program is defined by the sequential application of functions to functions (that's my opinion/definion, I don't think concatenative is really well-defined).


None of the symbols are unnecessary. If you want any explained I can probably tell you without launching an editor or opining the docs

Does this just mean there is partial function application?

So, mostly useless but you're going to shill for it every day?

concatenative.org/wiki/view/Concatenative language


Lisp isn't useless. Writing a text editor for the umpteenth time is useless.

...

Misreprenting what undefined behaviour means and can do, noice
"random SJWs" form committies, retard. BDFL has always been the best solution. ANS(I) kills languages.
What does `a[i] = i++` do?

Most C UBs are easy to remember though. Stuff like "don't modify a variable more than one time in a statement", "don't rely on signed integer overflow" or "don't assume function argument evaluation order" aren't that hard to understand nor is the reason for their existence.
As a C programmer, I now understand that 95% of its problems are due to its age (and wanting backward compatibility with the K&R era stdlib and syntax) and the remaining 5% to its design of being as low level as possible (C++ and Rust wants zero-cost abstraction, C wants zero abstraction). I'd be quite happy with builtin array support (fortunately, I cobbled something together akin to github.com/eteran/c-vector).

A C2 simply modernizing all this shit with length based strings (finally being uint8_t arrays), using stdint.h types everywhere, cleaning up the stdlib (using arrays instead of strings allows to remove all the strn* function and add those lacking, like regexec not havin a n version), maybe finding a way to make something like templates (some help from the language to implement genericity, basically), maybe removing the concept of header with the use of stuff like static and extern to quality function visibility directly, add more of GCC's attributes to the standard, better wchar functions and a set of mb_ functions to work on multibyte representations instead of 4 byte codepoints.

This isn't exhaustive, but you get the idea: it's not very hard.

1. slava is a bitch and should get fucked
2. 'concatenative' is just stupid as a category of language.
3. just use Forth. Forth has actual advantages vs. other languages due to it being very low level while being very capable of stacking up on abstraction, *capability* of writing very very clear code due to the free syntax (not 'functional composition), and high quality native code implementations. Forth's only problem is that its proprietary implementations are way better than its free implementations, but gforth and ciforth still ain't bad. You can extend Forth to have Factor-like features but with Factor you're using what slava deigns to give you
4. if you just can't into Forth, then stop bothering with fake 'concatenative' genres try oforth.com/

Why are proprietary implementations of forth 'better' than open source ones? How do you go about implementing forth? Anyone still using forth?

what.
gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=blob_plain;f=basis/glib/ffi/ffi.factor;hb=c6f2cbdeaf8cc4a858dc93f0e4858a1f91bf8d58
apart from that it's similar to an FFI that iforth and mpeforth both have (sf's FFI is simpler) - all proprietary Forths though
gforth's FFI is nuts, requiring gcc at runtime, but it's much more capable

*shrug*. just the way of things somehow.
iforth is not very proprietary - you pay $100 and then you get a "do literally whatever you want, including giving this to other people without paying me" license. but, you're never given the kernel source, so you can only dive so deep into iforth itself. it's still about the best forth for a lot of purposes.
implementing forth is not very hard and lots of people have done it, but there's a lot of lore about implementation techniques in the community that you can learn to do it better than you probably would with a cold design. if you're interested in implementing forth then you're not very interested in the language really, are you? why waste your time? go implement Lisp in some language that does interest you, check out jonesforth or yourforth (basically jonesforth but by the ciforth guy)

Thanks for an actual reply. I'm interested in it as a bystander mostly. I have done the implement a lisp in c book, it was fun. Any other recommendations for work along those lines? A bit offtopic ik

not that interested myself, but people usually recommend the dragon book. I picked up a 'write an interpreter in Go' book (not going write in Go though) but haven't gone through it yet so can't recommend.
compilers.iecc.com/crenshaw/ is very good but it might not interest you after that lisp book.

Not an argument
Concatenative is a special case of functional. Get fucked brainlet.
Mostly agree, but Factor isn't Forth. It just inherits the syntax and some semantics.
Anyone can "into" forth.


Because gforth devs keep changing the FFI for no reason


Starting Forth, and Thinking Forth, both by Leo Brodie.
Liz's book isn't really great

What does
: normalize ( string -- string' ) [ Letter? ] filter >lower ;: palindrome? ( string -- ? ) normalize dup reverse = ;
do?

weird, it's super persuasive for me
Not a definition.
Also I totally think of FP when I think of Forth. Yep. The language just *radiates* FP-ness.

Those are perfectly reasonable semantics in line with the syntax of the language. You're exposing yourself for being a nogrammer LARPer by failing to understand that.

a[i] = i++ is undefined behaviour. It could mean literally anything because the syntax is quite poorly defined.

: normalize ( string -- string' ) [ Letter? ] filter >lower ;: palindrome? ( string -- ? ) normalize dup reverse = ; Does exactly what any Factor programmer would think, and you could even reason about it without ever having seen the language before.

>: ( string -- string')
`:` starts a definition, `` is the name of the subroutine (word), `( x -- y )` is a stack comment showing how the word works (string is transformed, producing string'). ` [ ] `are braces for a quotation, which puts the contents (`Letter?`) as executable tokens on the stack rather than executing them immediately. `filter` applies the quotation to the characters in the string. ` >lower ` turns something "to lower(case)".

Everything in Factor's syntax is well defined, it's an inherent advantage of the concatenative paradigm. This isn't hard. You're just a brainlet who can't even click the link in the OP to begin to learn more.


Your want to be a smart-ass about something does not invalidate its legitimacy

s/executing/compiling

No, it really is. If 'concatenative' means anything, Forth is an example of it. If 'concatenative' means FP, then 'concatenative excludes not only Forth but even more concatenative languages like UserRPL or PostScript. There is nothing FP about these languages. It's even worse than calling Lisp FP.

There's no binary for Linux. Why should I care?

Yes, there is
You are just stupid

what?
builds.factorcode.org/release?os=linux&cpu=x86.32

FP doesn't mean "purely functional" as in haskell, dumbass. Forth is a functional concatenative language.

then 'functional' means nothing.
I'll just talk about ML-like languages in the future.
We could've had FPSes, but instead we have to have Doom-likes, because some jerk decided that Dark Souls was an FPS.

Love Factor, it's really the best stack based language for a modern environment.


You make a FORTH by writing a few small functions in assembly language on the bare metal. Once you're done with that you can make your standard dictionary with FORTH itself. Or you can write it in C or another programming language, but that's not really what FORTH is for.

Forth is for whatever you want to do with it. The only difference language implementation makes is execution speed, if implemented correctly.

Good question OP

How you enjoying it, OP

Forth is a meme. It used to be occasionally useful when size was extremely limited and was more important than speed. Today it has no purpose other than if you're stuck maintaining ancient embedded hardware that used it.
Zig Forums treats it as some sort of magical language that can do anything when in actuality it's a primitive stack machine and slow. It shares more in common with flash than C.

Forth has two stacks.
No.

Chuck is past regular Forth VMs anyway. His current chips use circular stacks and 5-bit opcodes for maximum efficiency.

Also, Factor isn't Forth

C-c C-d d to pull up documentation for any word is a godsend.

I love this language. Reading some of the simpler libraries now to get my head wrapped around it.

HELP IFORTH ( "name" -- ) Parse name delimited by a space ignoring leading delimiters. Find an entry in the glossary help file forth.hlp and list that entry to the screen. HELP is not part of the kernel system but can be loaded by including the file help.frt. By default the file forth.hlp contains a copy of the glossary of Forth words from your manual. Thus HELP provides an online manual for Forth words. Note that any typesetting that is in the manual is removed so only ASCII text is left. The text in the help file is automatically generated from the original glossary documents, so there are no textual differences between the printed and the online version of the manual. okwow what an uncommon feature

iforth isn't an Emacs mode

iforth isn't even Free Software

I assume this is C code.
What happens according to "standardese":
I fail to see the undefined behavior. It's all perfectly clear.

Maybe read the standard mate

Ups. Looked elsewhere. You're right.
At least you can still just write: a[i] = i; i++; instead.

It's a random mess of different symbols. I doubt anyone who isn't familiar with this class of languages could tell you what it does.

Most of it is plain english

KipIngram in the #Forth IRC spams it to shit talking about his fucking shitty Forth project with no source and endless ideas-guy tier ideas and I hope he blows his fucking brains out

bomp

lol another gay joke of a language < --- UseLeSS < ---

C and its derivatives give applications

python gives scripts for L33T H4ck3rZ

javascript needs to die and LISP is for jews like (((you))) OP

Another cool thing about factor is it's linter. It will read your source code and then search any libraries you've imported to see if you accidentally reimplemented something already written.

for instance you might put

[ length swapd ]

and it will realize you actually could have used

[ (split) ]

The effect is that all your code becomes simpler and more terse while retaining the same use without having to rewrite helper functions. It looks like it can apparently do this because it can reason about the stack effects.

It's a very cool system.

Autodocumentation is literally two lines of code you run in the repl and then you can fill in details in the generated markup document.


Lisp =/= Factor/Forth

>lol another gay joke of a language < --- UseLeSS < ---

A "gay joke" of a language is all the bastardized attempts at emulated C-syntax and stuffing it into a higher level language. Which is most languages in existence.


Buggy, drone-written crap. We can express things much more elegantly if we accept a different logical base as opposed to "muh description of how a computer is modeled"


Python is the worst example of trying to solve too many syntactical rules by adhering to no-syntax.

It's a complete joke and should be considered the new Dijkstra's "programming in BASIC will cause brain damage"


Agree

> LISP is for jews like (((you))) OP

Jews always win though, is this a complement?

Nobody thinks in postfix. This is the most unnatural, brain-contorting way to syntact your language. Please stop doing it. Just look at this mess:

: sign-test ( n -- ) dup 0 < [ drop "negative" ] [ zero? [ "zero" ] [ "positive" ] if ] if print ;

Like what the fuck? Who thinks programming like that is a good idea? Am I supposed to read this while staring at the computer screen through a mirror like it's some manuscript of Leonardo Da Vinci?

Secondly, you can get the concatenative paradigm in applicative languages. Even in the shitlang called Javascript, you can make a prototype object o with a bunch of "chainable" functions f,g,h and then sequentially transform an instance of it by going something like o.f().g().h(). In a less-retarded language that has macros (like Clojure) you can write a thread-forward macro (>>) and then write your functions f, g, h to accept object o as their first argument like:

(>> o (f ...) (g ...) (h ...))

The advantage of this is that you get a language that allows you to break into the concatenative paradigm when it's more natural to do so and then return to the applicative paradigm when it isn't (which is most of the time).

It's really fucking easy if you learned FORTH as a kid or learned how to program an HP RPN calculator. It's too much for brainlets though.

For those of us with brain cells, it's super easy to understand. You're either pushing stuff onto the stack or popping it off with operations.

two journeyman bickering like girls
while a crowd of apprentices looks on in confusion
and the masters in disappointment

Everyone should be using assembly. With enough macros you could literally have multiplatform environments that enable you to get your goals to the metal as swiftly as shells/scripts with the power and speed your ISA permits.

Prove me wrong faggots

k well you asked why I'm not using factor and it's because i want to write "if condition then x else y" and not "condition [x] [y] if" on account of me being a human and not a 40 year old calculator


I'm not saying use clojure. My point is that you don't need this wrong backwards way of doing things. Most languages look like algol (including "pseudocode") because most brains think like algol, which is to say, from start to finish. RPN is just a worse way of writing stuff.

Intel's architecture now supports what, over two thousand instructions? It'd be macro hell.


Brainlet then.

how is this even employed

Attached: Screenshot 2018-09-29 at 12.07.30 AM.png (1166x214, 50.28K)

It's really not brainlet. Brainlets wrap their mind around a language; normal mold the language to their needs. You would know if you were an EXPERT PROGRAMMER like me.

bamp

who the fuck writes the syntax like that? There are many ways of doing a sign-test and I wouldn't indent the syntax like that with any of them.
USING: combinators ;: sign-test ( n -- ) { { [ dup 0 < ] [ "Negative" ] } { [ dup 0 > ] [ "Positive" ] } [ "Neither" ] } cond nip print ; Would be my suggestion, I think it's in the documentation somewhere.

You're just too stupid to think about what you're typing, rather than slamming the keyboard as fast as possible

Also, you're still a brainlet, besides being able to use Factor's parsing words to form an `if` that has your preferred syntax - regular Forth has almost exactly the syntax you think of for an if statement if x else y then as opposed to clojure's(((((if) then (then else ) when? (if then else then)((()()())(((clojure cucks)))())

hmmm which is less retarded (sorry about my LISP syntax, I did SICP in Forth, don't really know much about LISP, but it gets the point accross)
\ Just random shit: x 33 10 */ ;: y abs 20 mod ;: word 0< if x else y then ;(define x (n) (/ (* n 33) 10))(define y (n) (mod (abs n) 20))(define word (n) (if (< n 0) (x n) (y n)))
🤔

stupid lisp clojure faggot can't even read postfix, babby duck syndrome supreme, and thinks his shitty meme popular lang is any good. Clojure is for faggots and Elixir will kick Clojure's ass in the long run

BEAM is less suited for generalized computation than the JVM. Kotlin will beat both.

Generalised computation isn't restricted by BEAM. What the fuck are you talking about?

(defn palindrom [string] (->> string clojure.string/lower-case ((juxt identity clojure.string/reverse)) (apply =)))(defn palindrom-sentence [string] (palindrom (clojure.string/join (re-seq #"[A-Za-z]" string))))

What the fuck is that monstrosity

The least retarded is prefix notation because the operation is stated first and then the operands come after. For example, "x" in your example is read "divide (the product of n and 33) by 10". Assembly operations are written like this too. eg intel syntax: "mov ax, 1" is read "move into ax, 1" and it would be "move 1 into ax" if using at&t syntax. Any C-style language uses a function calling syntax like fn(a, b, c, ...) because you want to know what you're doing first, then the details second.

Now lets look at how to read backwards-ass postfix. "33 and 10, multiply them and then divide the top of the stack by that". At the expense of parens you have something that must be read in its entirety before it can be understood. On the other hand, prefix can be gradually understood as it is read, left-to-right.

"Here's the data you want, now do this to it"

...

"Intel use this established syntax" is not an argument fucking moron. Various architectures have various syntaxes for assembler. GA144 assembler is basically colorForth, it's a one-pass compiler. You're still writing a HLL for the Intel piece of shit CPU, because your """nice""" Intel/AT&T syntax is still being converted to uops on the CPU which then converted to hex machine code, so fuck off retard

wrong, because data could be of varying size and usually can be far larger than any operation identifier, and because knowing the operation beforehand lets you do validity checks on the data/better optimization with out of order magic.
there's a reason function calls are usually in the form function(data,moredata,evenmoredata) instead of data,moredata,evenmoredata(function).
there are a few good cases for the latter too, of course.

Forth compilers can optimise and do """validity checks""" if you need it. But Forth is usually interpreted. You know what you could do if you want to add 20 items instead of two?
You could `: add 0 + do loop ;` or clean your stack like a good boy and add to depth. You could also modify INTERPRET to count some variable up until the lastest operation. There are loads of solutions to your non-problem. Only in Lisps are you doing `(+ 1 2 3)` and if you can't type `6` or if you struggle to understand `3 2 1 + +` maybe you should blow your brains out. Come up with a real problem.

factorcode.org/
OS?
Arch?
So not really that portable.

If you use some retarded distribution with no features, but can't figure out how to compile a simple program, you should kill yourself

You don't seem very knowledgeable. Think for a second to figure out how the script is "Finding OS..."
It uses `uname -s` to find the OS just like every other build script unless it uses that lsb_release stupidity.
In this case though... if it doesn't like what it finds then it simply throws it away and coyly prints that it can't find the OS.
find_os() { if [[ -n $OS ]] ; then return; fi $ECHO "Finding OS..." local uname_s=$(uname -s) check_ret uname case $uname_s in CYGWIN_NT-5.2-WOW64) OS=windows;; *CYGWIN_NT*) OS=windows;; *CYGWIN*) OS=windows;; MINGW32*) OS=windows;; *darwin*) OS=macosx;; *Darwin*) OS=macosx;; *linux*) OS=linux;; *Linux*) OS=linux;; esac}
So when the authors say Unix they really just mean OSX and Linux. Only one of those is Unix. See if you can figure out which one. This naievity is reflected in the GNUmakefile targets.
So no. I'm not going to spend my time personally porting some esoteric game scripting language who's only killer feature is that it'll give you 1337 h4xx0r st4tuz.
OP asked why I don't use it and that's why. Like I said, maybe I'll check it out again when It's more portable github.com/factor/factor/issues/2039 . Looking at their (((GitHub))) stuff it seems unlikely.

...

CLOJURE IS FOR RETARDS

It's not just the build script idiot.
github.com/factor/factor/issues/2039
github.com/factor/factor/issues/1262
So no. I'm not going to port this garbage just because I want to look kewl on a Zig Forums thread.