Better HN
topnewbestaskshowjobs
Log inSign up

grumpyprole

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

Submissions

comment 5y ago · link · parent

Yes, but like any encoding, it has its problems. One potential issue is that you will need to formulate your transformations as strict catamorphisms (folds), e.g. you cannot match two levels deep. This has reasoning advantages, but makes it harder for the average user. Type classes can also have issues with ambiguities, if many type variables are involved. Lastly, you also cannot match all remaining terms, like these examples:

  getDates
      :: Exp 
      -> Set Date
  getDates = cata alg where
    alg :: ExpF (Set Date) -> Set Date
    alg (EDate i) = S.singleton i
    alg e = fold e

  substitute 
      :: Map VarId (ExpF Exp) 
      -> Exp
      -> Exp 
  substitute env = cata alg where
    alg :: ExpF Exp -> Exp 
    alg (EVar i) 
      | Just e <-M.lookup i env = Fix e 
    alg e = Fix e

comment 5y ago · link · parent

By "compositional datatypes", I mean being able to define datatypes and functions on them in a modular fashion. I gave a very simple example with enums. For a real world use case, imagine a compiler pipeline, where we have an AST that we are desugaring over multiple steps. Ideally we want a succession of ASTs that remove the form being eliminated, so the AST type can guarantee it's eliminated. This is very easy with structural variants, there's no need to actually define and name each separate AST, which differs only slightly. Or imagine we are typing a SQL join that is a merge of two existing record types. Such "compositional data types" can be achieved with elaborate encodings and type-level computations in a language like Haskell (see e.g. Data types `a la carte), but it's difficult and somewhat ugly. There is an opportunity here for improvement.

comment 5y ago · link · parent

It's great to see a lean app without hundreds of dependencies.

comment 5y ago · link · parent

It's great to see structural typing in the form of polymorphic extensible records. But I am a bit disappointed they didn't go further, I would have at least liked to see extensible variants. The tuple-based syntax, also makes it rather noisy to use anonymous records as arguments (e.g. for named parameters).

If I was designing a new modern language, I would make the default types structural records and variants and use a single "new type" form for creating nominal types, when necessary. Compositional datatypes are much easier to achieve with structural records/variants (e.g. define a new enum set based on another). It is also trivial to make a structural type nominal, but not to go the other way. But having structural records as something special alongside nominal ADTs (like Flix, Elm and Purescript), does not exploit the duality and does not give a modern rethink that IMHO is needed.

comment 5y ago · link · parent

Are they perhaps scared of patents? The whole UI tries hard to be not like Windows or Mac OS, for IMHO little user benefit. I have tried to use Gnome in the past, seeking an easier life, but the multiscreen support was just not good enough. I use i3 instead.

comment 5y ago · link · parent

Not really a valid comparison. If you buy a pair of high-end Sennhiesers, they'll last many many years. I still use my HD580 from the 90s. They also sell all the necessary spare parts and are easy to repair (mine have had new cables and pads). An Apple product be will be e-waste in less than 10 years, the glued-in battery will start failing in less than 5.

comment 5y ago · link · parent

If the artist makes and sells the CD themselves, it could be close to 100%. This old article from 2013, says a typical figure for major labels is 13%: https://www.bbc.co.uk/news/magazine-23840744

How many times would I have to play an album on iTunes or Spotify before the artist received the same contribution? A thousand times? This source suggests so: https://soundcharts.com/blog/music-streaming-rates-payouts

comment 5y ago · link · parent

This is one reason why I still buy CDs. I know that a far bigger proportion of my money will be going to my favorite artists.

comment 6y ago · link · parent

What exactly do you mean by "build quality"? Do you just mean built from glass and aluminium? (hardly obvious choices for a laptop). IMHO, Apple can hardly claim to be leading in "build quality", what with glued-in batteries, un-repairable designs and keyboard reliability issues that have been ongoing for years.

comment 6y ago · link · parent

It was certainly well marketed. But in reality, Spring is also too complex. It has far too much dynamic dispatch, byte-code weaving magic and runtime failure. This is now causing them problems with GraalVM and fast startup times needed for cloud.

comment 6y ago · link · parent

None, I guess they didn't make it complicated enough!

comment 6y ago · link · parent

Oops, yes I mean't JSP not JSF. I almost want to learn more about JSF, out of morbid curiosity. I'm guessing one can't bookmark any pages and the back button is broken?

comment 6y ago · link · parent

In some future decade, when Banks start trying to migrate their "Enterprise Java" systems, anyone that can make sense of that bizarre and rather absurd model of computation is going to get well compensated.

comment 6y ago · link · parent

My jaw dropped the first time I learned that JSF was translated (not sure compiled is the right word) into Servlets full of print statements. And of course no JSF-based application has ever managed to produce valid well-formed HTML ever since.

comment 6y ago · link · parent

If one wants to learn what the Monad abstraction is, then one by definition will have to learn some category theory! I don't think there is any need to understand what a monad is in order to use any practical programming language. My point was that the burrito analogy does more harm than good (as predicted by Dijkstra).

comment 6y ago · link · parent

I completely agree. There should be motivating problems and examples. But I don't think that's at odds with Dijkstra's viewpoint?

comment 6y ago · link · parent

I cannot imagine a mathematics lecturer telling his students "a monad is like a burrito". Sometimes I think the analogies can actually hurt our understanding of something very abstract or novel, as is the case with the bad burrito analogy.

comment 6y ago · link · parent

Developers: please start supporting and advocating Linux, then we'll all have (hopefully) a better alternative future.

comment 6y ago · link · parent

I think what you are asking for are first-class parameterised modules, which is certainly a feature that OOP has that many FP languages don't. It does exist in some FP languages though, for example OCaml and the 1ML paper and language.

Most FP languages are already incredibly good for the amount of funding and development they have received. They could be so much better if industry / US big-tech actually started investing in them or the ideas behind them.

comment 6y ago · link · parent

The reasoning behind "closures", is that one can capture some context such as the example you describe. If we think of an object as simply a record of functions, then we can close over some shared context during the construction of such records, if we have a language with records and closures.

comment 6y ago · link · parent

"Dependency injection" frameworks look to me like a hack. In a more expressive language, such as F#, one could probably describe what needs to be done symbolically, and then write interpreters that implement the different behaviours required.

comment 6y ago · link · parent

Exactly what I was thinking

comment 6y ago · link · parent

> What you see in K8S is the exception rather than the norm in Go - but is the norm in other languages.

I suggest that is because not many large applications have yet been built in Go and it is still relatively young. If Go was used more sparingly as a "domain-specific language for concurrent network services", then I might be inclined to agree with you, but it seems to be marketed and promoted as a general purpose language.

comment 6y ago · link · parent

> Yeah it's hard to write weirdly complicated code in Go

Just because Go lacks many forms of abstraction, doesn't mean complex code will not be created with it. Quite the opposite. It's lack of expressiveness will encourage "frameworks", elaborate encodings, code generation and various productivity aids. Look at what the lack of generics has done to the Kubernetes code base:

"The core team replaced a compile-time language feature that was missing (Generics) with their home-built runtime system"

https://medium.com/@arschles/go-experience-report-generics-i...

comment 6y ago · link · parent

> Functional programming is about programming with immutability first.

I completely agree with this. So perhaps I am being rather hard on Scala.

comment 6y ago · link · parent

I am skeptical about the novelty of Scala's "OOFP" as you put it. It looks essentially the same as the original anonymous classes or SAM types in Java. Function values are objects with a single method and methods themselves are not first-class, but are wrapped in objects as required. The most important part of OO are the first-class modules; and in the literature, arguably more elegant examples of unifying first-class modules and FP exist, for example by starting with FP and adding objects as records containing functions, this way both "objects" and methods would be first-class. Subtyping also adds significant complexity to the language and weakens type inference.

Scala is, first and foremost an OO language which embraces subtyping, class hierarchies and imperative programming, see for example its own collections library. As Java gets more and more FP features, there is a danger it will struggle to differentiate itself.

comment 6y ago · link · parent

> You can do this in any language, functional or not.

No, not in practice. For example, in an average imperative language, you'd have no tail-call optimisation, and so would run out of stack space pretty quickly. There'd also be no persistent collections, meaning you'd have to keep copying any sets of values for every recursive call with absymal complexity. And so on...

comment 6y ago · link · parent

Well, I have noticed significant degradation of 128kbps MP3 sources when sent over Bluetooth, whereas my FLAC CD rips sound fine. I don't think that the effects of transcoding are well understood or well-studied, especially the interaction between different codecs.

comment 6y ago · link · parent

Actually that's probably a description of how JavaScript itself came into existence.

comment 6y ago · link · parent

> Transcoding doesn't make much of a difference either.

I respectfully disagree. Transcoding does make an audible difference, at the bitrates typically used, and should have no place in "high fidelity" audio. My issue with these Bluetooth codecs is that they are not used at the sources and so will always be used in practice for transcoding.

1
282930
69