Better HN
topnewbestaskshowjobs
Log inSign up

drathier

133 karma · joined Nov 3, 2016 (10y ago) · 9 submissions

Submissions

comment 8mo ago · link · parent

1. Such bad examples :( Tuples are data types you have to destruct, in every language. Somebody please show me a language where this doesn't require a tuple-to-function-argument translation:

  sayHi name age = "Hi I'm " ++ name ++ " and I'm " ++ show age
  people = [("Alice", 70), ("Bob", 30), ("Charlotte", 40)]
  -- ERROR: sayHi is String -> Int -> String, a person is (String, Int)
  conversation = intercalate "\n" (map sayHi people)

In python you have `*people` to destruct the tuple into separate arguments, or pattern matching. In C-languages you have structs you have to destruct.

2. And performance, you'd think a slow-down affecting every single function call would be high-up on the optimization wish list, right? That's why it's implemented in basically every compiler, including non-fp compilers. Here's GHC authors in 2004 declaring that obviously the optimization is in "any decent compiler". https://simonmar.github.io/bib/papers/eval-apply.pdf

3. Type errors, the only place where currying is actually bad, is not even mentioned directly. Accidentally passing a different number of arguments compared to what you expected will result in a compiler error.

Some very powerful and generic languages will happily support lots of weird code you throw at them instead of erroring out. Others will errors out on things you'd expect them to handle just fine.

Here's Haskell supporting something most people would never want to use, giving it a proper type, and causing a confusing type error in any surrounding code when you leave out a parentheis around `+`:

  foldl (+) 0 [1,2,3] :: Num a => a
  foldl + 0 [1,2,3]
    :: (Foldable t, Num a1, Num ((b -> a2 -> b) -> b -> t a2 -> b),
        Num ([a1] -> (b -> a2 -> b) -> b -> t a2 -> b)) =>
       (b -> a2 -> b) -> b -> t a2 -> b
Is it bad that it has figured out that you (apparently) wanted to add things of type `(b -> a2 -> b) -> b -> t a2 -> b` as if they were numbers, and done what you told it to do? Drop it into any gpt of choice and it'll find the mistake for you right away.

comment 8mo ago · link · parent

https://capnproto.org/ has been my goto since forever. Made by the protobuf inventor

comment 4y ago · link · parent

Lots of web devs only testing in chromium browsers, perhaps?

comment 4y ago · link · parent

Why don't any of these websites have maps?

comment 5y ago · link · parent

Lies!

comment 10y ago · link · parent

Did I just render that book obsolete?

comment 10y ago · link · parent

The code snippet it finds imports sleep and calls it directly. Fire it up in a repl and check __author__ or _code yourself :)

8.

StackOverflow Importer – Import code from Stack Overflow as Python modules(github.com ↗)

301 points · by drathier · 10y ago · 84 comments

9.

From stackoverflow import quick_sort(github.com ↗)

4 points · by drathier · 10y ago · discuss