• 5 Posts
  • 22 Comments
Joined 1 year ago
cake
Cake day: June 15th, 2023

help-circle

  • I was about to start learning Perl in a proper way, but always decided against it. I just can’t find a good reason for myself to write Perl code. Unless you want to read or edit others Perl code, what is the reason to learn it? GNU+Bash and Python are often enough for me.

    So why learning and using Perl in modern age and day as a newcomer to the language? Look, I’m not negative here, just asking honest question. Because I am actually searching for good reasons to learn Perl.






  • But that mathematical pseudo code has nothing in common with the walrus operator := in Python and Go. They are just the same symbols, but with a totally different meaning and use case. Its an operator designed specifically for programming languages, because that is not applicable to mathematics at all. In mathematics you don’t have an assignment operator a = 69 that cannot be used as part of an expression. Therefore you don’t need a dedicated := that yields an expression that can be used as part of an expression and create a variable if its not already. (Edit: I’m so sick of my stupidness.)


  • Turns out it was introduced in 3.8, released in 2019, so it was much too late to inspire Go

    You are probably right about that. But don’t forget that the operator didn’t made it day one, there was lot of discussion before and probably testing it in the beta releases before. But given how old Golang at that point is, you are right about my take on inspiration. This operator wasn’t a new invention in Python.

    It also has a substantially different meaning than in Go.

    I don’t know if there’s an “official” rationale for the Go syntax, but := is a fairly common (but not ubiquitous) math notation meaning “define the thing on the left to be equal to the expression on the right”, i.e. to distinguish it from the other use of =, i.e. “the expression on the left must be equal to the expression on the right.”

    Does it though? In both cases, Go and Python, the operator will assign a variable a value and also use it as an expression. That is useful in cases like for loops or other cases where you want immediately use the variable content as an expression. This cannot be done with the regular assignment operator a = 69, which itself is not an expression. So in practical terms, its the same in usability for Go and Python. So its doing the same for both languages and has the same differences to the assignment operator. (Edit: Read the reply, I learned something myself. That’s why its important that you don’t blindly teach people like I did.)



  • The := operator is called walrus operator and is inspired by Python I think. It’s declaring a variable and assigning it in one go. map[string] int is defining a map (associative array or also known as dictionary in Python), with string as key type and int as value type. And the following {} is the body of the associative array, meaning empty content.

    I only played a bit with Go and did basic tutorials. I might go back to it at some point, but Zig is much more appealing to me. Go is too simple in the language to me, but on the other side, this is exactly whats appealing.




  • I copied the sub-headings from the document, serving as an overview:

    • Introducing Windows Copilot Runtime to provide a powerful AI platform for developers
    • New experiences built using the Windows Copilot Runtime
    • Windows Copilot Library offers a set of APIs helping developers to accelerate local AI development
    • Introducing Windows Semantic Index that redefines search on Windows. Vector Embeddings API offers the capability for developers to build their own vector store with their app data
    • Windows is the first platform to have a state-of-the-art SLM shipping inbox and Phi Silica is custom built for the NPUs in Copilot+ PCs
    • Developers can bring their own models and scale across breadth of Windows hardware powered by DirectML
    • PyTorch is now natively supported on Windows with DirectML
    • DirectML now supports web apps that can take advantage of silicon to deliver AI experiences powered by WebNN
    • High-performance inferencing on Windows with ONNX Runtime and DirectML
    • New experiences designed to help every developer become more productive on Windows 11
    • Environments in Dev Home help centralize your interactions with all remote environments. Create, manage, launch and configure dev environments in a snap from Dev Home
    • Windows Customization in Dev Home allows developers to customize their device to an ideal state with fewest clicks
    • New Export feature in Dev Home Machine Configuration allows you to quickly create configuration files to share with your teammates, boosting productivity
    • Dev Drive introduces block cloning that will allow developers to perform large file copy operations, instantaneously
    • Sudo for Windows allows developers to run elevated commands right in Terminal
    • New Source code integration in File Explorer allows tracking commit messages and file status directly in File Explorer
    • Continuing to innovate and accelerating development for Windows on Arm
    • Continuing investments in WinUI3 and WPF to help developers build rich, modern Windows applications
    • WinUI 3 and Windows App SDK now support native Maps control and .NET 8
    • Windows 11 theme support makes it easy to modernize the look and feel of your WPF applications
    • Extend Windows apps into 3D space
    • Building for the future of AI on Windows


  • From https://github.com/python/cpython/blob/3.12/Lib/pathlib.py

    class PosixPath(Path, PurePosixPath):
        """Path subclass for non-Windows systems.
    
        On a POSIX system, instantiating a Path should return this object.
        """
        __slots__ = ()
    
        if os.name == 'nt':
            def __new__(cls, *args, **kwargs):
                raise NotImplementedError(
                    f"cannot instantiate {cls.__name__!r} on your system")
    

    Which sub classes PurePosixPath, which itself is basically just PurePath with a Posix flavour to it. And Path itself is PurePath as well. Not sure if I should copy paste them here.

    Edit: So I added these to my reply:

    PurePath

        def __new__(cls, *args, **kwargs):
            """Construct a PurePath from one or several strings and or existing
            PurePath objects.  The strings and path objects are combined so as
            to yield a canonicalized path, which is incorporated into the
            new PurePath object.
            """
            if cls is PurePath:
                cls = PureWindowsPath if os.name == 'nt' else PurePosixPath
            return object.__new__(cls)
    
    
        def __init__(self, *args):
            paths = []
            for arg in args:
                if isinstance(arg, PurePath):
                    if arg._flavour is ntpath and self._flavour is posixpath:
                        # GH-103631: Convert separators for backwards compatibility.
                        paths.extend(path.replace('\\', '/') for path in arg._raw_paths)
                    else:
                        paths.extend(arg._raw_paths)
                else:
                    try:
                        path = os.fspath(arg)
                    except TypeError:
                        path = arg
                    if not isinstance(path, str):
                        raise TypeError(
                            "argument should be a str or an os.PathLike "
                            "object where __fspath__ returns a str, "
                            f"not {type(path).__name__!r}")
                    paths.append(path)
            self._raw_paths = paths
    

    Path

    
        def __init__(self, *args, **kwargs):
            if kwargs:
                msg = ("support for supplying keyword arguments to pathlib.PurePath "
                       "is deprecated and scheduled for removal in Python {remove}")
                warnings._deprecated("pathlib.PurePath(**kwargs)", msg, remove=(3, 14))
            super().__init__(*args)
    
        def __new__(cls, *args, **kwargs):
            if cls is Path:
                cls = WindowsPath if os.name == 'nt' else PosixPath
            return object.__new__(cls)
    






  • When I first read the headline, my first 2 assumptions where:

    • another AI driven development, which writes multiple lines and assumes complete logic and what you want to do
    • dependent on the internet

    After your comment (I can’t verify, but assume you are serious) sounds actually good if its just trying to autocomplete stuff. I have yet to see any AI driven autocomplete system that does just that. But the other fact (according to the article) is, it’s not dependent on the internet. This is huge! One of the biggest downsides of AI tools is, that they rely on the internet to send data back and forth.

    Unfortunately this is closed source. And when I stop paying subscription, while being addicted and dependent to it, would be bad for me. I get it, its a buisness model and they have to make money without others stealing or using their products for free. But I am super curious to where this leads and if this tech is truly better than its competitor. Sorry for my rambling.


  • Firefox has a reader view mode, which I can enable by clicking an icon in the address bar. But for some reason, this icon will not appear for this website here. I even have enabled a setting in the about:config that this icon should be shown for all pages, but it will not for this site.

    I used darkreader in the past. But I could not find a solution to just enable temporarily for the current page I am reading. I don’t want to enable for all pages. But you actually reminded me of another plugin I totally forgot: Tranquility Reader https://addons.mozilla.org/en-US/firefox/addon/tranquility-1/ and it does exactly what I want and works for this page too. A click will turn it into a readable text temporarily (default black on white, but changeable). So I guess this is a solved problem for me now? Thanks to you, because otherwise I would not remember and lookup again.