You're looking at Less Wrong's discussion board. This includes all posts, including those that haven't been promoted to the front page yet. For more information, see About Less Wrong.

Luke_A_Somers comments on Learning programming: so I've learned the basics of Python, what next? - Less Wrong Discussion

8 Post author: ChrisHallquist 17 June 2013 11:31PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (67)

You are viewing a single comment's thread. Show more comments above.

Comment author: Luke_A_Somers 18 June 2013 09:50:42PM *  0 points [-]

What I'm talking about here would still compile to Java bytecode. It would just be some syntactic sugar to easily wrap static functions in anonymous classes.

Comment author: Baughn 19 June 2013 09:37:09AM 0 points [-]

Sure, that's what I was talking about.

Though Java syntax really isn't that great, and if you're changing it at all, there's a lot more low-hanging fruit than just functions.

Comment author: Luke_A_Somers 20 June 2013 06:50:56PM 0 points [-]

The only thing that really bugs me is the inability to use variables declared in a try block in an ensuing catch or finally block. That would let you scope things much better.

What are you thinking of?

Comment author: Baughn 21 June 2013 12:27:21AM *  0 points [-]

Lack of multi-parameter polymorphism, lack of return-type polymorphism, lack of algebraic data types, lack of parametric polymorphism, etc.

Okay, essentially I want Java to be Haskell. That's an impossibility, but most of the type-level stuff needs no runtime support whatsoever.

Comment author: Luke_A_Somers 21 June 2013 01:28:08PM *  0 points [-]

You can do polymorphism with generic types, and that's been around for a while.

Like,

List<Thing> listOfThings = new ArrayList<Thing>(); listOfThings.add(new Thing()); Thing t = listOfThings.get(0);

Is this not what you're talking about? Generics need no runtime support, but they do enable a lot of compile-time checks.

Generics certainly don't do parametric polymorphism or algebraic data types. Of course anyone can write a Pair<T, U> or Triple<T, U, V> class with trivial get and set methods, but that looks (and acts) silly.

Ooh, another thing I'd love is to have there be a Bracketable interface that lets you use brackets to call the class's get and set methods. Then you could access Lists and even Maps with array syntax. It'd be sweet.

Comment author: Luke_A_Somers 04 March 2016 06:13:49PM *  0 points [-]

All three of the things I asked for in this chain now exist as part of Java -

-- Lambdas - code snippets you can pass (without even declaring them as functions, even!),

-- brackets for accessing Lists and Maps, and

-- a way to declare variables for both a try and its associated catch and finally blocks.

I'm kinda floored.