News for hackers. Stuff that matters.

l_dopa

Re:WASM_of_OCaml on Monday July 24, 2023 @02:18PM (#36852167)
I always assumed this convention was just using "of" in the same sense as function composition. From wikipedia:

> The notation g ∘ f is read as "g of f "...

Re:Design Principles Behind Smalltalk (1981) on Sunday June 14, 2020 @12:59PM (#23519285)
> Classes as concept, are nothing more than extensible modules

If you're talking about ML-style modules, that really can't be farther from the truth, both in theory and how they're used in practice.

Modules can be used (among many other things) to implement abstract data types, which are conceptually a bit easier to compare to objects[0]. Then you'd have to go into structural vs nominal typing, functors vs generics, etc.

[0]https://www.cs.utexas.edu/users/wcook/papers/OOPvsADT/CookOO...

Re:Why OO Sucks by Joe Armstrong (2000) on Sunday April 21, 2019 @09:02PM (#19715600)
That's not entirely accurate. Abstract data types (e.g. ML modules) can also be modeled as existential types and don't have the same problems.

I think it's the particular combination of only having nominal typing, only allowing the oo-flavor of data abstraction, and encouraging programming with state and using inheritance for code reuse that leads to the object-spaghetti nonsense in heavily-oo Java/C++ codebases.

Re:A Crash Course on ML Modules (2015) on Sunday February 25, 2018 @05:55PM (#16461701)
One big difference is that java interfaces can't contain member types. They describe the methods of one particular type. Imagine you could define an interface for an entire java package.

Another big one is that module types are structural: you don't have to declare all the module types implemented by a module when you define the module.

Re:A Crash Course on ML Modules (2015) on Sunday February 25, 2018 @03:51PM (#16461091)
Type checking, type abstraction. If you're willing to throw those out, you can "get the same thing" with structs and void pointers.
Re:Sum Types Are Coming (2015) on Friday February 16, 2018 @03:59AM (#16390941)
Actually, they're the "other side" of products types, which are sometimes called "records" or "structs". Maybe they're occasionally used to solve the same problem, but inheritance is unrelated. Inheritance is a variety of ad-hoc methods for sharing code with quite different semantics in every language where it's implemented.
Re:Opinions on functional programming and OCaml on Saturday December 23, 2017 @01:36PM (#15995509)
This is exactly what higher-order functions do, without the ad-hoc OO junk that's slightly different in every language.
Re:Advantages of Functional Programming in Java 8 on Tuesday September 06, 2016 @01:09PM (#12437494)
> I haven't claimed that equational reasoning is limited to pure languages

Sorry, I may have read that into your comment.

> the code itself needs to be pure

But that's also incorrect. Just because you can't replace an effectful computation with a value doesn't mean you can't reason equationally. You can also have benign effects that are unobservable, for example, memoization.

> Not sure how to parse that

I meant that functions with effects are just functions with computation type at the meta level. I.e. there's nothing more "mathematical" about only allowing nontermination in your language. It's just the simplest case.

Re:Advantages of Functional Programming in Java 8 on Tuesday September 06, 2016 @09:50AM (#12435960)
This is a really annoying meme in "pop" FP. Equational reasoning isn't limited to "pure" languages. Effectful functions, as you probably are aware, are just functions of type A -> T B.
Re:On Two Views of Computation in Computer Science on Friday September 02, 2016 @10:15AM (#12413169)
You're positing some new notion of complexity, without a definition, where lists are somehow fundamentally different than trees. Sorry, but that kind of claim requires more than just just an appeal to intuitions about how they might be implemented on a typical CPU. They're both just initial algebras.

The fact that your grand ideas about machine and language models doesn't apply to the lambda calculus should be a hint. We know how lambda calculus relates to typed languages: it's a degenerate case with a single type. Any differences in the complexity of type-inference or checking are between language models. You can't (without wildly waving your hands) formulate a meaningfully comparable problem for TM states.

Re:On Two Views of Computation in Computer Science on Wednesday August 31, 2016 @08:21PM (#12402425)
Why is the complexity of parsing well-formed states from strings somehow interesting? If you generalize to trees and pick the right alphabet, suddenly every element of your datatype is a well-formed lambda term.

It's also unclear if you're talking about the complexity of type inference or type checking, what annotations you're allowing, etc. Your claims about complexity re: states of typed languages are too hand-wavy to engage with.

And yet there's still a glaring error: for a very popular machine model, namely the C abstract machine, it's undecidable whether a state is meaningful (regardless of how you set up your parsing problem).

So, you have an interesting idea about the difference between machine models and languages but it clearly doesn't hold together. People have been studying the relationship between machine models and languages for quite some time, and it's relatively well understood. Machine models are one of the many ways to give semantics to languages. They just don't have many useful properties compared to more "abstract" approaches, and are mostly used to reason about implementation.

Re:Goodbye, Object Oriented Programming on Tuesday July 26, 2016 @10:41AM (#12165911)

  Languages are not so much a collection of features ...
If you want to define objects precisely, even just to have a language spec, they are absolutely made up of sums, products, recursive types, etc. Whatever useful metaphors one might have to work with objects doesn't change what they actually are. If you give the programmer access to these building blocks, you get ML.

  Calling them just domain specific ...
I meant that the particular way they're combined to get OOP is domain-specific.

Again, I'm just asking: why mess with the basics? Why require encoding simple, universal concepts in terms of an ad-hoc object system? You can still have an object system on top, if you find that helps with the really complicated cases, but why encode the parts of your code that are simple in terms of much more complicated, derived concepts?

Re:Goodbye, Object Oriented Programming on Monday July 25, 2016 @11:07AM (#12159167)
It sounds like we agree that lexically scoped immutable values are easier to understand, either precisely or with fuzzy metaphors. I'm not sure what "ideal" FP is or how it might have a certain "mathematical view of the world". The features I mentioned are just a subset of semantics that every high-level language programmer already knows, but are pointlessly hobbled in popular languages.

Why should expressing something basic like a tagged union require a detour through the quirks of a particular object system? Ditto for polymorphism, modularity, etc, etc. Clearly we disagree on how useful objects really are in practice, fine. Why not add these domain-specific features on top of a core language with simple semantics? It worked fine for lisps. Luckily, after a couple of decades of "everything is an object!" nonsense, that seems to be where newer languages (Rust, Swift) are headed.

Re:Goodbye, Object Oriented Programming on Sunday July 24, 2016 @10:23PM (#12156087)
You're still, at some point, simulating the steps of some abstract machine in your head to understand what the debugger is telling you.

The simplest case is replacing an expression with its value, given an environment of lexical bindings that are apprent from the source program. Not much investigation necessary. That's FP.

For OO code, you just need to keep track of a lot more context: the state of the receiver of the currently executing method, its heirarchy of parent classes, the runtime class of each object because late binding is pervasive. Of course you can write code that doesn't use any OO features, but the languages clearly aren't designed for it. See: any number of "functional C++" articles.

And, of course, you can get the same kind of highly dynamic behavior in FP languages by explicitly using open recursion, higher-order state and hiding everything behind existentials. But very few codebases do that because the vast, vast majority of the time just one of these features is enough to solve a problem.

Re:Goodbye, Object Oriented Programming on Sunday July 24, 2016 @06:29PM (#12155215)
"Pure" functional programming isn't the only alternative. There's plenty of benefit from just using a language with reasonable semantics (e.g. ML) that doesn't force you to contort simple programs into bizarre "OO" patterns.

Whether or not you want your language to enforce segregating (most) effects is a separate issue, about which reasonable people can disagree.

The problem's not on your end -- a lot of these blogs are just junk, probably the vast majority of ones that fall under "advocacy". As far as I can tell, the author's objection to conditionals is based on a misunderstanding of a different blog post[0]. It's nonsense.

Really understanding where FP is coming from requires an introduction to programming language semantics[1]. Interesting stuff, but not immediately useful to a working C programmer.

[0] https://existentialtype.wordpress.com/2011/03/15/boolean-bli...

[1] http://www.cs.cmu.edu/~rwh/pfpl.html

> The only plausible way to fix a bug in an ANN is to incorporate said bug in the training set

My point was not something about manipulating weights directly vs. augmenting the training set. The analogy is roughly, find a misclassification : add particular input to training set :: find a bug : add a patch/test case. I'm playing devil's advocate, of course, and there are obvious, important differences.

> The difference is that all human written systems was once understood by a human

But that's not one of them! In practice, we create software systems by getting some rough intuition about an interface, wiring together some components, then checking the results empirically. Basic components that everything else is built on, C compilers for instance, are based on ambiguous, even contradictory specifications.

Is knowing, for example, that there's a race triggered by a new optimization in compiler version X that happens under conditions Y and Z really a qualitatively different type of understanding than "the weights are such that the ANN computed this incorrect output for these inputs?"

In both cases we can only fix a particular instance of an error and effectively have no way to show that similar errors don't exist, or even that we didn't introduce new bugs with the fix.

Re:Moving Beyond the OOP Obsession on Monday March 28, 2016 @08:42AM (#11373891)
Assuming you're in some client code that shouldn't rely on the implementation of m, it's an https://en.wikipedia.org/wiki/Abstract_data_type
Re:Moving Beyond the OOP Obsession on Monday March 28, 2016 @07:48AM (#11373701)
You're describing subtyping which, like modularity, does not require inheritance or really any other part of "OOP".

I think that supports the article's point that C++, Java, etc. only support certain language features in an ad-hoc way tied to their object systems, making them, among other things, poor teaching languages.

Re:Swiftc – SIL and its not-so-basic blocks on Monday November 02, 2015 @05:57PM (#10495992)
People recognized ~20 years ago that, semantically, SSA is just reinventing lexical scope:

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.3...

That's a very strange interpretation of Rice's theorem. Just because properties of computable functions are undecidable doesn't mean they somehow "can't be described by mathematics". I'm also not sure why incompleteness is relevant here at all, unless you think describing something mathematically requires a complete formal system. In that case, we can't "describe" arithmetic "mathematically".
Re:OCamlers' critiques of Haskell on Thursday August 27, 2015 @01:40PM (#10130850)
It was me[1] and I'm afraid you are still mistaken on a number of points:

> The truth is that Haskell -- like all programming language -- has made a design choice, which was to bake in correctness proofs based on the Curry-Howard correspondence into the language

Haskell is not a logic and is not used to write proofs for program verification. General-purpose functional languages don't have all that much to do with CH, and they don't include any design decisions that favors a particular approach to verification. The type system helps you enforce useful invariants in your code and can make verification easier, but it's completely orthogonal to how you can prove programs correct.

> I think C-H has so far disappointed, because 1., people don't seem to want it, and 2. because other verification systems (like KeY) or the verifiable imperative, reactive real-time languages of the eighties (like Esterel) whose descendants are still in use today, have so far been used to much better effect.

Theorem provers based on C-H are general-purpose logics that can be used for a lot more than just program verification. So, different tools for a different purpose. Having said that, they have proven to be very useful for verification of complex systems like those you listed, where existing tools have trouble even stating what correctness means. That is, they can help us answer the question "how can we be certain that this compiler, verification system, etc. is correct?" That typically includes representing your object language in your theorem prover and proving things about the language, which is quite different than showing that an algorithm meets some specification.

> But the notion of subset => simpler is a mathematical notion with no relevance to cognition. If humans operated in this way, natural languages would have been much more mathematically simpler, too.

You can show that, quite literally, any "true property" of a program in your more complicated language is also true of the corresponding program in your simpler language. So, if you come to some correct conclusion, even if the way you reason is completely bogus and just happens to work, it will be valid for your simpler language.

There's no need to solve the much, much harder (and poorly specified) problem of "what is easiest for humans". That's not to say that the current crop of functional languages is presented in the easiest way for people to understand, but that's an entirely different problem independent of semantic considerations.

[1] https://www.reddit.com/r/programming/comments/3i1l9n/from_im...

This is exactly why a lot of formal methods work isn't, imho, terribly compelling.

Something like http://vst.cs.princeton.edu/ has a much, much stronger case for enabling "100% correct software".

Re:Why functional programming matters (1990) [pdf] on Monday May 11, 2015 @11:01AM (#9525247)
Yes, we're talking about different things. I took the parent comment to mean that talking narrowly about "FP" as programming with pure functions isn't very useful any more. It may have made sense in the 90s when few widely-used languages had h.o.f, but that fight has pretty much been won.

The field that gave rise to FP has a lot to say about how we specify languages and their properties and how we prove things about programs in general. That includes languages with all kinds of effects: state, exceptions, concurrency, etc, and equally as imporant, mechanisms for abstraction and modularity. There's currently no other "foundation" for computation that lets us define these ideas formally.

In discussions of FP, the contributions of the field get reduced to "programming with functions".

Re:Why functional programming matters (1990) [pdf] on Thursday May 07, 2015 @04:16PM (#9507952)
Sorry for the glib answer. I'm not arguing for programming in the pure, untyped lambda calculus.

My point was that it's possible to systematically extend (or restrict) the lambda calculus and associated techniques. You can add effectful operations and give them semantics (e.g. as functions on stores), define a cost semantics and prove whatever you want while being completely formal.

Try extending RAMs with dynamic allocation, call stacks, or anything to make it more natural to write down a whole algorithm. Try proving something about the composition of RAM programs. I don't think you'll get very far.

Re:Why functional programming matters (1990) [pdf] on Thursday May 07, 2015 @10:02AM (#9505081)
> I'd like the "foundation" of CS to give a faithful mathematical description of what computers can and cannot do. Is that too much to ask?

http://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis

> A better "foundation" would try to describe computational behavior and reason about it, instead of abstracting it away

A lot of interesting research does exactly this, and a lot of it has found its way into ML-family languages. The starting point (or "foundation") in every case is a typed lambda calculus. Machine models, like turing machines, are just annoying to reason about and not extensible in any meaningful way.

Re:Why functional programming matters (1990) [pdf] on Wednesday May 06, 2015 @11:10PM (#9503098)
This is a really important point that I'm not sure I've seen before in a discussion about the adoption of FP. You're completely right, but I can't imagine FP language advocates would get very far by leading with the history of type theory.
Ah, thought you were talking about some technical limitation. That's a shame, one would think an alternative to LLVM that is not so C-specific would find more use.
It's hard to keep adding new instructions to MLRISC!

Could you expand on this? Based on the problem statement page, this seems to be the exact problem MLRISC tried to address. Is there something that keeps it from working well in practice?

Older »