4,901 karma · joined Sep 13, 2020 (6y ago) · 1,641 submissions
comment 4y ago · link · parent
comment 4y ago · link · parent
And in the case of Swift the atomic "release" calls at ends of scopes will run regardless whether there are hot loops or not.
So it all depends on the language.
Also, you pointed to 3 languages with 3 different memory management strategies and 3 different toolchains (Rust is LLVM-based; Nim compiles to C and then calls a C compiler, GCC recommended; D has its own non-GCC non-LLVM compiler). It feels weird to put them in the same bag implementation-wise.
[1]: <https://golangbyexample.com/goroutines-golang/> (potentially stale information)
comment 4y ago · link · parent
What precisely do you mean by that statement? What is the thing that is not provable but constructible? A conjecture? If so, then what do you mean when you say that a conjecture is constructible? What does it mean to construct it?
As far as I know, "construction" in maths usually means a finite process. And proofs are finite sequences of strings, satisfying certain rules specified by a proof framework (such as sequent calculus). So I'm curious in what way something could be constructible, but not provable. To be honest, I don't understand how those words could apply to the same things, because proving usually applies to conjectures, statements, formulas etc. But constructing usually applies to definitions and proofs, which cannot said to be true or false at all.
comment 4y ago · link · parent
What PDF-s generated by LaTeX have, that so far web failed to replicate, is beautiful fonts for maths, consistency, legibility and overall beauty of the end result. They also have the advantage that they are self-contained, so if I want to archive one or move to another place, I just grab the single file and I'm done. With web a single document is distributed across many files and you need make a weird wget dance (which is easy to misuse)/install some obscure browser extensions/etc - not exactly user-friendly. Also, if you want to print the document to get away from the distraction of the computer, you're guaranteed to get at least as good a result as what you see on the screen.
Don't get me wrong. This attempt is better than any that I've seen so far. Kudos to the author for that. It's no small feat. But it doesn't prove that PDF-s are obsolete and that people favouring them are irrational.
comment 4y ago · link · parent
I do not deny the usefulness of ADTs (which is what "private" is all about). I question whether it's the right default. My experience tells me it isn't. Whether you call my style of programming "OOP", is irrelevant to me. This term, after decades of evolution, doesn't mean anything anymore. I certainly don't treat it as a badge of quality and don't consult any definition of it before judging whether a particular technique in programming is useful or not.
comment 4y ago · link · parent
Fred Brooks:
> Show me your flowcharts and conceal your tables, and I shall continue to be mystified. Show me your tables, and I won’t usually need your flowcharts; they’ll be obvious.
In that situation, having to sprinkle "public"/"pub" all over them is very noisy and unproductive. It's the worst with Rust's enums, which require you to declare the visibility of variants and enclosed types of variants separately, so you see a couple "pub"-s per line of an enum definition.
That may be an argument for separate keywords for plain data, and for "APIs", although I'm not sure how I feel about it. Underneath it's just coupling of data with functions. Some languages have separate keywords for those, some don't.
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
I found that a lot of those guidelines lead to the exact opposite. Examples:
- Prefer polymorphism to if/else or switch/case (oh, the joy of tracing a simple task through 50 files)
- Use dependency injection (same as above)
- Hide internal structure (that "private" is the default in C++, Java and Rust just adds to boilerplate; the default case is that you want everything public (unless you like writing trivial getters and setters just for the fun of it); legitimate uses of "private" exist, but are rare)
- One assert per test (I guess I need to throw my property-based tests out the window)
1185.
Ask HN: OS-es with dynamically-linked libs in separate address spaces?
2 points · by yakubin · 4y ago · 3 comments
comment 4y ago · link · parent
- recipes (doesn't matter whether it's from today or from 30 years ago, what matters is the quality of the recipe)
- art and art theory
- poetry
- chess
- films
Searching by date or date range doesn't work, when you don't know when a relevant article was written. What's needed is not an option to select older articles, but an option to stop prioritizing new ones.
comment 4y ago · link · parent
As for ML functors: they're neither polymorphism, nor dynamic dispatch. First: functions for different types can't share names (unless we're talking about shadowing of names with lexical scope), the names are either qualified with the name of the struct they come from or they're not qualified at all. In all cases there is exactly one implementation for every name. And again: no dynamic dispatch. MLton even defunctorizes all code at compile-time. The only polymorphism in SML is the one that's used in some built-ins (like +), but it's not available to users of the language. SML has something called "polymorphic functions", but it has nothing to do with writing multiple implementations of one function under one name and letting the compiler select which one is called; which is what is usually meant by "polymorphism".
comment 4y ago · link · parent
Also, stabilising a full-blown camera in hands is a lot easier than stabilising a smartphone.
[1]: Mantises aren't really a thing in this part of the world.
comment 4y ago · link · parent
comment 4y ago · link · parent
Scheme:
> (mod 5 2)
1
> (mod 5 -2)
1
> (mod -5 2)
1
> (mod -5 -2)
1
> (remainder 5 2)
1
> (remainder 5 -2)
1
> (remainder -5 2)
-1
> (remainder -5 -2)
-1
Haskell: Prelude> a = 5 :: Integer
Prelude> b = 2 :: Integer
Prelude> mod a b
1
Prelude> mod a (-b)
-1
Prelude> mod (-a) b
1
Prelude> mod (-a) (-b)
-1
Prelude> rem a b
1
Prelude> rem a (-b)
1
Prelude> rem (-a) b
-1
Prelude> rem (-a) (-b)
-1
So in Scheme mod is the Euclidean modulus (always >= 0) and remainder takes the sign of the dividend (comes from truncated division, same as C's %). In Haskell mod takes the sign of the divisor (floored division, same as Python), while rem behaves the same way as Scheme's remainder or C's %.I prefer Scheme's way, because it was what we always used in classes when I studied maths. mod returning a negative number is just too weird.
EDIT: It appears that Scheme also has modulo, which comes from floored division:
> (modulo 5 2)
1
> (modulo 5 -2)
-1
> (modulo -5 2)
1
> (modulo -5 -2)
-1comment 4y ago · link · parent
Longer term, I'm planning on moving to another country (from Eastern Europe to most likely one of: Scotland, Netherlands or Finland) and, from what I gather, my company will allow me to work from abroad. Even longer term, I'm planning on simply starting my own company, so place is not going to be a constraint.
comment 4y ago · link · parent
That's not true. Many pure mathematicians use programs such as Wolfram Mathematica and Macaulay2 in their work. (Source: I studied maths and I know a bunch of them personally.)
comment 4y ago · link · parent
Now as for completely theoretical possibility you can reverse any hash by brute-force. But that may not be computationally feasible. Now let's think what is easier: reversing a hash with few or many collisions? Let's take an edge case: a hash function hashes everything to just one value (not a very good hash function, but bear with me). That will be the easiest hash function to reverse, since any input is a right answer. Now as you reduce the number of collisions, the task becomes harder: you can divide images into disjoint sets such that each of them is defined by the hash value images in this set hash to, so if you have two images, each from distinct set, they hash to distinct values, and if they are in the same set, they hash to the same value. When you reduce the number of collisions the sets get smaller in size, but their amount grows. So for any given hash value which you want to reverse you need to check a bigger number of candidates to figure out which of the sets is the one for the given hash value (one candidate to check from each set). And that's assuming it would be feasible to just keep a list of those sets and their members, which it isn't, but illustrates the correlation. So actually it's easier to reverse when you have more collisions. It's counter-intuitive, because it's a different kind of reversing than what is usually meant by "reversing a function", which requires a function to be injective.
But: with fewer collisions you have higher likelihood that what you got as the result of reversing is what someone else used as input to the hash function (each of the sets is smaller, so with uniform distribution we get 1/n probability, where n is the number of elements in a given set of elements hashing to the same value).
Anyway, the sets I wrote about here are elements of a quotient set defined by the equivalence relation of hashing to the same value. You can read more on Wikipedia, if my description was a bit confusing: <https://en.wikipedia.org/wiki/Equivalence_class#quotient_set>
comment 4y ago · link · parent
Now from the comments I've found out about yt-dlp[1] which claims to fix this issue[2]. Will check it out.