News for hackers. Stuff that matters.

privethedge

Re:Being Alone on Monday June 22, 2020 @09:22AM (#23599863)
I'm alone and don't feel bad at all. Actually, I prefer to be alone. There are so many interesting things to do, so many interesting books to read, etc, I don't understand how someone can be bored. It's really strange to me that so many people suffer from being alone and feel lonely.
Re:What I Wish I Knew When Learning Haskell on Sunday April 12, 2020 @05:26AM (#22846993)
For those who really want to blow their mind, I suggest learning Coq instead https://softwarefoundations.cis.upenn.edu/
Re:From Zero to Main(): Bare Metal Rust on Tuesday December 17, 2019 @08:18PM (#21820868)
This is great and I love Rust, but

> However, when working directly with the hardware, which has no knowledge of Rust’s guarantees, it is necessary to work in Rust’s unsafe mode, which allows some additional behaviors, but requires the developer to uphold certain correctness guarantees manually.

If the whole code will be wrapped in unsafe blocks, then what is the point of using Rust?

There are also union types. And sum types can be implemented in terms of union types: https://waleedkhan.name/blog/union-vs-sum-types/
Re:Parse, Don’t Validate on Friday November 08, 2019 @05:37AM (#21481159)
What if there is another application (or e.g. a stored procedure) that uses this DB table so you cannot control all saving operations from your application?
Re:Parse, Don’t Validate on Friday November 08, 2019 @05:31AM (#21481128)
> Sure, I didn’t say it does.

Sorry, I implied it from your "foo" example.

> two phases

So maybe we need to change the mantra to “parse, and validate as little as possible”?

Re:Parse, Don’t Validate on Thursday November 07, 2019 @05:25PM (#21477964)
> head :: [a] -> a

> This function returns the first element from a list. Is it possible to implement?

But the type itself doesn't say that it must return the first element.

> If you see why parseNonEmpty is preferable, you understand what I mean by the mantra “parse, don’t validate.”

Okay, what about more complex cases? E.g. how do you describe type "such value doesn't exist in the db table yet"?

Then why do I have the following results?

    const a = [...Array(1000000).keys()];
    const m = 8;
    let leftAvg = .0;
    for(let _ of Array(m)) {
        const t0 = performance.now();
        a.map(Math.tan).map(Math.sin);
        const t1 = performance.now();
        leftAvg += (t1 - t0)/m;
    }
    let rightAvg = .0;
    for(let _ of Array(m)) {
        const t0 = performance.now();
        a.map(x => Math.sin(Math.tan(x)));
        const t1 = performance.now();
        rightAvg += (t1 - t0)/m;
    }
    console.log(leftAvg, rightAvg, leftAvg/rightAvg);
    // JS Firefox 70:  264 360.75 0.7318087318087318




    var a = Enumerable.Range(0, 10000000).Select(x => (double)x).ToArray();
    double[] xs1 = null;
    double[] xs2 = null;
    var m = 16;

    var leftAvg = .0;
    foreach (var _ in Enumerable.Range(0, m))
    {
        var watch = System.Diagnostics.Stopwatch.StartNew();
        xs1 = a.Select(Math.Tan).ToArray().Select(Math.Sin).ToArray();
        watch.Stop();
        leftAvg += (double)watch.ElapsedMilliseconds / m;
    }

    var rightAvg = .0;
    foreach (var _ in Enumerable.Range(0, m))
    {
        var watch = System.Diagnostics.Stopwatch.StartNew();
        xs2 = a.Select(x => Math.Sin(Math.Tan(x))).ToArray();
        watch.Stop();
        rightAvg += (double)watch.ElapsedMilliseconds / m;
    }

    Console.WriteLine($"{leftAvg} {rightAvg} {leftAvg / rightAvg}");
    // C# Results: 505.75 602.25 0.839767538397675
Then it is 8Gb of pointers. I doubt it's practical to worry about such extreme cases.
> a.map(g).map(f) ≣ a.map(x => f(g(x)))

> But the one on the left will be slower and use a lot more memory.

Is it really true? I mean, GC will clean the intermediate array, won't it? And the speed won't be significantly slower. It's still linear complexity anyway.

Re:Text Rendering Hates You on Sunday September 29, 2019 @02:41PM (#21108822)
> If you're in Safari or Edge, this might still look ok! If you're in Firefox or Chrome, it looks awful, like this: https://gankra.github.io/blah/text-hates-you/transparent-cur...

It doesn't look awful in Firefox, it looks perfect (it's version 26 of Firefox though.) This is what I see https://i.imgur.com/sjvqycv.png

Re:Why Haskell Is Important on Sunday September 08, 2019 @09:05AM (#20910333)
There was Liskell, but it seems it's dead.

https://wiki.haskell.org/Haskell_Lisp

Re:Why Haskell Is Important on Sunday September 08, 2019 @06:32AM (#20909660)
> Purity and side-effect isolation

This can be solved in many ways [1][2] and I don't think haskell's approach is the one that can be imported.

[1]: https://www.microsoft.com/en-us/research/wp-content/uploads/...

[2]: https://en.wikipedia.org/wiki/Uniqueness_type

I mostly use Console, Network and Inspector tabs and I rarely debug (in general.) Especially Network tab in Firefox's dev tools is much superior to Chrome's one, IMHO.
Can I say please that it's very annoying that Chrome (and everything Blink based) doesn't let you to open a file in an application you can choose and see the size of the file before downloading it?

https://www.ghacks.net/wp-content/uploads/2013/07/firefox-do...

I personally prefer firefox's dev tools to chrome's ones.
Re:DSVPN – VPN using TCP at port 80 and 443 on Wednesday July 31, 2019 @12:40PM (#20575875)
https://en.wikipedia.org/wiki/SoftEther_VPN > Firewalls performing deep packet inspection are unable to detect SoftEther's VPN transport packets as a VPN tunnel because HTTPS is used to camouflage the connection.
Re:Thaddeus Kosciusko on Friday July 12, 2019 @08:21AM (#20420133)
https://www.nytimes.com/2019/07/07/world/europe/kosciusko-be... > “Belarus did not even exist when he was born,” said Veslav Wychodzki, a retiree from Poland who traveled to Kosava recently to pay tribute to Kosciuszko. “This was Polish land. They only put up a statue to him last year and never really talked about him before.”

> Mr. Nesterchuk, the Belarus historian, said: “The Poles say he belongs to them. The Lithuanians, the Ukrainians say the same thing. The Americans, too.”

> “But I always say that Kosciuszko does not belong to anyone,” Mr. Nesterchuk added. “He belongs to the whole world as a true democrat and a fighter for freedom.”

Re:Ask HN: What influenced your personal growth the most? on Monday January 15, 2018 @12:03PM (#16151726)
I doubt that you doubt it.
Re:Ask HN: What influenced your personal growth the most? on Monday January 15, 2018 @11:40AM (#16151537)
Scepticism.