Is it possible to buy or send bitcoins without an intermediary? If I want to buy bitcoins, I can buy them from an online exchange, from an ATM or from another person who has bitcoins. Online exchanges and ATMs charge high premiums because they are intermediaries. If I buy bitcoins from other people, they also charge high premiums. The whole idea behind the blockchain was to get rid of third-parties. Is is possible to connect to the public ledger somehow and acquire bitcoins without a third-party?

I wonder how the first bitcoin transactions were completed when there wasn't any online exchanges, mobile wallets or ATMs. Can programmers somehow connect to the public ledger and do transactions without bitcoin wallets or fees?
Do not mix the fees, and its base. Whenever you transfer amounts of value between two fiat currencies (let's say GBP to Euro), you pay a fee. So if you go from GBP to Bitcoin or from Euro to Bitcoin, you pay a similiar fee to those, who are "in fiat currency" to ramp up. 

Now, when you are within the bitcoin ecosystem, and you transfer bitcoins from your account to my account, then you pay a miner fee. Miners make sure, the bitcoin network is working correctly, and this is to be paid. 
When you say the whole idea was to get rid of third parties, than you omit the miners. I guess you mean with third parties the "old structures" of the fiat world... They are indeed not required, once you are in bitcoin world. 


  connect to the public ledger somehow and acquire bitcoins without a
  third-party?


yes, you can setup your own mining equipment, mine some blocks, and get rewarded for it. Otherwise, if you convert Euro/GBP/Dollars, no (see above). 


  Can programmers somehow connect to the public ledger and do
  transactions without bitcoin wallets or fees?


Yes, with a mining node. No in general. Example: I have my own set of script to transfer bitcoins between wallets. In this sense I can be considered a programmer :-) I assemble a tx, and send it into the network (aka "connect to the public ledger", following specific rules). For the miners to bring my tx into a block, I have to pay a fee. 

So there is no such thing as free beers :-)

I consider reading the book "Mastering Bitcoin" from Andreas (http://chimera.labs.oreilly.com/books/1234000001802/index.html) for further info.