ristos | 1 month ago | on: My Gripes with Prolog
ristos's comments
ristos | 1 month ago | on: My Gripes with Prolog
You can't do length + 1 as a single expression in any language though, in python for example len(ls) + 1 is two expressions, but I get what you mean, it is a little less terse. But those commas in prolog are super useful. And you can make your example bidirectional too:
``` :- use_module(library(clpfd)).
foo(List, X) :- length(List, Out), X #= Out + 1. ```
``` ?- foo(X, 3). X = [_, _] .
?- foo(X, 3), X = [a,b]. X = [a, b] . ```
-----
No standarized collection types:
I think that's a feature rather than a bug. The ability to just use infix and compound terms in a generic way without it being tied to a clause or operator is a huge feature. For example:
``` pets(dog-rex-poodle, dog-fluffy-bishon). ```
That defines the collection in a semantic or mathematical sort of way, then you can pass that into whatever data structure you want, whether it's a ordered map or a hashmap or whatever.
----
No boolean values:
That's also a feature in prolog, same as having no null. It's the same sort of motivation for Haskell's Maybe and Either types or Rust's Option and Result types, same kind of usefulness.
----
Cuts are confusing:
Conditionals don't need to use cuts, the modern prolog way of doing it is using the reif library:
``` :- use_module(library(reif)).
if_(Cond, Then, Else) ```
For example:
``` :- use_module(library(clpfd)). :- use_module(library(reif)).
sign(X, S) :- if_(X #> 0, S = pos, S = nonpos). ```
---
Non-cuts are confusing:
This isn't doing what you're thinking:
``` \+ (A = B) ```
It's unifying A with B, `A = B` unifies. You want `dif(A, B)`.
----
Straying outside of default queries is confusing:
It might be tempting to use bagof, but it's not monotonic. You should try to write as much prolog code as you can in a pure, monotonic way, so your code can take advantage of prolog's unique advantages, like monotonic debugging.
Check out the SWI prolog discourse group, there's a lot of good stuff in there and everyone's very supportive to newbies. And Markus Triska's website and youtube channel Power of Prolog is a super useful resource for all this stuff, a good place to go if you want to know what sets prolog apart. A lot of prolog's usefulness doesn't show up as an embedded language either, like minikanren isn't "pretty much prolog", it lacks a lot of stuff that prolog offers. Multiparadigm programming languages are also really popular now, but a lot of what sets programming languages apart isn't what they can do, it's what they can't do, what sort of paradigm or way of thinking they force you to adopt.
ristos | 10 months ago | on: Ask HN: How do you talk about past jobs you regret in interviews?
ristos | 11 months ago | on: Has the decline of knowledge work begun?
ristos | 1 year ago | on: Suckless.org: software that sucks less
I'm pretty bummed out to hear about all of this. I thought the suckless style software was pretty cool, easy to grok, minimalist. I use a lot of it. Granted, I've been planning on translating all of the minimalist C software I've been using to R7RS scheme, so maybe this just gives me more motivation to get started on porting my stack to that.
Someone in an earlier thread said something like, if he avoided software written by assholes then he would have a hard time using his computer, something like that. I think that's kind of true, but there are definitely red lines when it comes to violent ideologies.
ristos | 1 year ago | on: Our phones are killing our ability to feel sexy (2024)
That's probably the difference between how cool people use technology vs nerds or dorks. When I use my phone, it's either to look something up, study or learn something new, read the news, or talk to my mom. I would imagine I probably don't look cool using my phone.
Joking aside, I think one thing that I really don't like about smartphones and texting entering our lives is that when you're out for food or coffee people get on their phones, and it feels antisocial, like you can't talk to them now without interrupting them from whatever they're doing on their phone. In the past, I remember, if people had nothing to say, they would just sit there and look off into the distance. It all felt way more social back then, when people got together they interacted more.
ristos | 1 year ago | on: GNU Artanis 1.0.0 Released
ristos | 1 year ago | on: Scientific American's departing editor and the politicization of science
ristos | 1 year ago | on: When did estimates turn into deadlines?
The issue isn't around tasks that are predictable in nature and therefore easy to estimate with a small margin of error, it's around complexity in software, unforeseen things, bugs, etc, which can compound for larger long term projects.
If engineers give estimates close to what it would be if everything goes right, then they risk overpromising and underdelivering if something goes wrong (hofstader's law). They might've just wanted to do the right thing by saving the company money and time, but in the end they footgunned themselves.
Or engineers intentionally over-estimate in order to manage the complexity, but then you end up with a lot of padding and parkinson's law. Because as soon as the engineer starts underpromising and overdelivering consistently, management will pressure them to lower their estimates because they have a track record of doing that, so instead they're incentivized to pad and then fill up the entire time they estimated even if it took less time.
Sprints were probably invented in order to deal with some of these issues, so that people just work with a bunch of smaller tickets that are much easier to estimate, with the more complex long term estimates going to management, which are incentivized to get it right because they're shareholders. That often leads to micromanagement and burnout, and it doesn't fix the padding/overestimation issue either, it might even amplify it in a lot of cases.
People here mention giving ranges or probability distributions, and have also equally mentioned that they don't work because management wants a single number, or management just assumes the best-case or middle-case of the range as the actual estimate, and then they still get in trouble for giving ranges and it didn't solve anything. It also doesn't solve the problem of unanticipated setbacks, the whole you don't know what you don't know thing, which can only really be solved culturally in some way.
While there are certainly bad managers that want to squeeze their workers, a lot of the time management is probably also pressured to give estimates and that's why they want and need that accuracy, because they're pressured by investors and clients that want to know how much time and money something will cost.
Overall the entire problem is a system cultural issue around managing complexity.
ristos | 1 year ago | on: When did estimates turn into deadlines?
ristos | 1 year ago | on: Everything Is Just Functions: 1 week with David Beazley and SICP
ristos | 1 year ago | on: Please stop the coding challenges
If I were interviewer, I'd probably do a coding assignment that builds on an already existing mini codebase, quarter or half day assignment (2-4 hours), with a strict time limit to turn it in by the end of the allotted time. It would test for someone's ability to read unfamiliar codebases, with the codebase being reasonably small for the little time that's available, and the ability to build features on top of it, to write clean readable code compatible with the codebase, etc. And an a 30-60 minute more open-ended informal knowledge interview to gauge how knowledgeable the candidate is and where their strengths and weaknesses are. And previous work would probably be a good indicator, like open source work and/or previous job experience.
ristos | 1 year ago | on: Ask HN: If you were rewriting Emacs from scratch, what would you do differently?
I'd like to eventually write something like this, there are a lot of things it would enable that you just can't do with emacs. It would be an emacs killer if implemented well, but it would also open up a whole new set of possibilities.
I don't know how far I'd get just working on it on my free time, which is competing for time with other projects. I'm looking for funding for these sorts of projects. If anyone reading this is an investor and interested in funding this sort of thing, please reach out.
ristos | 1 year ago | on: Can logic programming be liberated from predicates and backtracking? [pdf]
I wouldn't say that the logic or relational way of describing effects is a bad thing either. By design it allows for multiple return values (foo/1, foo/2, ...) you can build higher level predicates that return multiple resources, which is pretty common for many programs. It makes concatenative (compositional) style programming really straightforward, especially for more complex interweaving, which also ends up being quite common. Many prolog implementations also support shift/reset, so that you can easily build things like conditions and restarts, algebraic effects, and/or debugging facilities on top. Prolog is also homoiconic in a unique way compared to lisp, and it's quite nice because the pattern matching is so powerful. Prolog really is one of the best languages I ever learned, I wish it was more popular. I think prolog implementations need a better C FFI interop and a nicer library ecosystem. Trealla has a good C FFI.
I think logic programming is the future, and a lot of these problems with prolog are fixable. If it's not going to be prolog, it'll probably be something like kanren and datalog within a lisp like scheme or clojure(script).
This is a great resource for getting a good feel of prolog: https://www.youtube.com/@ThePowerOfProlog/videos
ristos | 1 year ago | on: First Report on the Pre-Scheme Restoration
I'm looking to use prescheme for low level code that needs more precise control where chibi scheme or guile isn't a good fit. I'm also hoping at some point that I have the time to write a borrow checker on top of prescheme, which might be a subset of prescheme but would still fit many use cases, so that it can be used instead of Rust. And also to create a transpilation step that creates optimizations, that would then ideally be proved. And then that way the borrow checked code with optimizations can be all transpiled by prescheme into C, and then tiny c compiler can compile it unoptimized into straightforward assembly. The goal would be to have verified code that can also be easily hand audited as well. LLMs just make all this stuff so much more possible because of how much faster we can iterate. Fun times for coding!
ristos | 1 year ago | on: AI won't replace human devs anytime soon
What ended up happening in practice is just that time was saved on grunt work, and really engineers just ended up working on composing and debugging higher level components, optimization, or low level work.
ristos | 1 year ago | on: Why my apps will soon be gone from the Google Play Store
ristos | 1 year ago | on: Why my apps will soon be gone from the Google Play Store
ristos | 1 year ago | on: Why my apps will soon be gone from the Google Play Store
Can you elaborate on your example here? Couldn't they just do something like replace oldGalleryAppOpensOrWritesToAnyPlace() to askPermissionsForWhichFilesAndFoldersCanBeWrittenTo() or ifSensitiveDirIsNoLongerAccessibleAskPermissionOnWhichFolderToUseForCompat() ?
ristos | 1 year ago | on: Optimizing Guile Scheme
Edit: nevermind, that's also dynamic dispatch. You'd have to add static dispatch via macros or some external transpilation step.