Web frameworks do their routes matching with various mechanisms:
Let's see an example:
@GetMapping(value = "/student/{studentId}")
public Student studentData1(@PathVariable Integer studentId) {}
@GetMapping(value = "/student/{studentId}")
public Student studentData2(@PathVariable Integer studentId) {}
@GetMapping(value = "/student/umm")
public Student studentData3(@PathVariable Integer studentId) {}
Issues:
studentId
appears in 2 places, you can make a typo and nothing will work."/student/{studentId}"
route is duplicated, there is no compiler support and it will fail only in runtime..studentData1
will be picked up before studentData3
..!?Well, you need a special compiler for this, essentially a new language.
People have to learn how it works, there's probably no syntax highlighting, no autocomplete etc.
Similar to special route file approach, people need to learn it.
And again, you don't leverage compiler's support like exhaustive pattern matching and extractors.