6 ms·
Hurl, a terrible (but cute) idea for a language
- deleted 3y ago[deleted]
- smackjer 3y agoI think I'm gonna hurl!
- lnenad 3y agoFYI Bitlocker shows ntietz as a virus and won't let me access it.
- ntietz 3y agoThanks for letting me know! I couldn’t find anything about Bitlocker as antivirus but assuming you’re talking about BitDefender (which also has flagged it). I’ve submitted a false positive report.
- LinuxBender 3y agoIt looks like a few vendors are flagging the URL. [1] Not sure why. Nothing sticks out at me on urlscan [2] You may have to reach out to those vendors to see what is tickling their detectors. [1] - https://www.virustotal.com/gui/url/d4deec9bca49cdedb57d059d909018966c9d2b21d6662002379b13207e6a4a29/detection https://www.virustotal.com/gui/url/d4deec9bca49cdedb57d059d9... [2] - https://urlscan.io/result/157fd01c-3442-43ae-a563-77ac7af2dcb4/#summary https://urlscan.io/result/157fd01c-3442-43ae-a563-77ac7af2dc...
- ntietz 3y agoHmm interesting, if anyone can help me track down why I would greatly appreciate it!
- firstlink 3y agoI trust you already obtained the proper licenses from your local authorities before designing and implementing a new programming language? And those licenses are on file with the major security vendors?
- alexisread 3y agoI did find the licences in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying ‘Beware of the Leopard.
- lnenad 3y agoBrainfart, yes BitDefender!
- remram 3y agoThe cute idea is: > the only control flow you get is error handling (and function definition/call, just without returns)
- juujian 3y ago"Hurl" is terribly cute, but I suspect you could be even more successful if you had called it "yeet" :)
- Quarrelsome 3y agohurl has the enjoyable duality where it can mean throw or vomit, where in the case of this language's curious construction both meanings apply.
- ntietz 3y agoThis was a consideration in naming the language
- Quarrelsome 3y agoit is most admirable naming <3.
- Deukhoofd 3y agoRust already uses that for a similar feature. https://doc.rust-lang.org/beta/unstable-book/language-features/yeet-expr.html https://doc.rust-lang.org/beta/unstable-book/language-featur...
- knome 3y agoYour 'toss' primitive looks like common lisp's condition+restart, using a catch-block syntax in place of a `handler-bind` function. https://stackoverflow.com/questions/36178141/common-lisp-exception-handling-condition-and-restart https://stackoverflow.com/questions/36178141/common-lisp-exc...
- debarshri 3y agoNot to confuse with Hurl.dev[1], which is a net request automation tool [1]https://hurl.dev/ https://hurl.dev/
- lfconsult 3y agoRight.
- chomp5977 3y ago[flagged]
- dcsommer 3y agoI love this exercise. Great job exploring a concept fully. I find this article one of the better arguments I've seen yet against including exceptions in a language.
- lpghatguy 3y agoThis is incredibly funny and also brilliant: toss/return is an implementation of algebraic effects!
- gpderetta 3y agocall/cc as the only control flow primitive!
- firstlink 3y agoAlgebraic effects use delimited continuations (and this appears to match toss/return). Call/cc captures an undelimited continuation. Totally different.
- gpderetta 3y agoYes delimited continuations are better in practice, but call/cc is more iconic.
- dirkt 3y agoAlso called "continuation monad", which can be proven to be universal. So, no surprise.
- throwaway17_17 3y agoThese three comments as a chain are hilariously close to the paper ‘On the Expressive Power of User-Defined Effects: Effect Handlers, Monadic Reflection, Delimited Control’ by Forster,Kammar,Lindley,Pretnar. It’s relatively new and evaluates the expressive power of the three concepts, which barring preserving typability during translation, are equivalent. 1 - https://ps.uni-saarland.de/Publications/documents/ForsterEtAl_2017_Expressiveness-Effects.pdf https://ps.uni-saarland.de/Publications/documents/ForsterEtA...
- alexisread 3y agoYou can match return types across continuations with delimited dynamic variables, an extension of delimited continuations http://okmij.org/ftp/papers/DDBinding.pdf http://okmij.org/ftp/papers/DDBinding.pdf
- andai 3y agoTo be fair, you did warn me!
- DaveFlater 3y agoDeja vu, I have been in this place before. Prior art: John Aycock and Mike Zastre. An Exceptional Programming Language. Proceedings of the 2005 International Conference on Programming Languages and Compilers. https://pages.cpsc.ucalgary.ca/~aycock/papers/plc05.pdf https://pages.cpsc.ucalgary.ca/~aycock/papers/plc05.pdf
- yccs27 3y agoDoes it really need the toss/return syntax to loop? You could use let loop = func(state, self) { let next = foo(state); self(foo); }; loop(start, loop);
- duped 3y agoWhile cute this is really close to call/cc and/or algebraic effects as an abstraction for control flow, which isn't as much "cute" as it is "a powerful way to express programs in as few expressions as possible"
- btown 3y agoYep! Everyone should read https://overreacted.io/algebraic-effects-for-the-rest-of-us/ https://overreacted.io/algebraic-effects-for-the-rest-of-us/ for how powerful this can be in practice. The caller gets to pause execution on the raising/hurling of an event - which makes many crazy things possible.
- compscigirl 3y agoI feel like I must be missing something. It seems to me (just from reading this post) that if you need algebraic effects you’ve probably painted yourself into a corner and should probably reconsider your program’s architecture. It seems like a good way obscure what the code is really doing and end up with poorly organised spaghetti code. In the post he’s effectively making a function async while pretending it’s not, or calling a callback but making the top level code’s problem instead of encapsulating in the associated type. I’m sure there’s uses for algebraic effects down the line I haven’t thought of, but I don’t understand why these would be desired outcomes?
- dvt 3y agoYou're not missing anything. Algebraic effects are basically typed gotos†[1][2], and are generally a bad idea to use and/or implement. They can be useful in a few very niche situations when using typed functional languages. † With added asynchronicity. [1] http://community.schemewiki.org/?call-with-current-continuation http://community.schemewiki.org/?call-with-current-continuat... [2] Some argue call/cc is, in fact, worse than goto: https://okmij.org/ftp/continuations/against-callcc.html https://okmij.org/ftp/continuations/against-callcc.html
- 3y ago
- bfung 3y agoFun experiment, but feels like a miss not to then explore the Optional type ideas and eliminate ‘catch’ all together.
- gmalette 3y agoA few years back I wrote a language called “exceptional” based on some shared ideas. Hurl is super neat and you took things further than I did. https://github.com/exceptional-lang/exceptional https://github.com/exceptional-lang/exceptional
- SashaSirotkin 3y agoThis is very fun! I am only making suggestion because it rhymes with "hurl" (and it works well metaphorically for the repeating tossing/hurling): you could introduce a "whirl" keyword or part of the standard library as the way to handle loops. It could be functionally the same as your loop example but removes the self-referential first argument (i.e. whirl(count, [1,3])).
- thekiptxt 3y agoIn my university, the slang term for an uninitialized variable was "dead squirrel". IIRC, some TA had described uninitialized C++ variables as follows: "It could be any value: zero, 100, or even a dead squirrel." If hurl ever allows uninitialized variables, I would love to see use of an uninitialized variable to `hurl` a `squirrel`! :)
- cogman10 3y agoIf you squint a little, what OP has invented here is pattern matching with algebraic data types.
- kabdib 3y agoThe Icon language (by the Griswalds, the same couple who brought us SNOBOL of decades past) has similar control structures for its generators.
- alexisread 3y agoExceptions as the underpinning of such a lang is interesting, but I think you might be better off with push-prompt, and an implementation of delimited dynamic binding to allow eg. Process migration. Wat is a very small language which does fexprs (vau calculus), delimited continuations, delimited dynamic binding, custom algebraic effects (try catch, fibres) on top of them, modules, types, and has a metacircular VM in a few hundred LOC. It's missing a native implementation but it's very impressive. https://github.com/GiacomoCau/wat-js https://github.com/GiacomoCau/wat-js Links to the formal research are in the readme. http://axisofeval.blogspot.com/?m=1 http://axisofeval.blogspot.com/?m=1 Has several good discussions on the topics, and are more accessible than the papers.
- SAI_Peregrinus 3y agoYou can make it more terrible (but still Turing complete) by removing `toss` and `return`, since you have conditional catches. Just nest enough catches so that when you throw the execution will start again and skip over any unnecessary code.
- deleted 3y ago[deleted]
- shaftoe444 3y agoI love it.
- tshaddox 3y ago> Oh, also, functions cannot be recursive (without passing in a function to itself), because we won't have the function bound to a name in the local context when defining itself. Fun, right? The startup accelerator that runs this forum is named after a pretty neat thing you can do with a language that only has anonymous functions: https://en.wikipedia.org/wiki/Fixed-point_combinator https://en.wikipedia.org/wiki/Fixed-point_combinator
- Joker_vD 3y agoYou don't even need that, there is a much more efficient way in a language that supports let-bindings (but not letrec): let f' = func(f, g, other_args...) { // ... g(f, g, whatever...); // ... }; let g' = func(f, g, other_args...) { // ... f(f, g, whatever...); // ... } let f = func(other_args...) { return f'(f', g', other_args...); } let g = func(other_args...) { return g'(f', g', other_args...); } That's basically just closure conversion, only instead of doing it the compiler backend, you do it manually yourself.
- tshaddox 3y agoThat’s true, although I wasn’t sure if simpler approaches using let bindings like that would fall under the author’s “without passing in a function to itself.”
- Joker_vD 3y agoI understood that passage as "our let won't be letrec, so no recursion for you (unless you do some self-passing trick, of course)".
- Joker_vD 3y agoOr you can go all the way in the other direction (double- or triple-barreled CPS) and have functions that can't return but only call other functions. let fizzbuzz = func(ret, fizzbuzz, x, max) { (x == max)(ret, func() { let printed = false; (x % 3)(func (t0) { let k0 = func() { (x % 5)(func (t1) { let k1 = func() { let k2 = func() { (x + 1)(func (t2) { fizzbuzz(ret, fizzbuzz, t2, max); }) }; (printed == false)(func () { print(k2, x); }, k2); }; (t1 == 0)(func () { print(func() { printed = true; k1(); }, "buzz"); }, k1); }); }; (t0 == 0)(func() { print(func() { printed = true; k0(); }, "fizz"); }, k0); }); }); } fizzbuzz($halt, fizzbuzz, 0, 100);
- quickthrower2 3y agoIs this a slightly less esoteric version of the Lambda calculus?
- abecedarius 3y agoRaph Levien's Io was along those lines (but conciser). (Different language than a newer now better-known Io.)
- scrame 3y ago> Oh, also, functions cannot be recursive (without passing in a function to itself), because we won't have the function bound to a name in the local context when defining itself. OP Might want to look into the origins of this website name.
- Dylan16807 3y agoWhy? The parenthetical is right there.
- amluto 3y ago> You can toss it, which works a little differently: it traverses the stack until you reach a matching catch block, but then you can use the return keyword to go back to where the value was tossed from. > > I know, it's cursed using return in this unusual way. Again, sorry, I didn't make you keep reading. But, the reward is that since you got here, you get to see how we can use these to create control flow. Maybe calling it 'return' is cursed, but this concept isn't cursed at all. These are resumable exceptions, and I used to love them! Windows supports them natively, although I don't think they're widely used. Here's the C/C++ extension for Window's native "structured exception handling", and ordinary C++ exceptions are built on top of it: https://learn.microsoft.com/en-us/cpp/cpp/structured-exception-handling-c-cpp?view=msvc-170 https://learn.microsoft.com/en-us/cpp/cpp/structured-excepti... It supports: > Recognize the exception but dismiss it (EXCEPTION_CONTINUE_EXECUTION). And as a kernel programmer, I really like resumable exceptions -- most hardware exceptions are resumable, and the kernel uses them extensively. When you get a page fault, that's an exception, and the kernel has a handler, and the control flow, um, yeets to the handler, and the handler, well, returns (or exits or whatever you want to call it) right back to the exception site. And POSIX signals support this too -- it's even the default behavior when a signal handler returns. (POSIX signals suck.)
- andrewflnr 3y agoYeah, it would be 90% less cursed if she replaced "return" with "resume". But I get the impression she's going for the cursed aesthetic, so...
- deleted 3y ago[deleted]
- ranger207 3y ago> I guess this assumes the stack goes down, but this direction metaphor in stacks has always confused me. What's up and what's down? The stack starts at the end of a process's memory space, so stack frame 0 has the highest possible memory address (ex 0xFFFF) and further stack frames have lower memory addresses (ex 0xFFF8). Now combine this with the fact that many visual representations of memory space have 0x0000 at the top and 0xFFFF at the bottom and the stack grows down by growing up and it all gets very confused
- gqcwwjtg 3y agoIf you extend the `catch` matching to compound values this isn’t even that bad. let fizzbuzz = func(fizzbuzz, x, max) { try { hurl [x % 3, x % 5]; } catch ([ true, true]) { print("FizzBuzz"); } catch ([false, true]) { print("Buzz"); } catch ([ true, false]) { print("Fizz"); } catch ([false, false]) { print(x); } try { hurl x; } catch (max) {} catch (x) { fizzbuzz(fizzbuzz, x + 1, max); } }
- chii 3y agoand if you just renamed the `catch` to `case`, it almost looks like a regular language. Who cares how it does the jumps in the implementation! ;D
- zzzeek 3y agoyeah "toss" is what we used to call GOSUB. so it's "hurl" and "toss" as slightly weird versions of GOTO and GOSUB.
- AlbertCory 3y agoHurling doesn't always mean throwing up: https://en.wikipedia.org/wiki/Hurling https://en.wikipedia.org/wiki/Hurling
- slackstation 3y agoThis is cursed. I'm happy that it exists and this person had fun but, my poor brain...
- nixpulvis 3y agoWait, what exceptions can even exist if all you can do is bind names and make functions? Or are you trying to tell me my application is broken?
- dividezero 3y agoAll this thought and yeet isn't a reserved word
- thih9 3y agoI’m seeing a connection error. Is the server still up? Is there a mirror / archive?