Imagine if Java got rid of semi-colons; and those {brackets} ?

I ran across Joel-on-software's comments on Python (boils down to "I don't know jack about the language, but the indentation thing is cool!") and I thought about Java doing the same exact thing. Change nothing else but make indentation count. Suddenly Java looks really clean!

Here's a Java Servlet with indentation:


import java.io.*
import javax.servlet.*
import javax.servlet.http.*

public class HelloWorldServlet extends HttpServlet 

        String content = ""

        public void init(ServletConfig servletConfig) 
                throws ServletException 

                content = "This is some content"

        public void doGet(HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException

                response.setContentType("text/html")
                PrintWriter out = response.getWriter()

                out.println("<html>")
                out.println("<head>")
                out.println("<title>Hello World</title>")
                out.println("</head>")
                out.println("<body>")

                out.println(content)

                for(int x = 1; x < 10; x++)

                        out.println("Testing!")

                out.println("</body>")
                out.println("</html>")

        public void doPost(HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException

                content = request.getParameter("content")
                doGet()


Damn, that looks pretty clean! Notice I didn't get rid of *all* semi-colons, just the ones at the end of statements and it's pretty cool. I actually grabbed a much bigger class file that I have and formatted it, then got rid of the {}'s and ;'s and it too was very clean.

Not that this would ever happen, but it'd be cool.

-Russ

< Previous         Next >