DEV Community


Discussion on: You don't need classes

jcubic profile image
Jakub T. Jankiewicz • Edited

Yes you also don't need named functions and numbers, you can write everything with just anonymous functions (like lambda calculus). Check this article: Programming with Nothing, here is the code in JavaScript.

The reason why the code is simple is not because you use less of language features, but because you use features that are known by other person that read the code that also know that language.

This is not good way to go, your code will be less and less understandable by other programmers, but I will probably never convince you.

Thread Thread
lukeshiru profile image
△ LUKE知る Author

But you the idea with a good discussion is not to convince the other person, is to share knowledge so both parts end up more knowledgeable. If you provide information based on logic, and that logic is good enough, my point of view could shift in your direction.

You now added that "that is not good because is harder for other programmers", and I agree... but if you really think about it, is hard because they need to "unlearn" stuff that was taught to them as indispensable, and if they use less features of the language to achieve the same thing, they are basically using just english to express themselves.

You also mentioned "lambda calculus" and not needing named functions, and I don't agree with that. You need to have good names for your functions, constants and attributes, because you're using those to express the intent of your code, and without them then the code is unreadable. Haskell is a classic FP language, and I despise how they have super short names for functions, and 1 letter names for attributes. Is like they really don't want people to understand:

foldr :: (a -> b -> b) -> b -> [a] -> b
Enter fullscreen mode Exit fullscreen mode


type reduceRight = <Item, Output = readonly Item[]>(
    reducer: Reducer<Item, Output>
) => (initialValue: Output) => (array: readonly Item[]) => Output;
Enter fullscreen mode Exit fullscreen mode

A Haskell fanboy would be like: "but .... but ... you wrote more there!" ... and that's true, but I did that once, and then when I use that function I have great documentation in the IDE itself while using it, instead of getting a, b, and so on.

TL;DR: The idea with this posts and the ones that will follow is not to suggest we should move from a programmer model to a mathematical one as Haskell folks would suggest, but to move from a programmer exclusive model, to one that is closer to plain english (easier to learn, easier to teach and easier to think about).

Some comments have been hidden by the post's author - find out more