15 ms·
Joy (Programming Language)
- reedwolf 6y agoExample from C2[0]: (* x y percent approxEqual *) DEFINE approxEqual == 100.0 / rotate [0 =] [pop] [dup rolldown - swap /] ifte > [0] https://wiki.c2.com/?JoyLanguage https://wiki.c2.com/?JoyLanguage
- jayp1418 6y agoI still find ada language more advanced than current ones
- oddity 6y agoWhat do you mean? They’re different branches on the tech tree. Saying one is more advanced than the other is strange.
- msla 6y agoAda is just another Foogol, and is missing a lot of features from other branches of the language development world.
- Jenz 6y ago‘[M]ore advanced’ meaning ‘better’?
- ngcc_hk 6y agoVery confusing as just have another Joy web framework. For this kind of new language, one may have to have a kind of FAQ for the reason why it exists at all. Why not just FORTH?
- progre 6y agoThe language is 19 years old, it's not new.
- yiyus 6y ago> Why not just FORTH? Joy comes from a totally different background, and has a very unique set of features. The fact that a purely functional point-free programming language finished looked quite similar to Forth in some aspects was just an accident (a happy accident, imo).
- billfruit 6y agoThough there too much fatigue from trying to give mind space for new languages popping up almost every day, but this seems an older language. While I am not going to try it out, I can give you some ideas like : "The concatenation of two programs denotes the composition of the functions denoted by the two programs."
- Jenz 6y agoAs one might expect, ‘Joy’ is a popular name. IIRC the Crystal language was also initially named Joy.
- nivertech 6y agoIt's a functional programming language where every function is of type stack -> stack. I like concatenative languages[1] and especially pipelines[2], but IMO Forth-like stack-oriented languages are in the wrong direction, b/c they force programmer to manipulate arguments on a stack, which feels hackish. And my first real physical computer was an RPN calculator. As a kid I wrote lots of programs for it. Also b/c of their simple implementation, Forth-s and stack-based VMs are frequently used in the wrong domains, i.e. Bitcoin's Scripts and Ethereum's EVM. APL-family languages are better in this regard, but they also feel hackish in the general case, especially when passing arguments to nested functions. Copying RTL-style from math notation is also wrong. You are typing LTR (at least in English), but the expressions are evaluated RTL. Here Forth, RPN, and UNIX pipelines got it right. The interesting direction would be a programming language with following attributes: - Purely-functional - Statically typed with an algebraic type system - Concatenative [1] - Tacit / Pipelines [2] - Homoiconic - top-to-bottom, LTR [1] https://en.wikipedia.org/wiki/Concatenative_programming_language https://en.wikipedia.org/wiki/Concatenative_programming_lang... [2] https://en.wikipedia.org/wiki/Tacit_programming https://en.wikipedia.org/wiki/Tacit_programming
- vanderZwan 6y agoI think your list basically describes http://kittenlang.org/ http://kittenlang.org/ which sadly has kind of halted in development because the sole dev working on it couldn't get anyone else on-board. Probably because it occupies a pretty rare niche of computer science interests.
- nivertech 6y agoany relation to Cat [1]? [1] https://web.archive.org/web/20150205081218/http://cat-language.com/manual.html https://web.archive.org/web/20150205081218/http://cat-langua...
- vanderZwan 6y agoIt's a direct inspiration - hence the name ;)
- vincnetas 6y ago"In Joy, everything is a function that takes a stack as an argument and returns a stack as a result. " But formal parameters are same things[1]. It's just a values pushed to stack before calling a function and values poped from stack on return. That's why you get stackoverflow exceptions in java when your recursion fails. EDIT: [1]most of the time, in situations that i know about.
- boomlinde 6y agoThe difference is that in one case it's an implementation detail covered by an abstraction to make that fact irrelevant to the programmer, and in the other the language is fundamentally designed around the idea that the stack itself is exposed as a data structure to the programmer. If you don't understand how the difference is significant, I suggest trying a language like Joy, Factor or Forth.
- throwaway_pdp09 6y agoI fully understand the difference but having read up on forth but never used it, I don't know if it's helpful in that sense. Exposing the stack fully is a weakness not a strength to me. I also understand that this is a formalisation that supports concatenative programming but from a user point of view, does it fit human comprehension as well as, or better than, a more conventional language. Honest question, thanks.
- vincnetas 6y agoclass Fun implements Function<Stack, Stack> { public Stack apply(Stack s) { return s; } } So this is Joy in Java. But as my neighbor comment asks. How does this benefits a language as tool for humans to get job done (c). From my perspective it only brings you down the abstractions ladder.
- vanderZwan 6y ago> it only brings you down the abstractions ladder. Ironically I'd say you're both right and wrong at the same time because of the somewhat paradoxical nature of concatenative languages: you're closer to the metal (especially with Forth) but at the same time working with Forth is an exercise in abstracting everything away. The strength/weakness is that it has only one hammer to do so: defining Forth words to manipulate the stack ("words" == Forth lingo for functions, more or less). It has a Lisp-like minimalism (you can almost think of it as postfix-Lisp in some sense). The Fun class you describe misses the point entirely of the minimalism of Forth or Joy - the complete lack of syntax is a feature that makes concatenative language inherently composable in ways that other languages can only dream of. In a language like Python, you could compose three function calls like so: y = foo(x) z = bar(y) w = baz(z) In a language like Joy (or Forth, or Factor) you would write: x foo bar baz .. where the x is only included if we assume it is a stored value that has to be put on the stack first. Ok, sure. But here is the thing: imagine that I wish to refactor calls to foo and bar into their own function (this particular example is childishly simple of course, but I think it gets the conceptual point across). Compare the Python and the Joy ways of doing that: def bla(x): return bar(foo(x)) DEFINE bla == foo bar The difference is small but significant. Because the concatenative languages have no function application, refactoring is often a simple cut/paste operation, followed by one big find/replace. You can literally split (almost) any piece of code into parts at any point, define those parts as new words, and the result would be valid code. Precisely because of the brutal minimalism at play here. The trade-off is an upfront cost of having to structure the entire program around stack operations, and thinking in a postfix way of doing operations. I'm not saying that makes them better - I like my type checking very much, and in the right amounts a bit of boilerplate makes code a lot more self-documenting. But I also think that learning how to solve problems the "Forth" way is a good programming exercise.
- toolslive 6y agoJoy is great (at least better than SQL) as an API to a database. IE, every query is a joy program. If you add get, set and (de)serialize as primitives, you have stored procedures, intermediate results, galore! Want to transform your result before you send it back to the client ? no problem, just add a transformer function.
- mafm 6y agoCan you add a link pointing at some examples?
- toolslive 6y agothere's a bunch of research related to 'stack based query languages' google for SBQL. Anyway, in the specific case of joy is more difficult to dig up. Here's an example (I know it, because I implemented it): https://github.com/openvstorage/arakoon/blob/lsl/src/system/single.ml#L416 https://github.com/openvstorage/arakoon/blob/lsl/src/system/... "script1_" true "script2_" false 0 [POP; 1; ADD] FOLD_RANGE The above program has basically calculates the number of keys between "script1_" inclusive and "script2_" exclusive. It's really compact flexible and powerful. Now, before you run off and think about implementing this yourself. First have a look at kitten: https://kittenlang.org/ https://kittenlang.org/
- botwriter 6y agoDon't think this will catch on in Cambodia, Joy means Fuck in Khmer.
- co_dh 6y agoThe point of Forth/Joy is that the language is so simple, you don't need compiler. It is a minimum language.
- kalium-xyz 6y agoMichelson language has distinctly ruined my taste for language like this.
- Gormisdomai 6y agoThe coolest part of this article imo is the binrec operator. Do other languages have something similar?
- carapace 6y agoI've been working with Joy for several years now, on an off, in a hobbyist way, and I've got to say, I think it's the most useful, simplest language. (I've made implementations in Python and Prolog https://joypy.osdn.io/ https://joypy.osdn.io/ )
- amelius 6y agoFrom many viewpoints a stack is a nuisance, for example memory management and context switching. Therefore I think that languages which use a stack are going in the wrong direction.