Better HN
topnewbestaskshowjobs
Log inSign up

grumpyprole

4,485 karma · joined Jun 30, 2015 (11y ago) · 2,043 submissions

Submissions

comment 4y ago · link · parent

> You can absolutely write fairly nice functional code in Java already

You mean it has Lambdas? Yes that's a start, but there's a lot more it needs to claim good FP support. Programming with lambdas is not sufficient to do "functional programming", which is really about composing pure functions (everything else follows from this, e.g. immutable data). Java's roadmap does look promising though.

comment 4y ago · link · parent

It's not about just being more expressive. See the Brian Goetz quote. A more "functional style of programming", this means less mutation, more pure functions, e.g. Java's proposed records are immutable.

comment 4y ago · link · parent

Yes they have succeeded in using Java to make profit, but argubly not in creating reliable, secure and easily maintainable software. Like I said, even Java's creators believe there is significant room for improvement.

comment 4y ago · link · parent

It has a culture of over-engineering, just look at Log4J or Spring with its AbstractSingletonProxyFactoryBean's. More complicated and far more adhoc than any abstraction should be.

comment 4y ago · link · parent

The way I see it, is people searching for a better way, after years of trying to actually use Java. And what does Java's chief architect think?

"It is my belief that the best direction for evolving Java is to encourage a more functional style of programming. ... We're not going to turn Java into Haskell, nor even into Scala. But the direction is clear."

https://mail.openjdk.org/pipermail/lambda-dev/2011-August/00...

comment 4y ago · link · parent

The Java runtime provides runtime type information for all types, and extensive reflection is available, including for example invoking arbitrary code. Very dynamic and a significant problem for static analysis, optimisation and security.

comment 4y ago · link · parent

A bigger issue I think is Java's need to box values, primitive or otherwise. For example, even an ArrayList of integers creates an object for each one. IMHO, the Java runtime has many of the design hallmarks of a dynamic language, with strong (generic) types somewhat bolted on.

comment 4y ago · link · parent

My point is that there are no studies demonstrating the absence of such issues. Anecdotally, my Bluetooth headphones certainly seem to sound better with a FLAC source.

comment 4y ago · link · parent

> even Vorbis at 128kbps or other formats at 256kbps or higher will provide a very good listening experience.

Until it is resampled in the noisy OS mixer and/or lossy compressed again to be sent over Bluetooth. Very few ABX studies consider the effect of such modern "digital signal chains", especially transcoding. It's much better to start with FLAC.

comment 4y ago · link · parent

I was interested that Blackberry didn't use Android - their QNX based OS had a lot of potential. At the time, my Android phone would get hot and drain the battery whenever a batch process decided to reindex my media.

comment 4y ago · link · parent

This one's older, but here's an example using Haskell: http://www.timphilipwilliams.com/slides/minecraft.pdf

The main idea is algebraic composition (a non-commutative monoid).

comment 4y ago · link · parent

> Long answer: they aren't.

This is not true in general. It is only true for instruments that use the well tempered tuning, e.g. a piano. But for example, the violin and cello do not.

comment 4y ago · link · parent

If you don't mind some advanced Haskell, these slides have plenty of examples:

https://github.com/willtim/recursion-schemes/blob/master/sli...

comment 4y ago · link · parent

Why is a game not like that? It transforms a stream of input events into stream of output events (video and sound hardware commands). Yes there is lots of state, but that can also be thought about as data that is transformed, step-by-step.

comment 4y ago · link · parent

I agreed with your parent post and upvoted you, but too many inexperienced with functional programming claim it is all (or too much) recursion. I think this should be challenged.

Yes recursion is a useful tool, just like GOTO and is sometimes necessary or more practical. But it is better to e.g. use a fold if you can because that further constrains and aids reasoning. For example, a fold will always terminate unlike general recursion.

I recommend looking into recursion schemes, if you aren't familiar with them.

comment 4y ago · link · parent

Yes, recursion can be used to define a function inductively, just as we would in maths. However, recursion is the "GOTO" of functional programming and we prefer to used structured programming if possible, e.g maps/folds/unfolds etc. That would be a better reply for the parent post.

comment 4y ago · link · parent

> the tweak-it-until-it-kinda-works languages are fucking killing it on adoption.

Industry clearly prioritises speed of delivery above all else. Security, reliability and maintenance are future problems (that would be nice to have).

However, in order to gain the power to reason about our code and be able to prove the correctness of various properties (what a typechecker does), we have to program with more restrictive models. This has been argued many times before (e.g. Dijkstra's structured programming). Haskell and Rust are just two of many examples. My favourite is regular expressions, choose actual proper regexes and you have guaranteed O(n) execution, choose Perl/Python "Regex" and you have a potential security hole.

comment 4y ago · link · parent

> I have to laugh at these conspiracy theories.

Well, there are certainly a lot of closed platforms. But arguably it started a long time ago with games consoles.

comment 4y ago · link · parent

Iterators are potentially a much better design too as they allow for more modular code.

comment 4y ago · link · parent

Are you recommending zstd based on compression speed and ratio only? Because as the linked article explains, those are not the only criteria. How does zstd rate with everything else?

comment 4y ago · link · parent

Again, I was speaking generally about digital audio, the average consumer has no idea what happens when using audio playback software, USB DACs, AirPlay, Chromecast etc. Even a few of the downloads I have purchased have been resampled (more fraud than secret in that case).

comment 4y ago · link · parent

> We’re in control and it’s as perfect as it gets.

Do you perform bit-perfect tests to be sure? The people who write the software are surely the ones in control.

comment 4y ago · link · parent

> A DAC is a sampler that sends digital audio to your computer

No, DAC means digital-to-analogue convertor. It comes after the computer. Sampling before a computer is done by an ADC.

> The signal chain is that simple.

No, the software signal chain is not simple.

comment 4y ago · link · parent

I don't disagree that digital can be much better than analogue, or that analogue does not have problems.

comment 4y ago · link · parent

I am speaking generally, it is difficult to be in full control of the signal chain as it is often up to the software and operating systems. Even as someone who just plays music, getting a "bit perfect" feed for my DAC is highly non-trivial.

comment 4y ago · link · parent

Especially as digital signal chains are potentially more lossy: compression, transcoding, resampling. It's very often completely opaque too.

comment 4y ago · link · parent

It is! :) Perhaps the name could have made it more obvious: e.g. "get_or_fail"

comment 4y ago · link · parent

Unwrap is just the same (or better) than expect(""). The cat is out the bag with expect. What is needed, is good documentation, style guides, example code etc to guide users towards understanding the trade-offs and making informed decisions. I suppose unwrap could have had a more scary name.

comment 4y ago · link · parent

As Alan Kay said, the industry is a pop culture, driven by marketing not science. I'm still going to argue for good ideas though.

comment 4y ago · link · parent

Haskell let's one write fast imperative code when needed or call C functions.
1
161718
69