Comment by IshKebab

Comment by IshKebab 4 days ago

11 replies

This is one of Deno's killer use cases IMO. 100x better than shell scripting and like 5x better than Python scripting. Python should be good for this sort of thing, but it isn't.

Historically we had to use pip which was super janky. Uv solves most of pip's issues but you still do have to deal with venvs and one issue it doesn't solve is that you can't do imports by relative file path which is something you always end up wanting for ad-hoc scripting. You can use relative package paths but that's totally different.

PurpleRamen 4 days ago

> you can't do imports by relative file path

Just add the targeted path to sys.path, or write your own importhandler. importlib might help there. But true, out of the box, imports in python3 are a bit wacky for more flexible usage.

  • IshKebab 4 days ago

    Both of those are horrible and break all tooling. Deno's imports work properly.

    • PurpleRamen 4 days ago

      > Both of those are horrible and break all tooling.

      No, they don't. Tooling is fine with those things.

wiseowise 4 days ago

> 5x better than Python scripting

I’m not sure about that. All those ‘await’s, parentheses really kill my mojo. Why do you find it better than Python?

  • IshKebab 4 days ago

    > Why do you find it better than Python?

    I said already - the main reason is you can import files by relative file path.

    You can get close to the Deno UX with uv and a script like this:

      #!/usr/bin/env -S uv run --script
      #
      # /// script
      # requires-python = ">=3.12"
      # dependencies = ["httpx"]
      # ///
      import httpx
      print(httpx.get("https://example.com"))
    
    But you still have to deal with the venv e.g. for IDE support, linting and so on. It's just more janky than Deno.

    I wish someone would make a nice modern scripting language with arbitrary precision integers, static types, file path imports, third party dependencies in single files, etc. Deno is the closest thing I've found but in spite of how good Typescript is there are still a ton of Javascript warts you can't get away from (`var`, `==`, the number format, the prototype system, janky map/reduce design, etc.)

    • fainpul 4 days ago

      PowerShell is pretty good for shell scripting.

        iwr https://example.com
      
      You also have arbitrary precision integers and all the other stuff from .NET

        $b = [BigInt]::Parse('10000000000000000000000000000000000000000000000000')
      • IshKebab 4 days ago

        Powershell has god awful syntax though. There's no way I'd want to do anything remotely significant with it.

        • jcgl 2 days ago

          PowerShell’s syntax Is just fine. Very few special characters, minimal escaping, easy to read. If you understand PowerShell semantics, the syntax comes quite naturally.

  • tracker1 3 days ago

    For me, it's mostly that I'm more comfortable with TS/JS ecosystem... Deno is really nice in that you can import module references directly... I guess you can do similar with uv installed and have dependencies in comments in the top of the file (in another comment).

    For me, though TS is something I'm generally using anyway, web projects, etc. I'm comfortable with it, and there are modules for almost everything under the sun.. except a working MS-SQL client for Deno.