• 0 Posts
  • 75 Comments
Joined 3 years ago
cake
Cake day: July 1st, 2023

help-circle
  • Thank you for the answer!

    I have not previously heard Meson described as a reinvention of Cmake or a CMake clone, nor that it was meant to be. I would think that Meson being as opinionated as it is, including for example the fact that it does not and will not support user-defined functions, precludes it from being a CMake clone. It seems instead to be a build-system with a rather different philosophy and feature-set compared to Cmake. But if that philosophy or that feature-set does not match your needs, then there’s obviously no reason to pick it over CMake


  • Out of curiosity, why do you consider CMake to be the better choice compared to Meson?

    Personally I landed on Meson a few years ago, from what I remember chiefly due to simply not liking CMake’s DSL and finding Meson easier to work with, despite needing to target a pretty old version for the sake of compatibility. Though Meson is definitely not perfect either; it’s highly opinionated, and for example only recently got support for custom build targets putting stuff in sub-directories (as I discovered while writing this comment), so I’ll personally be stuck with my workarounds for a good while longer






  • Recently had to develop a Python project, the tests took at least ten seconds to start each single time. This is while I made over a hundred tests for my module and re-ran them after every change.

    Python is dog slow, but if your tests are taking 10 seconds to start (not even run!), then something is catastrophically wrong with your setup. For comparison, for one of my projects, it takes a total of 12 seconds to run nox on a clean slate, which involves setting up venvs for five major versions of Python, installing the package and its dependencies in each, and finally running the 1500 test test-suite five times


  • What about the fact that runtime startup alone auto-disqualifies python for all short-lived process use-cases?

    While Python’s start-up time is a lot slower than a corresponding compiled program, in most cases it’s not slow enough to matter even if the process itself is short-lived:

    $ hyperfine 'python3 -c "pass"'
    Benchmark 1: python3 -c "pass" (412 runs)
                    mean     ±       σ          min     …     max
      Wall Time      7.1 ms  ±     0.2 ms       6.7 ms  …     8.4 ms
      Memory         9.4 MiB ±     0.1 MiB      9.1 MiB …     9.5 MiB
    

    If you are running a small program so often that this kind of start-up time matters, then the loop should probably already be implemented in the program itself. In line with the article’s thesis


  • I haven’t read the paper in dept, but these are deeply unserious reasons for disparaging it.

    Bad research is still bad. The main paper is 9 pages with wide margins, outside of references. This was a few college students publishing their CS research assignment

    The length of this paper entirely within the norm for scientific publications. In fact, depending on the type of paper, they can be much shorter. For example, Nature expects submissions at around 2500 words or around 4300 words, depending on the format, while this paper is around 4800 words long (excluding references and SI).

    The authors also obviously not “a few college students publishing their CS research assignment”: Gloaguen, Mündler, Raychev, Müller, and Vechev.

    The “Limitations” section is rather telling:

    Another interesting avenue opened by this work is how to improve the automatic generation of useful context files.

    Okay, so they already admitted that they started with useless context files, which sabotages their own test.

    You know how you fix useless context files? You iterate until they are useful context files!

    The entire point of the study was to see what kind of context files were useful and which were useless, which according to the authors was not something that had been done before:

    A widespread practice in software development is to tailor coding agents to repositories using context files, such as AGENTS.md. Although this practice is strongly encouraged by agent developers, there is currently no rigorous investigation into whether such context files are actually effective for real-world tasks. In this work, we study this question and evaluate coding agents’ task completion performance in two complementary settings

    They found that,

    while instructions in the context files are well followed by coding agents, repository overviews, although popular and recommended by model providers, are not helpful.

    So when you say that they “admitted that they started with useless context files”, you are referring to the results of the study. Complaining that they didn’t base their study on the conclusions of that very study is just absurd


  • The problem of enums in other languages is that they do not make for a distinct type. They are just integers in a name. Or at least that is the case for C and Java enums. Python and JavaScript do not even have enums, which is even worse.

    Strongly typed enums is hardly unique to Rust.

    C++ has had them for a long time, for example: Using a plain integer type where an enum is expected has been prohibited since at least C++98. You can still use an enum in the place of an int, unless you use scoped enums (C++11 or later), which also require an explicit cast to convert from enum to the underlying type.

    And Python has had some form of enum since since 3.4: https://docs.python.org/3/library/enum.html. It’s not a language level feature, but that probably wouldn’t make much of a difference, and it’s as type safe as anything else in the language. But you will get a error when using type-hints, if you pass the wrong type to a function expecting an enum:

    from enum import Enum
    
    class MyEnum(Enum):
        A = 1
        B = 2
    
    def foo(_: MyEnum): ...
    
    foo(1)  # error: Argument 1 to "foo" has incompatible type "int"; expected "MyEnum"  [arg-type]
    


  • This breaks down when there are more than one SOURCE file, since each DESTINATION file depends on all source files. This means that $< will always be the first file in SOURCE. For example, if source contains the files 0001-01-01-some-file-name.md and 0002-02-02-some-file-name.md:

    $ make -n
    mkdir -p destination/0001/01/01/  
    /bin/bash ./myscript.sh source/0001-01-01-some-file-name.md > destination/0001/01/01/some-file-name.md  
    mkdir -p destination/0002/02/02/  
    /bin/bash ./myscript.sh source/0001-01-01-some-file-name.md > destination/0002/02/02/some-file-name.md  
    

    OP is probably better off using a scripting language to automate this kind of thing

    EDIT: Fixed example filenames








  • Here are a few random thoughts based on skimming the source:

    • I’d advice againsts using -Weverything. Many of the warnings it enables are not very useful, and you are going to get a lot of them. And if you enable warnings, then fix them, or you’ll just miss it when your changes cause new warnings.
    • A couple of your check functions may reach the end of the function without returning, if type is not on of the expected values. That is undefined behavior. One simple way to avoid this, is to move the common return out of the ifs.
    • That const std::string type argument in the above functions should be enums, since you are just checking againts one of three fixed values ("name", "ext", and "date").
    • Speaking of which, I can’t think of any situation where you’d want to have an const std::string argument. Either use a const reference (const std::string&) or a string_view (const std::string_view). The latter has the advantage that it doesn’t create a new std::string if you call the function with a C-string and it can be sliced cheaply.
    • You have const std::string &df = df_str; in a couple of places, where df_str is a std::string passed by value. That is of course utterly pointless, and you should simply change df_str to be passed by const reference or as a string view.
    • You define main with an int return type, but use std::exit to exit the function. Those std::exit calls could all be replaced with return, which does the same thing in main.
    • Don’t do work before you need the results. For example, in check_type you perform two checks (saved as starts_with_dot and has_dash), that are not used if name == "name".
    • Nobody who sees a function named check_exists would expect it to create a directory, so it should be renamed to something more descriptive. It is also redundant, since you already check that the directory exists in main.cpp via is_directory, but unlike that check check_exists doesn’t actually verify that the path is a directory.
    • is_founded is Engrish

  • ls can be piped safely if you use --zero:

    ls --zero *.txt | xargs --null -I {} mv {} /home/user/Documents
    

    While the above is a pretty silly example, one reason why you might want to do this is that xargs has a -P/--max-procs argument, that runs N commands in parallel. So you could do something like the following to gzip four files in parallel:

    ls --zero *.txt | xargs --null -n1 -P4 gzip
    

    This is a bit simpler than using the equivalent

    find . -maxdepth 1 -name '*.txt' -print0 | xargs --null -n1 -P4 gzip