babashka

Magnus 2025-07-22T11:58:02.097149Z

Hi. Don't know if this is the right place but I was using the babashka/fs library yesterday and managed to confuse myself with the create-sym-link function. The function itself looks like this:

(defn create-sym-link
  "Create a soft link from path to target."
  [path target]
  (Files/createSymbolicLink
   (as-path path)
   (as-path target)
   (make-array FileAttribute 0)))
while the java.nio function it calls is documented as
java.nio.file.Files/createSymbolicLink
[link target attrs]
Creates a symbolic link to a target (optional operation).
@param link the path of the symbolic link to create @param target the target of the symbolic link 
@param attrs the array of attributes to set atomically when creating the symbolic link
@return the path to the symbolic link
so the usage is (create-sym-link new-file-link where-the-link-points-to) But target in my mind becomes ambiguous when mixed with path. Maybe because I'm not native English? Point 'at' vs point 'from' maybe? Now that I've debugged it I understand. But I did mess up at first. Maybe because I was writing a script that moves a file from A to B, then create a new link A that points to B, basically centralizing my config files because after making complex config files I needed to version control them. What I did not understand yesterday was if the path or the target was the canonical file, or the 'main node' so to speak. In bash the links show up as a nice arrow, so pretty clear what 'points to' is used for in retrospect. somefile -> /a/path/somefile becomes path -> target The https://www.man7.org/linux/man-pages/man1/ln.1.html documents the os linking tool ln as
ln - make links between files
    ln [OPTION]... [-T] TARGET LINK_NAME
...
    In the 1st form, create a link to TARGET with the name LINK_NAME.
which makes it clear that target means the target is the 'source', or the actual file. But the argument ordering is opposite that of the create-sym-link function, so maybe that's why I was confused because of remembering creating links manually in bash? Sorry for complaining. But maybe this helps someone else in the future.

✅ 1
borkdude 2025-07-22T12:02:33.171469Z

A valid point of confusion, imo. The decision about the order of arguments in create-sym-link is that it's the same order as the Java API. The names of the Java API are link and target . Do you think it would be less confusing if I changed path to link? Probably so?

Magnus 2025-07-22T12:08:55.914579Z

Probably, yes. Just irks me a bit that it breaks the nice consistency of naming where you have ~82 path parameters in the fs namespace.... But maybe its the little mind speaking..

borkdude 2025-07-22T12:17:09.474349Z

Karl Xaver 2025-07-22T19:05:06.511049Z

Awesome! I remember falling into the same trap and making a mess :)

👍 2