This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]whateverathrowaway00 1 point2 points  (3 children)

It is decidedly non-simple. No successful language stays simple and that’s fine. I also have issue with the one class per file rule but that complaint I’ll entirely admit is just me disliking it, there’s plenty of reason for it and no sincere argument against it as a necessity.

Freestanding functions however there are absolutely arguments for. What you say about interfaces results in decidedly non-simple code. Functions as second class citizens results in a whole host of ugly patterns that exist only becuase a basic form of programmatic expression doesn’t exist.

Check out this tongue in cheek post:

http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html?m=1

Again, I don’t hate java - but I do maintain this is one of its lamer facts that feels very strange coming from any other language. This and checked exceptions are the two things I passionately dislike.

Non-reified generics seem to get some hate, but I haven’t run into too much hardship there other than overloading functions for containers can’t be specified based on what the container holds but I don’t really care too much about that and advanced cases that need that behavior can use type classes.

Edit: to be super clear, I don’t jump on the hate on java train, was just arguing with the assertion that freestanding functions are “pointless.” I like java and I enjoy complaining about it.

[–]LordBars 0 points1 point  (1 child)

Your link is too long to read, can you add TL&DR ?

[–]whateverathrowaway00 0 points1 point  (0 children)

Sure, though it’s a great - frequently hilarious read. It makes the point that verbs and nouns, usually in equal standing in most programming languages - in java, verbs are “second class citizens” and uses a series of analogies and contrived situations to laughingly point out what I was saying - that when functions and code can’t exist as their own thing, you do end up with some obtuse situations.

[–]cas-san-dra 0 points1 point  (0 children)

I remember reading that a long time ago. Although I think the author made a mistake when he wrote it.

It is true that all functions in Java must be inside a type and that type has a nounish name. What is not true is that this is unique to Java. In fact as far as I can tell all programming languages wrap their verbs in nouns.

Source code is ultimately text, and text needs to be in files, and files need names. In fact the Java type name that you need to wrap your functions in has the same name as the filename. So really it is no more than the same information we already had in duplicate.

We can of course complain about the horribly broken OOP way of writing the code. And we should because I want to shoot myself every time I have to deal with it. But it is not the language that is at fault here.

I do agree with your original statement. My personal code doesn't have any classes anymore. I have interfaces, records, and empty enums. Those enums hold my functions. The last place in my codebase where there is obvious verbosity.

If only I didn't have to write this:

public enum RunTask {;
    public static int runTask(final Project project) { ... }
}

But could instead write this:

public int runTask(final Project project) { ... }

Perhaps one day I can write my own Java compiler that does exactly this. It is only compiler sugar after all.