Image Source: Getty Images.

Only in the world of tech can a company started in a dorm room 12 years ago be worth more than $300 billion today. Investors are drawn to technology stocks because they're exciting. The opportunity to get in on the ground floor of the next big thing, whether it's the internet or social media or virtual reality, is often too enticing to ignore.

But investing in tech stocks can be dangerous if too much caution is thrown to the wind. The dot-com bubble and bust of the late 1990s and early 2000s wiped out fortunes, and offered a stark reminder that investing based purely on hope is a terrible idea. Before you buy any tech stocks, there are two things that you need to know.

Things can change fast

Twenty years from now, I'm almost certain that people will still be buying laundry detergent. I'm fairly confident that Procter & Gamble, which sells detergent along with dozens of other consumer products, will still be a large, successful company. Technological advances are unlikely to disrupt its business model in any major way.

I have no idea what kind of computing devices the average person will be using 20 years from now. Will PCs still be a thing? What about smartphones? Will we all be wearing some sort of augmented reality glasses that project holograms into our view? Who knows.

What I am certain of is that the unrelenting march of technological progress will continue to change our world. Business models in the tech sector will be disrupted and destroyed, and entirely new markets will be created. Predicting anything in the world of tech ranges from difficult to downright impossible.

A great example of how change can destroy a once-dominant company in just a few short years is Blackberry (NYSE:BB). During the company's fiscal 2011, which ended in February of that year, Blackberry generated $19.9 billion of revenue selling its once-ubiquitous phones. Revenue grew by 33% that year, and the company managed a lush operating profit margin of 23.3%.

In 2007, Blackberry's devices ranked the highest in terms of customer satisfaction among business users, according to J.D. Power and Associates. But customer satisfaction is determined, in part, by what alternatives are available, and the introduction of Apple's (NASDAQ:AAPL) iPhone in 2007 began a process that Blackberry was unable to reverse. The company couldn't see what was coming, and its market share crashed as a result.

In fiscal 2016, the company generated just $2.2 billion of revenue, and posted a net loss of $208 million. The stock has lost more than 80% of its value during the past five years, and it's down more than 95% from its all-time high.

BBRY Chart

BBRY data by YCharts.

What happened to Blackberry can happen to any tech company that fails to stay ahead of the curve. Apple has grown into a smartphone behemoth, generating more than $50 billion of net income in fiscal 2015. But cracks are starting to show.

The first year-over-year decline in iPhone sales occurred during Apple's fiscal second quarter, the smartphone market has slowed to a crawl after years of torrid growth, and inexpensive Android phones are closing the quality gap with the iPhone. Is Apple the next Blackberry? It's certainly not impossible.

The price you pay needs to be within reason

Tech companies, especially those growing fast, typically trade at lofty earnings multiples. In many cases fast-growing tech companies are unprofitable, plowing cash back into the business in an attempt to grow as quickly as possible.

What you're willing to pay for such a company should be based on two things: the size of the potential opportunity, and the probability that the company succeeds. Coming up with a ballpark estimate for the first number isn't too difficult. It's the second number that causes problems.

The difference between paying 20 times earnings and 30 times earnings for a company that will grow profits at a double-digit rate for decades is negligible. The difference between paying 20 times earnings and 200 times earnings is not so negligible. And when there are no profits at all, assumptions that are often little more than guesses need to be made.

Investors get into trouble when every promising tech company is valued like it's the next Microsoft or Google or Facebook. Twitter (NYSE:TWTR) is probably not the next Facebook, although the market sure thought it was as recently as last year. Twitter's market capitalization was around $33 billion in early 2015, despite revenue of just $1.4 billion in 2014, and losses measured in the hundreds of millions of dollars. Following a predictable collapse in the stock price, Twitter is now worth just under $10 billion, which is still fairly optimistic given the company's predicament.

TWTR Chart

TWTR data by YCharts.

Cyber-security company FireEye (NASDAQ:FEYE) is another example of a tech stock gone wrong. The cyber-security market is going to be a lot bigger in the future than it is today, but every company in the space doesn't deserve to be valued like it's already captured that opportunity. FireEye is growing fast, but it's generating staggering losses in the process.

At its peak in early 2014, FireEye was valued at more than $11 billion, an incredible 68 times 2013 sales. The company has nearly quadrupled revenue since then, but growth is slowing down, and a net loss of $539 million in 2015 on just $623 million of revenue deserves a double take. The stock is down 80% from its peak.

FEYE Chart

FEYE data by YCharts.

There's a reason why Warren Buffett generally stays away from tech stocks -- investing in tech is hard. Unexpected events can decimate your investing thesis. Even if you're right about a specific company in the long run, paying too high of a price too early can lead to disaster.

You can succeed by doing two things: recognizing that every tech company is vulnerable to disruption, and making sure that your confidence in a company's success isn't irrationally exuberant.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.