Better HN
topnewbestaskshowjobs
Log inSign up

grumpyprole

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

Submissions

comment 8y ago · link · parent

The problem with the word "generics" is that it already meant something else in programming language theory. If I used reflection to implement a serialisation function in Java or C#, it could be generic with respect to the data-type of the value passed in, but not parametric. A parametric polymorphic function strictly has the same behaviour for all types, a generic one has type-dependent behaviour. This matters of course when we want to reason about programs.

comment 8y ago · link · parent

ML first appeared in 1973. Pretty impressive considering the laundry list of features, many of which are missing from mainstream industrial languages. For example: parametric polymorphism (aka "generics"), pattern-matching and type inference.

comment 8y ago · link · parent

In Haskell it certainly is a closed definition, you would get a "multiple declarations" syntax error if you tried to split the definition up. I would assume the same for Clean also.

In the Haskell REPL, you would need to enter the definitions together.

comment 8y ago · link · parent

The style is lifted straight from mathematics tradition. It is a closed definition and so it would be syntax error to insert anything between the lines.

In Haskell you could always avoid that style and use the case syntax (or for this example guard syntax) instead. All varieties eventually desugar to a case analysis anyway. Haskell even added curly braces as an alternate to indentation!

comment 8y ago · link · parent

Python is extremely permissive and flexible, even for a dynamic language - a trait that makes it easy to learn and easy to throw something together quickly. But when building software at scale, we need restrictions. For example: static types, immutability, pure functions, total functions, algebraic laws. It is restrictions such as these that give us the power to reason about code and the ability to compose it at scale. Beginner's do not understand how one can gain power from restriction. Skilled programmers do and most would not recommend Python for large-scale general purpose programming.

comment 8y ago · link · parent

And it appears to be a recruiter goldmine, the staff turnover is significantly high (so I am told). A codebase of this size with no static type checking is not going to be fun.

comment 8y ago · link · parent

In order for the Q interpreter to fit in that small size, the language has some rather severe limits. For example, function parameters, local variables and conditional branch sizes. Forcing users to structure code around these limits feels a bit archaic to me. This is what compilers are for.

comment 8y ago · link · parent

Sure they tried to make it work. But it did create a static typing and OOP backlash. IMHO, too many of us succumbed to the marketing. Many would have been better off using OCaml or Python, both of which were released about the same time (and OCaml has always shipped with "generics"!).

comment 8y ago · link · parent

I didn't bring the term up, but I personally understand it to mean complex domain-specific code. Some examples from my own workplace: pricing/risk of derivatives transactions, financial contract definition, portfolio optimisation, interpreters/compilers for various complex data transformations.

comment 8y ago · link · parent

This boils down to how much one values static types and code reuse. If you do not have Generics (a.k.a. parametric polymorphism) then you are forced to make a choice between type safety and code reuse. You cannot have them both.

comment 8y ago · link · parent

The "wait and see" approach as you call it, means that "Generics" (a.k.a. parametric polymorphism) have had to be retro-fitted to languages like Java. This means they are more complex than they need to be and have some ugly edge cases.

comment 8y ago · link · parent

C# was originally trying to copy Java, a language that took influence from C (weak types retrofitted) and Smalltalk (no static types at all). Industry has since learned a lot about the tremendous value that types bring. Other forms of static analysis are now gaining popularity too.

comment 8y ago · link · parent

> I don't see how generics are needed to deal with "complex business logic".

Complex business logic really has no place in Go. I would advise people to use more expressive languages (ideally with a modern type system). Go was designed for low-level network systems programming and is not well suited to more high-level problems, despite what the hype train might claim. I see the future as a polyglot one. Folks should use the most appropriate language for whatever domain they are currently working in and not let their careers be defined by any one language or technology.

comment 8y ago · link · parent

Maybe Jobs was hoping to sell us an Apple III with 3 expansion slots the following year.

comment 9y ago · link · parent

There is plenty of GHC Haskell in the codebase. It's very common for banks to have proprietary in-house scripting languages. Mu, is at least based on a language standard and is not some ad-hoc design. The codebases of Facebook and Google would be no less "ancient legacy enterprise monolith".

comment 9y ago · link · parent

IMHO, sad is when you have large numbers of people hacking on a multi-million line codebase in Python with no static types, unfortunately a far more common situation in finance!

comment 9y ago · link · parent

Like Ruby and Erlang, Haskell is used a lot for building server-side applications. It's runtime offers N*M threading and software transactional memory, which make it an attractive choice to many. It's webserver, Warp, performance-wise is competitive with Nginx.

comment 9y ago · link · parent

Haskell is definately one to watch for Blockchain. IOHK have released a currency with their codebase largely in Haskell. Both IOHK and Digital Asset have smart contract / modelling languages based on Haskell.

comment 9y ago · link · parent

Your list should include Standard Chartered and Barclays. Standard Chartered probably has the largest commercial Haskell codebase in the world, it has over 30 full-time Haskell developers and many more users.

comment 9y ago · link · parent

The runtime could allocate "stack frames" on the heap, for such cases.

comment 9y ago · link · parent

You can turn it off, you just can't process large data sets, as you'd run out of stack space. But who wants to debug with large data sets?

comment 9y ago · link · parent

The dark theme looks much better than Chrome.

comment 9y ago · link · parent

It's an optimisation. It can be turned off when debugging with stack traces. If you need stack traces in production code, you have too many partial functions.

comment 9y ago · link · parent

It's even more fundamental than that. The world is built on C and C++, both of which were designed a long time ago and without safety and security in mind.

comment 9y ago · link · parent

Not surprisingly, most information on this is outside apple.com:

http://www.theguardian.com/news/2017/nov/06/apple-secretly-m...

comment 9y ago · link · parent

> They pay tax where they earn it.

No they don't. They employ offshore tax havens, shell companies and exploit various loop holes in order to avoid doing so. It's lawful yes. But it's immoral and unfair to smaller businesses who do pay their share. Buying an iPhone in Europe means less money for infrastructure, schools, hospitals and universities. The iPhone itself piggybacks on decades of tax funded research and development, yet Apple do not contribute back.

Apple are of course one of many corporations that employ these practices, but they are the largest and often market themselves as being ethical.

comment 9y ago · link · parent

The corollary to that is that these "exotic languages" are often such an improvement over the mainstream offerings, that such inconveniences have not prevented adoption in many cases.

comment 9y ago · link · parent

> Scala needs to interoperate with other Java languages

But does it? Can I even use e.g. a Scala collection from Java? (let alone Clojure, Kotlin, etc) Certainly it looks easy to import and use Java objects, but that looks to be the extent of it.

> it couldn't be statically known at compile time in the case where a library written in Scala is being called by code that was written at a later date

When you build some new code that uses an existing library, any parametric polymorphic type variables get instantiated at the use sites. Where I admit this isn't true, is the adhoc polymorphic dynamic dispatch via subtyping, but this wasn't given to me as an example. I don't see that ArrayLists and ADTs should present a problem.

> types still cannot be statically known in cases where you're being handed objects whose type is not determined until run time

Again, I think you are referring to dynamic dispatch here? I agree this could be a problem in open class hierarchies. But the ADT encoding in Scala is a closed statically-known hierarchy, so I can't see why it has to cause problems. Truly "generic" or parametric polymorphic code should not depend on type tags or even be allowed to introspect the runtime type, doing so violates parametricity, which ultimately reduces our ability to reason about the code.

comment 9y ago · link · parent

If it creates a specialised concrete array at runtime, then it can't be a truly "generic" method (whereby I assume generic here means parametric polymorphism?). If you want to specialise object arrays to primitive arrays for efficiency, then I do not see why this cannot be a compiler optimization, since the types are statically known at the use sites.

Perhaps Java interoperability is the reason for the choices Scala made, but it doesn't appear that e.g. Scala collections can be used from Java?

comment 9y ago · link · parent

I do not see why this problem cannot be solved by a compiler rather than a language feature. The type is statically known. It may require additional metadata alongside class files for separate compilation, but I don't see this as a big issue.
1
495051
69