Live data from Hacker News

What's worked in Computer Science: 1999 vs. 2015 (2015)

danluu.com

131–140 of 155 posts

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#131

Interesting how much has changed since 2015. Apple's M chips have made RISC is a clear yes now. Rust has a pretty fancy type system. Not Haskell-fancy but still. Functional programming is pretty much an expected feature now.

What can you do in Haskell that you can’t do in Rust with macros and elbow grease?

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#132

Earlier quoted context omitted.

Java records are object-oriented construct

OOP is about bundling state and behaviour into units that hide their internal mechanisms by some kind of interface. Records can have no state - compared to regular classes - so they are an anti-OOP feature.

I would say OOP revolves around the concept of modeling real-world entities or concepts as objects in code. Records encapsulate data fields within an object, providing a way to model real-world entities.

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#133

I'd say that " pure Functional programming" has become a no. But "Functional programming approach" has been subsumed into existing programming languages, e.g. records in Java. You get most of the benefit of FP while keeping all of the other good stuf from an imperative language.

> e.g. records in Java

Aren't these just C structs?

> You get most of the benefit of FP

FP = Functions. Same output for the same input. No capability to interfere with (or to be interfered with) other functions.

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#134
post #133

I'd say that " pure Functional programming" has become a no. But "Functional programming approach" has been subsumed into existing programming languages, e.g. records in Java. You get most of the benefit of FP while keeping all of the other good stuf from an imperative language.

> e.g. records in Java Aren't these just C structs? > You get most of the benefit of FP FP = Functions. Same output for the same input. No capability to interfere with (or to be interfered with) other functions.

> Aren't these just C structs?

Are C structs guaranteed to be immutable at compile-time?

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#135

Earlier quoted context omitted.

I haven’t used Java in many years, but TypeScript’s structural types give it a different flavor than I remember from Java. Unlike in Java, most of the types I define aren’t classes or interfaces. It’s just data that has an expected shape. Check out the design of Zod, for example. I have a bunch of Zod types for the validation of incoming JSON messages. This automatically generates the corresponding TypeScript types t…

In functional programming, a type is just a function that returns a list of possible values. It’s not a class.

Conceptually, you can think of a type as a set of values, but no, it’s not how static type-checking is implemented. Some sets are very large (consider the set of all JSON values) and enumerating them isn’t useful.

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#136

Earlier quoted context omitted.

I haven’t used Java in many years, but TypeScript’s structural types give it a different flavor than I remember from Java. Unlike in Java, most of the types I define aren’t classes or interfaces. It’s just data that has an expected shape. Check out the design of Zod, for example. I have a bunch of Zod types for the validation of incoming JSON messages. This automatically generates the corresponding TypeScript types t…

In functional programming, a type is just a function that returns a list of possible values. It’s not a class.

> In functional programming, a type is just a function that returns a list of possible values

Its literally not; there may be a language which does this or something close (actually, I’ve seen narrow, purpose-focussed relational languages where this is the case, and all types are enumerable), but it's definitely not generally the case in functional languages.

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#137

Earlier quoted context omitted.

> Functional programming means functions are first class citizens and can be constructed on the fly. FP is much more than this one language feature.

Yes, the field of FP is much more, but the core of FP is that. A language doesn't become non-FP simply because it has some imperative abilities, or logic programming builtin, etc.

I’m arguing it’s not FP when you take an OOP language and bolt on lambdas. Lambdas are necessary but not sufficient.

You need expression orientation, immutability by default, persistent collections in the standard library, some way to handle monadic code, etc…

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#138

Earlier quoted context omitted.

OOP is about bundling state and behaviour into units that hide their internal mechanisms by some kind of interface. Records can have no state - compared to regular classes - so they are an anti-OOP feature.

I would say OOP revolves around the concept of modeling real-world entities or concepts as objects in code. Records encapsulate data fields within an object, providing a way to model real-world entities.

Very few classes model a real world entity in my experience. Maybe that was the plan but it’s just not the reality of OOP in the industry.

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#139
post #17
post #9

> Fancy type systems We are taking steps to this direction. By adding optional typing to dynamic languages Python and JavaScript/TypeScript. And then type checker tools and local programming style guides are making using these maybe less optional, and more mandatory.

IMO the day python types become mandatory there will be a fork. It would be such a total betrayal of it's reason for existing that we would have to invent another untyped or duck-typed language again.

I find that even when type hints are made "mandatory" using Mypy's strict mode, having a dynamically typed language underneath that allows you to cheat using Any or cast() where necessary makes writing Python feel much less cumbersome than writing in actual statically typed languages.

Presumably, a Python with "mandatory" type hints would still allow you to cheat in those same ways.

Re: What's worked in Computer Science: 1999 vs. 2015 (2015)

#140
post #42

Earlier quoted context omitted.

For me the primary purpose of TypeScript is to give my editor information about interfaces so I don’t have to do the menial back and forth of accidentally making a typo in a function name, object param, etc. I find myself using less type hints in Python because the story for REPL driven development is so much better than JavaScript, and that takes most of the pain away.

Giving the editors hints in this case is very expensive.

It is, but it’s worth it in some situations.

It’s so much easier to sit down to an unfamiliar codebase, or to participate in a team of more than three or four serious contributors, when typescript is there to guide you.

I never would have guessed that that would be the benefit that won me over, but it absolutely has, all it took was a two year / six people project to completely sell me on typescript.

Post reply on HN