|
|
|
|
|
by aeonflux
332 days ago
|
|
Types are helpful in large codebases, but in Web Apps they tend to get into the way more than they help. You can still use semi-typed constructs in Ruby, but you have the freedom to choose where you need them. After moving to writing web in Go (from Ruby) I am still baffled how much more boiler plate there is and how much slower things move because of this. Types are great when you want to refactor some things, but thats just part of the job. In Ruby I loved how can you just quickly jump into REPL or just do inline breakpoint to inspect state: `scope.map(&:names).last.tally.sort_by(&:last).reverse.first(10)` Something like this is such a chore in Go that I simply skip it more often than not. > it uses a lot of special characters, which makes writing the code slower I don't get this part. What special characters? |
|
> I don't get this part. What special characters?
For example let's look at this code:
```
class ProductsController < ApplicationController before_action :set_product, only: %i[ show edit update destroy ]
...```
You can see a bunch of special characters: < : , % [] @
For example, if I wanted to write the same code in Typescript, based on my setup I might just need do something like this:
```
instance.get("/products", () => ProductsRepository.find());
```
Where instance is my router instance (fastify, express, whatever) and ProductsRepository is a TypeORM repository. My before_action might just be a middleware I pass to the callbacks chain or register as global middleware