Master New Programming Languages: Practical Tips for Java, Scala, and Go
This article shares practical strategies for learning a new programming language—summarizing, comparing, shifting mindsets, studying open‑source code, using analysis tools, and intensive practice—illustrated with concrete Java, Scala, and Go examples.
1. Summarize
Regularly summarizing what you learn deepens understanding and improves memory. For example, Go provides slice, map, and channel types that can be created with make, and also initialized directly:
colors := map[string]string{} slice := []int{}Note that channel does not support the same literal syntax: msg := chan string{} Using the var form creates a nil value:
var colors map[string]string var slice []intStruct pointers can be initialized without explicit type or address operators:
type Product struct {
name string
price float64
}
products := []*Product{{"Spanner", 3.99}, {"Wrench", 2.49}, {"Screwdriver", 1.99}}2. Compare
When learning a new language, constantly compare it with languages you already know. For arrays, the definitions differ:
// Java
int[] arr; // declaration
arr = new int[5]; // instantiate with length
arr[1] = 8; // assign
// Scala
val arr = new Array[Int](5) // size in constructor
arr(1) = 8 // assign using parentheses
// Go
arr := [5]int{} // array of length 5, zero‑initialized
arr[1] = 8 // assignMaps also differ:
// Scala
val capital = Map("France" -> "Paris", "Japan" -> "Tokyo")
println(capital.get("France"))
// Go
capital := map[string]string{"France": "Paris", "Japan": "Tokyo"}
fmt.Println(capital["France"])Multiple assignment in Scala can use pattern matching, while Go uses a simple tuple assignment:
// Scala
case class Tao(name: String, age: Int)
val Tao(myName, myAge) = Tao("taozs", 18)
println(myName)
println(myAge)
// Go
myName, myAge := "taozs", 18
fmt.Println(myName)
fmt.Println(myAge)Function definitions also vary:
// Scala
val increase: Int => Int = (x: Int) => x + 1
println(increase(8))
// Go
var increase func(int) int = func(x int) int { return x + 1 }
fmt.Println(increase(8))3. Change Your Thinking
Adopt the paradigm of the language you are learning. Moving from C to Java requires an object‑oriented mindset; from Java to Scala requires functional thinking; from Scala to Go you must blend procedural and object‑oriented approaches.
For example, a traditional Java for loop:
for (int i = 1; i < 10; i++) {
// loop body
}can be expressed functionally in Scala:
val autoList = (1 to 10).map(i => /* process i */)In Go, the same character‑by‑character transformation is written procedurally:
name := "abc"
second := strings.Map(func(x rune) rune { return x + 1 }, name)4. Study Open‑Source Code
Reading real projects on GitHub helps you see how experienced developers solve problems. For instance, a Go performance‑testing framework uses defer profile.Start().Stop() to ensure cleanup after execution.
func main() {
defer profile.Start().Stop()
// ...
}5. Use Code‑Analysis Tools
Static analysis, testing, coverage, profiling, and tracing tools reveal hidden issues early. A Java snippet that creates a new String may have performance drawbacks, while a synchronized method can hide concurrency bugs that tools like FindBugs would flag.
String sb = new String("Hello World");
synchronized public void send(authuserPacket pkt, Thread t, String flowNo) throws IOException {
// ...
if (!this.avaliable) {
Thread.sleep(2000);
}
}Go provides built‑in tools such as vet, test, cover, pprof, and trace that should be used while learning.
6. Practice Extensively
Just like learning a natural language, you must write code repeatedly. Re‑type examples, run them, solve exercises, and participate in projects whenever possible.
Take notes of key points and personal reflections.
Review material frequently.
Study a little each day to build long‑term retention.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Huawei Cloud Developer Alliance
The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
