DEV Community

Discussion on: Java In 2019 And Beyond

Collapse
 
drgrib profile image
Chris Redford

Even the version in 2019 Java looks pretty convoluted to me. Now it's looking like Scala, which I'm also not a fan of.

Check out the version of this code in Go:

package main

import "fmt"

func main() {
    a := []int{}
    for i := 1; i <= 10; i++ {
        a = append(a, i)
    }

    for _, num := range a {
        if num%2 == 0 {
            fmt.Println(num)
        }
    }
}

That's a full, executable program that I just wrote off the cuff in 30 seconds while looking at your blog code. I think it has both Java versions beat for striking the right balance of concision and clarity.