Better HN
topnewbestaskshowjobs
Log inSign up

grumpyprole

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

Submissions

comment 9y ago · link · parent

This is not the same thing as deferred type errors though. The programs are still type correct, it's just that some of the implementations are missing / producing errors.

comment 9y ago · link · parent

Yes I don't use deferred type errors much. But the parent poster wanted the option to avoid worrying about type correct programs.

comment 9y ago · link · parent

There's no reason why a statically typed language cannot also use an interpreter and avoid expensive optimisation and code generation upfront. For example, GHC Haskell has an interpreter, runHaskell, that will run a Haskell program straightaway with little delay (type checking is fast).

comment 9y ago · link · parent

Haskell can defer them by producing thunks (values) containing runtime exceptions. But unlike a dynamic-only language, you still get to know about the errors at compile time, by way of a set of warnings.

comment 9y ago · link · parent

There's no reason why static type errors can't be deferred until runtime, GHC Haskell can do this. Personally I find types invaluable when prototyping. I often fill in the implementations after I work out the types.

comment 9y ago · link · parent

Depends on what you mean by concurrency support. OCaml has nice green threads via Lwt.

comment 9y ago · link · parent

> There are still tons of things to improve in CPUs: power consumption, cost, embedded functionalities (SoC)

Don't forget bugs! We have had buggy silicon, microcode and drivers, all of which probably still need fixing.

comment 9y ago · link · parent

It is much harder to do functional programming in an OOP language, as one is often fighting the syntax, semantics and various defaults. For example all variables are typically by default mutable, null in every type, libraries and frameworks with pervasive mutable state etc.

Granted it has been getting easier as OOP languages have been slowly getting more and more functional features. But it really is easier to favour immutability and composition in a functional-first language.

comment 9y ago · link · parent

The reference type in ML/OCaml is an opt-in feature, a container with it's own special type. In Haskell, you can also capture IORefs or similar, but any reads/writes to them are effectful and captured in the types. The point is that Python does this all the time as the default. Any captured variable could potentially change under your feet. It is rarely useful and most beginners do not expect it, hence it is commonly considered a "gotcha".

comment 9y ago · link · parent

The ML/OCaml reference type is an opt-in feature with its own type and explicit syntax, it is not the default used pervasively everywhere. That's the key difference that makes ML programs easier to reason about.

comment 9y ago · link · parent

Unfortunately OOP languages typically lack sum types, the mathematical dual of product types (objects with just fields). This means subtyping and inheritance is often needed to encode sum types.

comment 9y ago · link · parent

No they are not exactly the same.

From the link you posted: "all uses of the name within the block are treated as references to the current block"

The Python folks call them "late binding closures" and they are frequently discussed as "gotchas".

Essentially lexically scoped variables are captured as references to mutable state. Java did not make this mistake, perhaps because they had Guy Steele (of Scheme fame) on the committee. It is a questionable default that ultimately just destroys ones ability to reason about programs.

comment 9y ago · link · parent

Those are good points, but really not an argument against FP. String could have originally been an abstract data type in Haskell. There are of course disadvantages to the Java string approach, in that there is potentially a lot of code duplication inside the String class. There will also always be some situations that will require you to unpack the string into an array of chars, because a particular method does not exist.

There are plenty of things that Java got wrong. Threads and concurrent programming in Java is particularly difficult to get right without expert knowledge. Haskell makes concurrent programming much easier. I've worked with both professionally and feel that Haskell got more things right.

comment 9y ago · link · parent

There is no language definition or implementation called "LISP". Both Scheme and OCaml lexically capture variables by value, as if they have been passed in as arguments. This is not how it works in e.g. Python.

comment 9y ago · link · parent

> That's kind of the definition of encapsulation.

State encapsulation, at least in FP, means that the state is not visible externally. For example a pure function that uses mutable state in its implementation. Such state does not contribute to the sytem global state.

> This is repeated as a mantra without any backup.

The more global mutable state your application has, the harder it is to reason about. That should be fairly obvious I think.

comment 9y ago · link · parent

Functional programming languages do not capture mutable state in closures.

comment 9y ago · link · parent

Passing a common struct into one or more procedures is absolutely not what is commonly understood as object-oriented programming. This is what people did (and are still doing) long before OOP existed. I also do it all the time in Haskell.

Similarly that article is wrong to imply that all these techniques are unique to OOP.

comment 9y ago · link · parent

The fundamental feature that makes such an example easy is first-class functions. You are simply using objects to encode this and not making any use of their identify and mutable state.

comment 9y ago · link · parent

In what way is the Linux kernel or my router firmware object-oriented?

Linus Torvalds has even gone on record to express his distaste for C++ and OOP.

comment 9y ago · link · parent

Any global state is potentially visible externally in terms of the behaviour of your system. Yes pure functions can be complex, but their behaviour is entirely reproducible and testable. For state not to be visible externally, i.e. true state encapsulation, then you need components that appear stateless externally, which is not how most people do OOP.

comment 9y ago · link · parent

I've now expanded on that statement. In my experience, working using OOP in large multi-million line codebases, the state issues have proven very true.

comment 9y ago · link · parent

Every object in OOP is potentially stateful, some are made stateless and immutable but most are not, you need to read the docs. If I build a composite object Z from objects X and Y, the set of possible states Z has is a product of the set of possible states X and Y have. No complicated theory, just basic mathematics. I spent many years building OOP systems before moving on to FP. I strongly disagree with the claim that it is easy to manage state in OOP!

comment 9y ago · link · parent

OOP does not offer true state encapsulation, it just hides it. Objects are always potentially stateful when reasoned about externally. This means that all objects in your system could potentially contribute to the global state space, resulting in a combinatorial explosion of state. This makes programs difficult to reason about and is not a good general approach.

In contrast, functional programming makes state explicit. This makes it easier to manage and control state.

comment 9y ago · link · parent

Agree that Java and C++ are poor examples. However, OOP fundamentally results in a combinatorial explosion of state, which makes programs difficult to reason about. This can be useful in some niche applications but does not make a good general approach. The best part of OOP is arguably its support for first-class modules, but this feature could in theory be added to a functional language.

EDIT: the reason why there is an explosion of state is because every object in OOP is potentially stateful. If I build a composite object Z from objects X and Y, the set of possible states Z has is a product of the set of possible states X and Y have.

comment 9y ago · link · parent

The inventor of the start menu and taskbar disagrees with you:

https://www.windowscentral.com/creator-first-start-menu-thin...

comment 9y ago · link · parent

OS/2 did not have the Start menu. Here is Microsoft's "TaskBar with Start Menu" patent: http://www.google.co.uk/patents/US5920316

comment 9y ago · link · parent

If you mean "normal" as similar to Windows 95, then there was a very good reason to experiment with alternatives: the US patent system.

comment 9y ago · link · parent

Sure 'evil' is hyperbole, but he gives many examples in the posted video of control, security and privacy issues. Essentially with proprietary software, there is a fundamental conflict of interest between the proprietor and user.

comment 9y ago · link · parent

It might be personal taste, but I'd prefer a language incorporating innovations from the 1980's onwards. I doubt that will be fixed in the next release.

comment 9y ago · link · parent

How about Algo-68?
1
525354
69