I am aware that in solidity there are two types of libraries.
Embedded Library: If a smart contract is consuming a library which have only internal functions than EVM simply embeds library into the contract. Instead of using delegate call to call a function, it simply uses JUMP statement(normal method call). There is no need to separately deploy library in this scenario.
Linked Library : On the flip side, if a library contain public or external functions then library needs to be deployed. Deployment of library will generate unique address in blockchain. This address needs to be linked with calling contract.
From what I can see, if there is a functionality/code that will be identical over many SmartContracts, we should write Linked Library to avoid code duplication and thus save gas. We deploy such a library and link it to all the contracts that need to use its logic.
So what is then the point of Embedded Library??
Because, from what I can see, we don't deploy Embedded Library because the compiler will basically copy-paste its code into all the smart-contracts using it. So why just not write the code in SC and save yourself the trouble? (I guess it could make your code look cleaner, but that is about it)
Or am I missing something here? At the moment, Linked Library seems to have an obvious use case, while I can't find any situation where I would use Embedded Library instead. So I hope someone with more experience can explain this to me.
Link to relevant article -> All you should know about libraries in solidity
Another good article on how to downsize your SmartContracts by using Library