# What is the FrontEnd?

Can anyone sort out what the Front-End is, how it is structured and what its relationship to the Kernel is. The FrontEnd is mentioned quite often but elusively avoids to be caught and clearly defined.

I think I understand that a notebook is a textual and graphical interface, and it is part of the so-called FrontEnd which is run by the kernel. But my understanding of its place and function in the Mathematica hierarchy, is unclear to me.

Here at SE, users are often encouraged to occasionally restart a notebook and sometimes even the Kernel to deal with certain problems. What happens here? I also see that some dynamic code works in a newly opened Notebook without an evaluation has been performed.

Anyone care to uncover the mystery?

• A seemingly very basic question that could potentially have a complex and important answer. +1 – Mr.Wizard May 23 '15 at 10:04
• I started an answer and posted it below but I realize that I could potentially go in a number of directions from here. To prevent it from becoming an aimless ramble would you please take a look and give me some guidance? – Mr.Wizard May 23 '15 at 10:23
• @Mr.Wizard I did the same search you mentioned, but didn't find any clear definition. Your answer is certainly helpful and I hope more will be added. You say some commands are managed by the Front End and some by the Kernel. I thought everything is ultimately driven by the Kernel. You see, I still don't understand how code is "run" in the Front End i.e. outside the Kernel. – MathLind May 23 '15 at 10:47
• Okay, I'll try to give my understanding of that aspect. Actually I think I'll have some coffee and breakfast first. :^) – Mr.Wizard May 23 '15 at 10:48
• LinkSnooper ought to be mentioned (e.g. q/18719) as well as the main, preemptive, and service links (e.g., see this chat exchange). One can observe what is done and communicated in each of the FE and kernel with LinkSnooper. – Michael E2 May 23 '15 at 10:56

I looked for a documentation section that concisely defined what the Front End is but I did not find one therefore I shall attempt my own definition. I admit I have never considered this in detail nor dug into the low level connection between the Front End and Kernel, so this definition is bound to be incomplete and possibly incorrect.

The Front End is the entire GUI (graphical user interface) to Mathematica. It is the implementation of the Notebook Interface. The alternative is a text-based (command line) interface.

The Front End is responsible for accepting input from keyboard, mouse, etc. Typed input is converted into Box representation(1)(2)(3) that can be passed to the Kernel. Menu commands, mouse clicks, etc., perform operations that may be applied by the Front End itself or which invoke Kernel evaluation, or a combination of both.

The Front End renders Box forms, directly input or passed back from the Kernel, in a human bearable way. These range from the simple RowBox, SubscriptBox types to all graphics and dynamic expressions. (One may use the menu command Cell > Show Expression to see the box structure of any Notebook cell.) Syntax highlighting, spacing and line breaks are applied by the Front End.

Some Front End rendering requires interaction with the Kernel. In recent versions even FrameTicks may rely on Kernel evaluation so graphics may not display completely until a Kernel is started and definitions are loaded. Dynamic expressions have their own evaluation channel to the Kernel in parallel to the normal evaluation channel employed by Shift+Enter.

• I believe Animator and Clock have a special implementation in the Front End. (See, for instance, my answer to Why animator smoothes dynamic updates, or how to make pacman drink beer.) – Michael E2 May 23 '15 at 11:03
• @MichaelE2 Would you care to collaborate if I make this answer a wiki? Or post your own answer? (Or neither I guess.) – Mr.Wizard May 23 '15 at 11:05
• I'm going on a trip after breakfast. My time and access might be limited for a few days. Which is why I chimed in with only a couple of comments. We can see how it goes, but for now I don't think I'd be able to fully participate. (But thanks for the invite!) – Michael E2 May 23 '15 at 11:17
• @Michael Okay. I hope the trip is fruitful and/or enjoyable! I'll be out for the day myself. – Mr.Wizard May 23 '15 at 11:18
• When Dynamic[] objects are involved, the connections between the front end and the kernel are more complicated, with three distinct links between them. This is explained well in Advanced Dynamic Functionality / Synchronous versus Asynchronous Dynamic Evaluations. – Emilio Pisanty May 23 '15 at 23:46

This answer is not meant to compete with @Mr.Wizard's answer, but to serve as a addendum presenting a historically-oriented view.

In the early days of Mathematica the dichotomy of front end and kernel was simple. Mathematica had a client-server architecture: The front end was the client and the kernel was the server.

The client's job was to manage the GUI, which could be broken into the following tasks:

• Get input from the user and typeset it on the screen.
• Translate input forms into kernel forms (think of these as FullForm) and send them to the server.
• Receive replies (evaluated forms and messages) from the server.
• Render the server replies on the screen (graphics rendering and more typesetting).

The server's job was to run the form evaluation engine on the forms received from the client and to return the resulting form (and perhaps some messages) when the evaluation reached a fixed point.

Since the introduction of Dynamic into the front end and support for parallel processing over multiple kernels this simple model has blurred, but perhaps it is still useful as a first-order approximation.

• Thank you. The historical perspective is helpful in understanding the origin and evolution of the Front End. The term "blurred" describes both its role and my past understanding of it pretty well. However after reading your answers it's getting clearer. – MathLind May 23 '15 at 13:05
• As you say, it has gotten blurred, but for the most part I pretend that it's still a simple client-server relationship unless I have to consider that it's actually not (e.g. w/ Dynamic[]). – J. M.'s technical difficulties May 23 '15 at 16:50
• @J.M. Dynamic is still pretty much client-server, if my understanding of it is correct. The kernel can track variable changes via the Names["Internal*Track*"] functions and the front-end configures listeners for that. What's more interesting is the stuff like Names["FEPrivate*"] which, with it's Mathematica-like syntax and limited scope (and the fact that it can only run in the FE), suggests there's something like a small kernel running in the FE. – b3m2a1 Aug 31 '17 at 19:47