News for hackers. Stuff that matters.

porges

Re:Chess, a Drosophila of reasoning on Monday December 10, 2018 @03:21AM (#18646159)
Here's a much better article with a similar title: https://pdfs.semanticscholar.org/c9e7/3fc7ec81458057e6f96de1...
Re:A formalization of category theory in Coq on Saturday August 05, 2017 @06:08AM (#14935026)
I can recommend SF, I just started it a week ago without prior Coq experience. I'm using the VSCode integration which helps, CoqIDE is a bit clunky.
Re:2D Syntax on Thursday June 29, 2017 @02:03AM (#14661117)
At that point aren't you just doing normal Racket pattern matching?

    (match
      (list (> x y) (stringp foo) (oddp n))
      [(list #t     _             #t      ) (whatever)]
      [(list _      #t            _       ) (other-thing)]
      [(list #t     #f            _       ) (etc)])
... or is that the joke :)
Re:Viper: a new programming language from Ethereum on Tuesday May 23, 2017 @01:37AM (#14399026)
Swift

C# has the ability to opt-into default checked arithmetic. I don't know of anyone that uses it...

Re:Me and SVG on Thursday April 20, 2017 @08:25PM (#14162099)
This looks really good, thanks! Nice support for isometry.
Re:Deis to Join Microsoft on Monday April 10, 2017 @09:08PM (#14084052)
That's just Windows. There's no combined codebase akin to Google's.
Re:How real are real numbers? (2004) on Monday April 10, 2017 @08:35PM (#14083846)
The difference is that a French text must be finite.
Re:Paxos in 25 Lines on Tuesday March 21, 2017 @06:19PM (#13926811)
("Free-format") Fortran has a max line length of 132 chars, up from ("fixed-format") 72 chars on punch cards.
Re:The lost letters of the English alphabet on Thursday January 19, 2017 @03:48AM (#13434178)
Yeah, I originally qualified everything and then figured most readers of the site are USian anyway ;)
Re:The lost letters of the English alphabet on Monday January 16, 2017 @07:39PM (#13414308)
FYI: `languæge` and `charæcters` don’t make much sense—‘æ’ and ‘œ’ usually changed to simple ‘e’ in modern English (Encyclopædia, mediæval), unless at the start of a word (æsthetics). There are variations, ‘œ’ seems to have been more likely to change to ‘e’ at the start of a word (œsophagus, œstrus).

Also, not every ‘ae’ was an ‘æ’—‘aerial’ is one example. I think the test is whether or not the Greek word used ‘αι’.

Re:The lost letters of the English alphabet on Monday January 16, 2017 @06:31AM (#13409424)
That's mostly because Encyclopædia Britannica is styled that way.
Re:The lost letters of the English alphabet on Monday January 16, 2017 @06:29AM (#13409414)
Also why Menzies is pronounced "mingiz": https://en.m.wikipedia.org/wiki/Menzies
Re:What lies beneath async/await in C#? on Thursday January 12, 2017 @08:32PM (#13387730)
Haskell for one, but lots of others: https://en.wikipedia.org/wiki/Green_threads
Re:Why Chrome 53 Is Rejecting Chase Bank's Symantec Certificate on Tuesday November 15, 2016 @04:35AM (#12956761)
Forgive my ignorance, but if you're issuing certificates for internal hostnames that you want to keep private, why would you need a public cert? Wouldn't an internal CA be better?
Re:New Zealand earthquake: Tsunami follows powerful tremor on Sunday November 13, 2016 @05:38PM (#12946126)
That page is just an inferior version of the source: https://www.geonet.org.nz/quakes/felt
> After instructions, participants were given printouts of sample code they could refer to while solving tasks. Group Lambda got code of a C++ program using lambda expressions and group Iterator received code of the same program written using iterators. They then had time to study the samples before starting the tasks and could refer to these samples later.

These samples do not appear in the paper, so we don't know what they saw.

The “iterators” discussed are Java-/C#-style iterators, not C++ ones (as I expected reading the abstract).

In a C++ context I would have expected lambdas vs iterators to be something like:

    // lambda
    float retVal = 0;
    std::for_each(mb.cbegin(), mb.cend(), [&](item x) { retVal += item.price; });
    return retVal;

    // pure iterator
    float retVal = 0;
    for (auto it = mb.cbegin(); it != mb.cend(); ++it)
    {
        retVal += it->price;
    }

    return retVal;
... and the first would be better off as:

    return std::accumulate(mb.cbegin(), mb.cend(), 0f,
        [](float acc, item x) { return acc + x.price; });

I think the need to use ref-capture (since you only get a side-effecting `std::function` to play with in their sample) would be the thing most likely to throw people off – as it’s something that should be avoided in most code, anyway ;)
Re:The Birkana hexadecimal number symbols on Sunday October 16, 2016 @11:19PM (#12722491)
The Tài Xuán Jīng symbols are, however. A subset can be used like:

𝌆𝌇𝌉𝌊𝌏𝌐𝌒𝌓𝌡𝌢𝌤𝌥𝌪𝌫𝌭𝌮

So Unicode has Bagua (3 bits), Tài Xuán Jīng (4 trits), and I Ching (6 bits, but incomplete).

Re:Proposal of a new concurrency model for Ruby 3 [pdf] on Thursday September 08, 2016 @04:58AM (#12451349)
I{HEART}COM
Re:Ill-Advised C++ Rant, Part 2 on Sunday March 06, 2016 @10:18PM (#11236898)
> Calculating the size of a static array.

std::size is in C++17: http://en.cppreference.com/w/cpp/iterator/size

This is hilarious.
Re:AMS-IX Breaks 4 Terabits per Second Barrier on Thursday September 17, 2015 @04:13PM (#10235768)
Because that seems to be what the person who came up with the "63 MB" figure has done.
Re:AMS-IX Breaks 4 Terabits per Second Barrier on Thursday September 17, 2015 @06:44AM (#10232570)
Something does seem funky. The website looked like this in 1997: http://web.archive.org/web/19970418234503id_/http://www.bath... [This page is 3,780 bytes.]

In fact, you can find the server stats from back then: http://web.archive.org/web/19970822145424/http://www.bath.ac...

This says that it transferred "3 599 Mbytes" and there were "728 506" requests. Interpreting "3 599" as 3.599 gives 4.94 bytes per request, which is absurd. It must be 3.6 GB, making each response just under 5 kB. This seems much more reasonable.

So the number on that page should probably be interpreted as 63 GB, which is reasonable if we assume the site became more popular later in the year, as the original source suggests (3.6 GB*12 = 43.2 GB, and the stats are from May).

Also notice the following year (1998) says 126 MBytes and in 1999, 197 GB. That's an order of magnitude jump!

Re:OCamlers' critiques of Haskell on Thursday August 27, 2015 @04:30AM (#10128229)
These exist in Haskell as "Pattern Synonyms". Here's a partial translation of some of the F# examples on MSDN to Haskell;

  {-# LANGUAGE PatternSynonyms, ViewPatterns #-}

  pattern Even <- ((`mod` 2) -> 0)
  pattern Odd <- ((`mod` 2) -> 1)

  testNumber x = show x ++
      case x of
          Even -> " is even"
          Odd -> " is odd"


  data Color = Color { r :: Int, g :: Int, b :: Int }

  pattern RGB r g b = Color r g b
  -- NB: this is bidirectional automatically

  printRGB :: Color -> IO ()
  printRGB (RGB r g b) = print $ "Red: " ++ show r ++ " Green: " ++ show g ++ " Blue: " ++ show b

  -- pretend we have functions to and from RGB and HSV representation

  toHSV :: Color -> (Int, Int, Int)
  toHSV = undefined -- implement this yourself!

  fromHSV :: Int -> Int -> Int -> Color
  fromHSV = undefined

  pattern HSV h' s' v' <- (toHSV -> (h', s', v'))
      -- here we explicitly provide an inversion
      where HSV = fromHSV

  printHSV :: Color -> IO ()
  printHSV (HSV h s v) = print $ "Hue: " ++ show h ++ " Saturation: " ++ show s ++ " Value: " ++ show v

  -- demonstrating being able to use pattern
  -- to construct a value
  addHue :: Int -> Color -> Color
  addHue n (HSV h s v) = HSV (h + n) s v
Re:Re: C as used/implemented in practice on Monday July 13, 2015 @08:30PM (#9882118)
The point here is not particularly about signedness, it's that UB allows better optimizations to be performed.

If overflow is defined to wrap around then it's potentially an infinite loop (take N == MAXVALUE). With overflow defined as UB you can say the loop executes exactly N times (because you're not allowed to write code that overflows).

So UB is both bad and a source of power :)

Re:String Interning – Trie vs. Hash Table Deathmatch on Monday June 29, 2015 @07:20PM (#9801824)
> It seems the terrible performance of the STL can be explained by std::string: this thing hits the general purpose allocator every time a new string is constructed. In this benchmark, that means every time we insert a string, possibly more. Not good for such an inner loop. There are ways to speed things up, but that would complicate the code, and defeat the purpose of leaning on the standard library.

It's actually reasonably easy to avoid the unnecessary copying.

Something like this would do (use a string as the buffer, pass it by reference, then use `try_emplace`). Also, it should probably be using the same hash function as your C code:

    #include <cstdint>
    #include <fstream>
    #include <string>
    #include <unordered_map>

    class Intern_pool
    {
        struct fvn_hash
        {
            // FVN-1a hash -- http://isthe.com/chongo/tech/comp/fnv/
            std::size_t operator()(const std::string& s) const
            {
                std::size_t hash = 2166136261; // offset basis (32 bits)
                for (auto c : s)
                {
                    hash ^= c;       // xor
                    hash *= 16777619;   // prime (32 bits)
                }
                
                return hash;
            }
        };

        std::unordered_map<std::string, std::uint32_t, fvn_hash> map;
        std::uint32_t next = 0;

    public:
        std::uint32_t add(const std::string& s)
        {
            auto r = map.try_emplace(s, next);
            if (r.second)
            {
                ++next;
            }

            return r.first->second;
        }
    };

    int main(int argc, const char* argv[])
    {
        for (int i = 1; i < argc; ++i)
        {
            std::ifstream file(argv[i]);

            Intern_pool intern_pool;

            std::string line;
            while (std::getline(file, line))
            {
                intern_pool.add(line);
            }
        }

        return 0;
    }
Re:Optimizing an Important Atom Primitive on Wednesday June 17, 2015 @06:50AM (#9730969)
Yi is one editor that does incremental parsing correctly: https://github.com/yi-editor/yi
Re:Favicon bug on Monday June 15, 2015 @04:43PM (#9721950)
All major browsers support PNG favicons
Re:Can Your Static Type System Handle Linear Algebra? (2014) on Wednesday April 29, 2015 @07:46PM (#9462582)
Each element of your matrix doesn't really have its own type, each column and row has a type:

                            1
                          +---
                       V  | V
                      Pa  | Pa

          V^-1    Pa^-1   
         +--------------- +-----
    mA   | mA/V   mA/Pa   | mA
    kg/s | kg/V/s kg/Pa/s | kg/s
I can imagine a system that types this quite well.
Re:The Z3 Theorem Prover released under MIT license on Thursday March 26, 2015 @06:38PM (#9273621)
There are potentially patents on the code, e.g. https://www.google.co.nz/patents/US8515891 which discusses PEX + regex (mentioning SMT solvers).
Re:CoreCLR is now open source on Tuesday February 03, 2015 @08:39PM (#8994837)
You have to store the length, C# strings can contain '\0' (although the hashing code doesn't take this into account!)

Older »