HackerTrans
TopNewTrendsCommentsPastAskShowJobs

throwaway858

no profile record

comments

throwaway858
·il y a 3 ans·discuss
The current implementation is not memory safe. Go uses 128 bit structs for interfaces and slices and assumes that they are updated atomically (when they are not).

It's possible to exploit this to read/write arbitrary memory and to execute arbitrary code. It appears that in practice this is very difficult so the issue is ignored.

https://blog.stalkr.net/2015/04/golang-data-races-to-break-m...
throwaway858
·il y a 3 ans·discuss
Haskell has equivalents to all of those libraries, and much more. And they are probably easier to use and more powerful.
throwaway858
·il y a 3 ans·discuss
The technique for "Make a textarea auto-expand" is obsoleted by a new CSS property("form-sizing"):

https://chriscoyier.net/2023/09/29/css-solves-auto-expanding...

Even without using this new CSS property, the technique that is used (adjusting the "height" of the element) is not ideal and can be glitchy.

A better approach is to use a mirror hidden element:

https://css-tricks.com/the-cleanest-trick-for-autogrowing-te...
throwaway858
·il y a 3 ans·discuss
IHP is a batteries-included web framework similar to "ruby on rails" for Haskell, with strong static typing.

The website has lots of information and videos and beginner tutorials.

https://ihp.digitallyinduced.com/
throwaway858
·il y a 3 ans·discuss
Thanks for this link. It seems to confirm things: "aren’t Conduits and Transducers then equivalent (isomorphic)? I am pretty sure they are."

I view this as a good sign. When two independent parties arrive at the same design it is usually an indication that they have discovered a universal and principled solution.

I consider the "conduit" library to be one of Haskell's "killer features", and sorely miss having something like it when working in other languages.

Maybe when Haskellers dismiss clojure transducers as being "just like conduit" it comes from a place of jealousy? I've seen several articles and discussions over the years of clojure transducers that take place outside of clojure communities and are aimed at the wider programming public, praising the benefits of it. But I've never seen conduit discussed outside of Haskell communities.
throwaway858
·il y a 3 ans·discuss
I'm not sure why the parent was downvoted, this sounds exactly like the Haskell conduit library (or indeed plain laziness if you don't need IO).
throwaway858
·il y a 3 ans·discuss
The shake build system (a general-purpose build system similar-to/better-than make) has a "prune" feature for exactly this purpose:

http://neilmitchell.blogspot.com/2015/04/cleaning-stale-file...

But I think the best solution (that also works with make) is to have a "make dist" target that creates a final .tar.gz archive of the result. If the rule is written properly then it won't contain any stale files. The disadvantage is for large project it may be slow, but you are not supposed to use this rule during development (where it is useless anyway), only for releases (which still can be built incrementally -- only the final .tar.gz needs to be created from scratch)
throwaway858
·il y a 3 ans·discuss
This reminds me of how book stores "return" unsold books to the publisher:

Shipping boxes of heavy books costs a lot of money, and the publisher doesn't actually need the books back (because they can always print new copies very cheaply).

So the publisher just tells the book store to destroy the books, and as evidence for their destruction asks only for the covers to be shipped back to them (which is cheap).

This is why books contain within them the text "This book should not be sold without a cover".

So with this printer company, they are effectively "destroying" the unused ink cartridge since it's not worth it economically to have it shipped back to them.

The added bonus is that if the customer renews the subscription then the ink can be "undestroyed"!
throwaway858
·il y a 3 ans·discuss
There is this for Haskell, which automatically converts all shell commands (like "ls") to regular Haskell functions:

https://chrisdone.com/posts/shell-conduit/

It uses a Haskell streaming library so you can do stuff like shell pipelines and file redirection (but in a more structured, safer and more powerful way)
throwaway858
·il y a 3 ans·discuss
If you ever need to use GNU make (still a popular tool) then you will be glad that you kept a policy of avoiding spaces in file names.

There are places in Makefiles where no amount of quoting will help you, and it simply cannot handle files with spaces.

Yeah, this is a problem with the tool that should be fixed, but my understanding is that it will never be fixed because of architectural reasons. And it's a very popular, useful, and most importantly, ubiquitous tool.

So this is another good reason to simply have a policy of banning filenames with spaces (and there are many more reasons).
throwaway858
·il y a 3 ans·discuss
There is no reason to believe that the AI will have self-preservation or self-replication as its goal.

One hypothetical example: it decides to "help" us and prevent any more human pain and death, so it cryogenically freezes all humans. now its goal is complete so it simply halts/shuts-down
throwaway858
·il y a 4 ans·discuss
A common case is when you need to add logging to a function.

There are 2 ways:

1. You cheat and use unsafePerformIO. This is discouraged and I won't go into the details.

2. You convert your inner function from being a "pure" function to being a monadic function over some abstract MonadLogger m. Then you can still call your function in a "pure" context by using a Writer monad for your MonadLogger, but you can also call it from the IO monad and get "better" logging (with real-time output and timing info).

Note that you still do need to convert your entire call chain from being pure to use "MonadLogger".

But I would argue that even in non-Haskell languages you should also do this (meaning you should thread a "Logger" object through all functions). Why? Let's say you don't, and now you want to do logging from some inner function. How do you configure the logging? To which file do you save it? What verbosity level? You will need to use a global/Singleton Logger object. But what if you want to call your function from two different places in your code and use a different verbosity setting for each? You can't. So I argue you are always just better off doing the refactor in all languages. The fact that Haskell forces this means that developers don't have the choice and are forced to do the right thing.
throwaway858
·il y a 4 ans·discuss
> A "function" is a "function" if it always returns the same result for the same arguments, right?

Yes. This matches the definition of a mathematical function that I gave above.

> how can I call a function which takes no arguments but which returns a value the user entered on the keyboard?

You can't. If your language allows you to write such a function then I would argue you are no longer doing FP (at least in this part of the code).

I believe that this is why many people like languages like Ocaml, F#, Scala. These are hybrid functional-OOP. You can use FP for the parts of the program that it's suitable for, and OOP/mutable-imperative for the other parts("the best of both worlds").

The purist FP programmers might claim that reading input from a keyboard is "uninteresting" and that programming is really about logic, algorithms, and computation, and therefore FP is enough for them (...in their ivory tower).

I personally am a fan of Haskell, but I don't like calling it FP, because it does allow you to write "code" that reads input from the keyboard. They still claim to be pure FP by using a loophole and saying that "getLine" is not a "function" but rather an "IO action". But to me it doesn't matter what you call it, you are still effectively allowed to write code that does I/O and mutates external stuff, doesn't matter if you call it a "function" or something else.

Of course the big advantage that Haskellers claim is that the language enforces the separation of effectful code from "pure" functions. In the other hybrid FP languages it is possible (and happens often) where you have a deep call chain of "pure" functions and then you realize you need some small side-effect somewhere, so you just add it. Haskell does not allow this at the language level, and forces you to refactor your code. In my opinion this does lead to cleaner architecture and more maintainable code in the long term.

But to me Haskell is really interesting for a different reason. I don't like to call it an FP language, because like I said, a lot of the code you write isn't really "functional". A better name would be: "mathematical oriented language". And by math I mean that the code is built using logical systems that have mathematical rules that can be reasoned about.

Going back the I/O (reading input from the keyboard): what the Haskell people have done is realized that you can actually model this behavior of user input as a mathematical model. This unlocks a type of thinking that allows you as the developer to go beyond the thinking of telling the computer: "do this, then do this, then do this, if this happens then do this, ...".

An example: the mouse-position on the screen. There are haskell libraries called FRP that model the mouse position as a "signal function" (a well-defined term they invented) that is a 2D coordinate that changes over time. You can then combine this signal function with others to create behavior such as an image that follows the mouse. You can build complete GUI applications using this approach, and the code looks nothing like imperative programming, and more like an electric circuit of different components connected together.

And that is just one example. The Haskell community has also come up with mathematical models for streams (think unix pipes) that allows you to write streaming code that is much more powerful and cleaner then what you see in other languages.

So my summary: Yes, functional programming is limited, but if we go one level deeper, we could say that the essence of FP is really mathematical thinking. And if we embrace that and run with it then we can open up entirely new possibilities.
throwaway858
·il y a 4 ans·discuss
That is not the definition of FP.

There is no definition of what FP is that is agreed upon by everyone, but the key is the word "functional" in FP.

This comes from a mathematical function, which is a mapping of input values to output values.

You could write a definition of a function f(x) to be such that the value of f(x) is the result of the execution of some imperative-looking code (including loops that mutate variables).

Mathematicians would be satisfied with such a definition and would confirm that f(x) is a function just as valid as any other.

And so functional programmers should also accept such a function. In fact, Haskell has specific syntactical support ("do" notation) to allow you to write functions using imperative-looking code including mutations (the ST monad, or other State monads).
throwaway858
·il y a 4 ans·discuss
It could be done if the thief, after having been found guilty, is then forced to pay a fine equal to the cost of the investigation and court costs.

Yes, this could end up being a fine of $10,000 for stealing a $150 phone, but there is an argument to be made that it is justified (and just).

What are the arguments against?
throwaway858
·il y a 4 ans·discuss
This isn't how it works. If a website is hosting content that infringes on some NDA, then you are supposed to sue the website (and not the person who posted it to the website -- who are often anonymous and can't be directly sued).

So Twitter would need to sue itself to demand that it take down the content. And the judge would reject the suit and scold Twitter for wasting the courts time, and tell Twitter that if it wants something removed from its own website then it should just remove it.
throwaway858
·il y a 4 ans·discuss
For every React there are 1000 other open source projects run entirely by volunteers.

I am curious if there is actual data on the number of man-hours that are spent on open source per year, and how many of those are funded by corporations. My guess is that it is less than 1%.
throwaway858
·il y a 4 ans·discuss
Lots of open source projects have a foundation that manages the money. The foundation decides how to allocate the funds based on what they think will provide most value to the community, whether that is covering server costs or paying specific individual contributors to write code.

Examples: Python Software Foundation, Haskell Foundation

In practice this seems to work well.
throwaway858
·il y a 4 ans·discuss
The Go runtime (and GHC runtime) use epoll from multiple threads and don't use SO_REUSEPORT and are highly efficient. I do believe that they use one epoll per thread.
throwaway858
·il y a 4 ans·discuss
The consumer did not actually agree to the terms of: "I, the consumer, will pay you $XX to download the film to my device, but you can delete it from my device at any time in the future without giving me a refund".

It may be written in the fine print, but it's not something that most rational consumers willingly agree to.