HN user

Peaker

3,101 karma
Posts0
Comments1,514
View on HN
No posts found.

Then what you have is not "anything". You have an expression problem:

Either each element has some "handler" that does the right thing for that data type.

Or you have a set of cases that each data can be, and you handle them all.

Neither is just "any type". And static types are very suitable to describe either.

Everything is of course possible, but at what cost?

In my experience, with large projects, you get to pick 2:

Dynamic typing Development velocity Reliability

I've seen multiple large projects grind to a near halt in their development speed, and I've seen some retain development speed, but unreliably crash after various changes.

UT coverage is expensive. System tests don't catch everything. Either you fear changes, and the system rots, or you work very slowly with coverage for everything.

Rust is a great systems language.

When I write applications, I don't need a systems language, and Haskell is easier to use.

Also, Rust is a great imperative language, it's not as great as a functional language, and you can't reap the benefits of pure functional programming.

I suspect the problem is mentoring. It took me months to get basic Haskell.

The people I mentored, though, could clarify any misunderstanding and get explanations from multiple viewpoints from me -- after years of experience with these abstractions. With such mentoring, you don't have to go through all the confusion phases.

Haskell record syntax with lenses is workable:

  import Control.Lens

  data MyRecord = MyRecord { _a :: Int, _b :: MyRecord }
  makeLenses ''MyRecord
Then you can use it nested like:
  over (b . b . a) (+5) myRecord

I've mentored programmers in Haskell and they were also productive within a few weeks.

I'm pretty sure I could get a student to write useful Haskell code in that time span with just mentoring and existing documentation material.

That's the Maybe type. The Maybe monad is this:

  instance Monad Maybe where
    return = Just
    Nothing >>= _ = Nothing
    Just x >>= f = f x
(And is not really related to the discussion)

Destroying a language's safety for a single use case is a terrible trade-off.

There are various possible solutions for circular structures that do not require destroying all static safety with nulls everywhere.

The joy of max() 8 years ago

Of course that's true. But Lisp is shitty at controlling memory use, indirections, and manual MM.

The joy of max() 8 years ago

They're not really "inheritance". They can do what inheritance can do, and much much more.

The joy of max() 8 years ago

I agree about constexpr, templates and exceptions.

But C function pointers are not really emulating virtual functions. They're better and more powerful than virtual functions.

Why do they reduce the amount of code?

They add the ability for constructors to carry constraints, which aids expressivity in some cases.

But the majority of GADT uses purely add safety. Can use ordinary ADT without a type-variable that is correlated with the data constructor, and crash at runtime if the constructors don't match.

But you can do this without S-expressions.

DLang, for example, has free-form macros that they weirdly call "mixin" (as in, mixing in some text or declarations into the AST, syntax-wise).

Each mixin must be a valid AST subtree on its own, which gives the same guarantee that paren matching prior to macro expansion gives you.

Then, the compiler can interleave:

     parsing

  -> evaluating mixin strings
  -> resuming parsing of the mixin subtrees
  -> evaluating the deeper mixin strings
  -> ...
You get the power of Lisp macros, but without the Lisp syntax that is unattractive to many.