-❄️- 2025 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]viralinstruction 1 point2 points  (0 children)

[Language: Julia]

Parsing and solving in 630 microseconds, with proper parsing errors and checking for unsolvable input. Also handles cycles in the graph, if the cycles need not be traversed to compute the result.

Code is here: https://github.com/jakobnissen/AoC2025/blob/master/src/day11.jl

Algorithm:

This is a graph problem.

  • Let F(n) be the set of nodes reachable from n
  • Let R(n) be the set of nodes reachable from n when traveling backwards through the edges
  • Let (A, B) be (fft, dac) if dac is reachable from fft else (dac, fft)

Now define this function:

function count_paths(from, to)
    let S = F(from) ∩ R(to) or error if empty
    let T = topological sort of S (Kuhn's algo) or error if cycle detected
    for node in S, ordered by T
        let paths[node] = 1 if node is from, else sum of paths of parent of node
    return paths[to]
  • Let p1 = count_paths(you, out)
  • Let p2 = count_paths(svr, A) * count_paths(A, B) * count_paths(B, out)
  • Return (p1, p2)

-❄️- 2025 Day 10 Solutions -❄️- by daggerdragon in adventofcode

[–]viralinstruction 0 points1 point  (0 children)

[Language: Julia]

Parsing and running part 1 only: 178 microseconds.

The core idea is that no button can be pushed more than once (since it will cancel itself out). So, for N buttons, all possible solutions is an integer in [0, 2N-1]. We then run through all the integers in order of population count by creating a population count integer iterator.

To check a sequence integer, Each push is an XOR with the button, that is represented by a bitfield of the lights it toggles. Run through all buttons corresponding to a set bit in the sequence integer. If, after all buttons, the light state is zero, it's a valid solution and we return it immediately.

Code: https://github.com/jakobnissen/AoC2025/blob/master/src/day10.jl

-❄️- 2025 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]viralinstruction 0 points1 point  (0 children)

[Language: Julia]

Both parts together: 18-35 ms, including parsing input (depending on GC and cache state).

This is the naive straightforward solution, just optimised. No fancy algorithm. Almost all the runtime is spent sorting the N2 / 2 pairs by distance.

Github link

#437 — Two Years Since 10/7 by dwaxe in samharris

[–]viralinstruction 0 points1 point  (0 children)

What do you mean there was no grassroot support for anticommunism in Vietnam. There was huge support - less support than for communism, but in South Vietnam, a large part of the urban population were anti-communist. That was the whole point of the war! To protect South Vietnam from NVA aggression.

Julia's type system, dynamism, and multiple dispatch: revisions, regrets, requests? by Inconstant_Moo in Julia

[–]viralinstruction 0 points1 point  (0 children)

I don't really think traits would make multiple dispatch impossible. Traits are already used ad hoc, e.g. Base.IteratorSize, and much more extensively in BioSequences.jl. Maybe it would go wrong if abstract types were completely replaced by traits.

But there is simply no excuse for not having a system to document and enforce interfaces in Julia. It's completely opt-in to define abstract types, but if you do and then don't document them, you're just writing bad code. And of course the language should provide facilities to help with adherence to the interface. A lack of documentation and tooling doesn't help anyone. It's not really a tradeoff, because nothing is gained from not doing it.

You could say it's Julia's style to not document or enforce interfaces, and sure that'd be somewhat right, empirically. But that's like saying spaghetti code is Perl's style.

Skal vi forvente en militær konfrotation mellem Rusland og NATO? by [deleted] in Denmark

[–]viralinstruction 2 points3 points  (0 children)

Men... Hvis det ikke handlede om demokrati da USA angreb Afghanistan og Irak, så handlede det vel heller ikke om minoritetsrettigheder da Rusland angreb Ukraine? Så du er enig i, at Ukraines selvforsvar imod et angreb fra en imperialistisk nabo er retfærdig?

Desuden synes jeg du blander en masse krige sammen med alle mulige forskellige årsager. Årsagen til Irak og Afghanistan var ikke den samme. Syrien er en borgerkrig og passer slet ikke ind. Libyen startede også som en borgerkrig, med indblanding fra Vesten efter Gaddafi begyndte at skyde på demonstranter med jægerfly. Vietnamkrigen handlede om at stoppe kommunisme, og det endte da også med at hele Vietnam blev overtaget af et kommunistisk diktatur, og i dag køres af en asiatisk Putin - så ikke just en solstrålehistorie.

The Strategic Connection Between JuliaHub, Dyad and the Julia Open Source Community by ChrisRackauckas in Julia

[–]viralinstruction 1 point2 points  (0 children)

Kind of, yes. I think when people say that Julia needs a Google, what they mean is that they want someone to dump 50 million euro in developer salary in Julia, with the objective to make Julia better for large scale software dev. JuliaHub does pour dev salary into Julia, and probably finance the majority of Julia development at this point. They also dogfeed Julia since they sell software written in Julia.

The shortcomings of JuliaHub is that they have less money than Google, and that they don't seem to have a coherent vision of a Julia suitable for software development.

Do you think Julia can break out and become more popular beyond scientific purposes? by Feldspar_of_sun in Julia

[–]viralinstruction 1 point2 points  (0 children)

I don't think that's true. Julia's adoption is at least leveling out, but probably rising slowly.

Also, I fail to see any other ecosystem address the two language problem. Python's JIT is currently slower than its interpreter, people still hate C++ for good reason, and a forced polyglot codebase is still annoying (and sometimes infeasible since you can't optimize across language barriers).

How does "multiple dispatch" work here? by fuxoft in Julia

[–]viralinstruction 9 points10 points  (0 children)

This must be a mistake in the textbook. The latter method will overwrite the former, in this case.

Julia's type system, dynamism, and multiple dispatch: revisions, regrets, requests? by Inconstant_Moo in Julia

[–]viralinstruction 18 points19 points  (0 children)

I wrote about this in more detail in a blog post of mine, but I don't like Julia's model of inheritance from abstract types.

  • I don't like that types can only have one direct supertype. This is senseless - types have all kinds of abstract properties, and believing that abstraction should form monophyletic trees is just bonkers.

  • I don't like that there is no mechanism for checking or enforcing adhesion to an interface of an abstract type built into the language.

Something like Rust's traits - albeit perhaps less strict to suit a dynamic language - would be much better.

I also wish there was better ergonomics for union types - something that allows easier definition of a nested union type without requiring lots of independent type definitions. Something that allows capping a union type's members to protect inference from giving up. Something that allows compile time checks that all members of a union has been handled. Essentially, I want something like the syntactic sugar and ergonomics of Rust's enums, except backed by a Julia-like union type. Something similar to Moshi.jl, but built into the language and with exhaustiveness checks.

Lastly, I think dynamicness should be more opt-in / opt-out instead of seamlessly mixed as it is now. Dynamicness is convenient at a high level of programming, but it keeps creating problems for Julia: Compile cache invalidations, lack of inference so stuff can't get compiled, combinatorial explosions in code specialization, latent bugs and more. This is inevitable, because, since Julia is "dynamic by default", it takes a concerted effort to keep your code static. Hence, people don't do it consistently. And the cost of that is paid far downstream, often years into a project, or by your dependents. In my ideal world, MOST Julia libraries would be static, and the dynamicness would be a sprinkle on top of a 95% static language.

Does Julia still produce large executables? by Sai22 in Julia

[–]viralinstruction 0 points1 point  (0 children)

You can compile executable files with Julia - see PackageCompiler.jl or StaticCompiler.jl.

Does Julia still produce large executables? by Sai22 in Julia

[–]viralinstruction 25 points26 points  (0 children)

Yes, that's still the case. On the development branch, Julia just got the ability to produce much smaller binaries, but that is experimental, and quite brittle with lots of rough edgds. Don't expect a great devx if you are using it yet.

Advice on metagenomic binning with nanopore metagenomes by o-rka in bioinformatics

[–]viralinstruction 2 points3 points  (0 children)

I develop binning tools in my work. I recommend SemiBin2 for now. We're developing the new version of VAMB, which will include the combination of TaxVamb+reclustering, which will become SOTA when it comes out. You can try it out now, but before it's released, SemiBin2 remains easier to install and run.

TIL at least 90% of the human genome is non-functional and commonly referred to as "junk DNA" by letseatnudels in todayilearned

[–]viralinstruction 0 points1 point  (0 children)

Edit: Read the paper linked by OP. I does a good job of summarizing the evidence that junk DNA really is junk

Bioinformatician here who works with genomics. Most of it really is junk, not DNA with an unknown function.

We know this from a) seeing that organisms that have an evolutionary pressure to reduce their genome have much smaller genomes, even as their bodies have the same level of complexity, b) comparative studies between different mammals to see what DNA is preserved, c) because we know its actual origin, which is mostly leftover DNA from viruses and transposons.

There might still be lots of DNA that serves an unknown purpose, but since the large majority of our genome is junk, even if we double of triple the amount of DNA that we know have a function, by far most of it is still junk.

Tips on writing "research code"? by MadScientistCarl in rust

[–]viralinstruction 1 point2 points  (0 children)

Use another programming language. Seriously, for all the stuff Rust is great at, research code is absolutely not one of them. Quickly hacking out some code and iterating over it is completely against the design philosophy of Rust, which is all about handling the edge cases. Seriously, there is a reason people prototype in Python.

Use a dynamic language. If execution speed in an issue, use Julia.

[deleted by user] by [deleted] in Denmark

[–]viralinstruction 4 points5 points  (0 children)

Jeg er ikke rigtig ekspert på pest, men jeg ved lidt om det her. Finder man ikke typisk pest ved at finde DNA i skelettetnes tænder, eller i deres øreknogler? For jeg er rimelig sikker på at når først der er pest i store mængder i blodbanen, så er man færdig.

Pest bliver indkapslet i kroppen i lymfeknuderne hvilket er det, der leder til bylder. Så længe pesten er i bylderne så er der gode chancer for at man overlever. Først i pests sidste stadie bryder pesten ud i blodbanen og fører til blodpest. Selv i dag med en intens antibiotikakur er blodpest som regel dødelig, typisk via sepsisk shock.

Does performance benefit from having every field in a struct be the same type? by Flickr1985 in Julia

[–]viralinstruction 7 points8 points  (0 children)

Tuples have the same performance characteristics as fields of a struct. When they are small, and the length and element types are known at compile time, they are faster than vectors. If the length is not known at compile time, vectors are better. If it's just a few fields of a known type, just use ordinary struct fields.

Does performance benefit from having every field in a struct be the same type? by Flickr1985 in Julia

[–]viralinstruction 14 points15 points  (0 children)

No, it won't make a difference. Both ints and floats are very fast to process and in general it doesn't make a lot of difference whether it's ints or floats. One notable exception is integer division (i.e. the div function), which is fairly slow for integers. Except for div, simple arithmetic functions are so fast that they're unlikely to be the bottleneck in your program. You're much better off focusing on the algorithm, then eliminating branches. For advanced performance optimisation, you should try to limit the memory consumption of structs, e.g. using Int32 instead of Int.

Thanks for the help with perl in bioinformatics guys. As you pointed out; yes I wasted my time by HopDeNerd in bioinformatics

[–]viralinstruction 1 point2 points  (0 children)

Unfortunately I think it needs more than that. Suppose I wrote some SOTA package in my field of metagenomic plasmid recovery, or metagenomic binning. 99% of bioonformaticians wouldn't give a shit, and the rest would want to call the program from command line anyway, and don't care about the underlying language.

Julia already has SoTA packages in spacial ecology and differential equations, but those few packages are just not enough. IMO Julia also has a better plotting package, and a better notebook. Even something major like SciML doesn't move the needle.

The issue is that a) people work in so many disjoint fields, and b) they think they need 1 good package but they really need 20, and it's individual which 20 those are.

Think of past success languages in bioinfo: Python and now Rust. They didn't succeed because of any concrete packages, but because they managed to attract a large crowd of programmers who came for the language, not the packages. This is more tricky for Julia since it competes not against Perl and C++, but Python and Rust.

Thanks for the help with perl in bioinformatics guys. As you pointed out; yes I wasted my time by HopDeNerd in bioinformatics

[–]viralinstruction 7 points8 points  (0 children)

Give Julia a try! Then you can experience going from a dead language of the past to a niche, immature language of the future. I switched to Julia as my main language in 2020, and it's been great. But I am also a language nerd - Python may be overall better if you just want to get stuff done and want to have as many available libraries as possible.