How does the Linux “Wine” algorithm work

271 viewsOtherTechnology

How does the Linux “Wine” algorithm work

In: Technology

2 Answers

Anonymous 0 Comments

WINE isn’t an algorithm but a framework, which at its very simplest can be described as a collection of algorithms and data objects.  

Anyway to your question.

Back in the day when a computer program wanted to draw some text or a shape on the screen it had to do all the work itself. So each program would have code to do even the most basic tasks.  It didn’t take long before people realized that it was far better to have a shared set of code to do those things that any program could use.  These shared pieces of code are called libraries and they have rules called application programming interfaces or APIs for how to use each function.  

For example, if I want to draw a rectangle there’s a number of ways I could tell the computer how to do that.  One is providing four coordinate pairs, one for each corner.  Another is to provide just one coordinate, say the bottom left corner, and provide the width and the height of the shape.  

Different libraries and different operating systems have different APIs.  Maybe Windows uses the four corners method for rectangles and Linux uses the one corner and two dimensions method.  So you can’t take software written for one OS and expect it to run correctly on another. It’s like handing someone who speaks German a recipe book in Chinese and expecting them to be able to bake a cake.  In order to make it work you have to translate the recipe first. 

WINE is a translation layer. It translates certain Windows APIs into comparable Linux APIs.  This lets many programs run even though they weren’t written for Linux. 

So why doesn’t every program do that?

Well a few reasons. 

First, not all the APIs are included.  Some don’t have an exact match. Others are rarely used.  Still others depend on specific conditions that are true of one OS but not the other.  

Second, APIs are added, removed, and changed over time.  If that happens WINEs needs to be updated too to adjust to any changes that impact its mappings. 

Third, some software, and this is especially true of many games, depends on the specific details of how a given API performs.  Maybe the rectangle drawing function on the Windows machine takes only 2 processor cycles to work, but the Linux equivalent takes 4.  If you don’t adjust for that the game will run twice as slow when drawing rectangles which can cause things to break. 

So WINEs does its best to bridge the gap, but it comes with limitations. Still it’s a powerful tool and works well enough for a lot of circumstances.  

You are viewing 1 out of 2 answers, click here to view all answers.