# concatenation

Concatenation is the operation of appending one string or sequence of values to another; in C preprocessing, token concatenation combines two tokens into one using ##.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## CodeSOD: Building a Line

DevFeed: [CodeSOD: Building a Line](<https://devfeed.tech/articles/codesod-building-a-line-139424.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/building-a-line>)

Author: Remy Porter

Published: 2026-11-17T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [concatenation](<https://devfeed.tech/topics/concatenation.md>), [IO](<https://devfeed.tech/topics/io.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [builder](<https://devfeed.tech/tags/builder.md>), [codesod](<https://devfeed.tech/tags/codesod.md>), [concatenation](<https://devfeed.tech/tags/concatenation.md>), [file](<https://devfeed.tech/tags/file.md>), [function](<https://devfeed.tech/tags/function.md>), [performance](<https://devfeed.tech/tags/performance.md>), [return](<https://devfeed.tech/tags/return.md>), [string](<https://devfeed.tech/tags/string.md>)

### AI overview

The function reads a file in full, adds a line feed to the resulting string, appends that single combined value to a StringBuilder, and returns it. The author calls this a superstitious use of StringBuilder: for the current task, returning the read contents plus a line feed is simpler. Separate StringBuilder appends could make sense if the output were expected to grow or change, but the author considers that setup premature abstraction here.

### Source excerpt

There's an unofficial category of posts here that I call "Somebody told us string builders were more efficient, so we always use string builders, regardless of whether or not that actually makes sense," or STUSBWMESWAUSBROWONTAMS, for short. Probably should workshop that name some. In any case, Adam sends us a new entry for that collection: Public Function ReadFromFile(ByVal filename As String) As String Dim sb As StringBuilder = New StringBuilder() Dim str As String = String.Empty Using sr As StreamReader = File.OpenText(filename) str = sr.ReadToEnd() sb.Append(str & Constants.vbLf) End Using Return sb.ToString() End Function This function takes a filename, opens a file, reads the entire contents of the file to a variable. It concatenates a line feed to the end of the string it just read, then appends all of that to a string builder. Finally, we return sb.ToString(), taking the single string in the string builder, appending nothing to it, and returning the result. I'd almost, almost forgive the code if it was more like: str = sr.ReadToEnd() sb.Append(str) sb.Append(Constants.vbLf) You're not actually gaining much from this, but it follows the broad pattern of "use a string builder" so that if you ever wanted to change the structure of the output, you're already set up to prepend/append new text in a scalable way. I'd argue that's premature abstraction, though: a simple return sr.ReadToEnd() & Constants.vbLf would do the current job. The code that we have is a clear superstitious use of string builders. The string builder is used as a charm against poor performance, without understanding why one might use it, or how it might work; string concatenation means string builder, always and forever, "why" doesn't enter into it. [Advertisement] Keep all your packages and Docker containers in one place, scan for vulnerabilities, and control who can access different feeds. ProGet installs in minutes and has a powerful free version with a lot of great features that you can upg

## How to Convert a String to a Number in JavaScript

DevFeed: [How to Convert a String to a Number in JavaScript](<https://devfeed.tech/articles/how-to-convert-a-string-to-a-number-in-javascript-106037.md>)

Original publisher: [Read original article](<https://markodenic.com/javascript-string-to-number/>)

Author: Marko

Published: 2026-10-28T20:00:00Z

Content type: article

Language: en

Sources: [Marko Denic Blog](<https://devfeed.tech/sources/marko-denic-blog.md>)

Topics: [JavaScript](<https://devfeed.tech/topics/javascript.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>)

Tags: [bigint](<https://devfeed.tech/tags/bigint.md>), [comparison](<https://devfeed.tech/tags/comparison.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [money](<https://devfeed.tech/tags/money.md>), [number](<https://devfeed.tech/tags/number.md>), [plus](<https://devfeed.tech/tags/plus.md>), [string](<https://devfeed.tech/tags/string.md>), [table](<https://devfeed.tech/tags/table.md>), [tutorial](<https://devfeed.tech/tags/tutorial.md>), [web-development](<https://devfeed.tech/tags/web-development.md>)

### AI overview

Use `Number(str)` for a strict conversion of the whole string: it returns `NaN` for trailing units, but turns empty or whitespace-only strings into `0`, so handle those separately and validate with `Number.isFinite()`. Use `parseInt(str, 10)` or `parseFloat(str)` to read a number from the start of text with units; `parseInt` truncates decimals, while `parseFloat` keeps them. Unary plus behaves like `Number()`. The article also advises `array.map(Number)` instead of `array.map(parseInt)`, notes JavaScript's basic parsing does not handle locale grouping separators, and recommends `BigInt` or strings for integers beyond the safe-number range. For money, it suggests integer cents because decimal arithmetic can be inexact.

### Source excerpt

Convert a string to a number in JavaScript with Number(), parseInt(), parseFloat() and unary plus. Which one to use, a comparison table of edge cases, and how to validate, handle BigInt and money.

## Representative Line: Readable Formats

DevFeed: [Representative Line: Readable Formats](<https://devfeed.tech/articles/representative-line-readable-formats-95368.md>)

Original publisher: [Read original article](<https://thedailywtf.com/articles/readable-formats>)

Author: Remy Porter

Published: 2026-10-22T06:30:00Z

Content type: article

Language: en

Sources: [The Daily WTF](<https://devfeed.tech/sources/the-daily-wtf.md>)

Topics: [formatting](<https://devfeed.tech/topics/formatting.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>), [clean-code](<https://devfeed.tech/topics/clean-code.md>)

Tags: [formats](<https://devfeed.tech/tags/formats.md>), [net](<https://devfeed.tech/tags/net.md>), [nuget](<https://devfeed.tech/tags/nuget.md>), [representative-line](<https://devfeed.tech/tags/representative-line.md>)

### AI overview

The excerpt criticizes mixing a .NET numeric format string with concatenation to make decimal places configurable: repeated `new string('0', 2)` fragments obscure the format. It suggests assigning that fragment once to `decimalPlaces` to make the concatenation clearer. It also notes that .NET has a per-mille format specifier and objects to spelling its Unicode symbol as `\u2030` in code. The source presents this as a readability critique, not a broader comparison of formatting approaches.

### Source excerpt

We all love format strings for generating human readable text. Certainly, they're a better choice than string concatenation. Even if I have a blind spot that keeps me from remembering the printf format tokens, I still prefer to use format strings. Jasmine has a co-worker that does use format strings, but they also miss using string concatenation. So they've found a way to combine them, and avoid the perils of making readable code that describes the format of their text. myField.DataFormatString = "{0:#,##0." + new string('0', 2) + ";(#,##0." + new string('0', 2) + ")}"; Now, in their defense, I can see how this code started its life. At some point, they wanted to make the number of decimal places a parameter. And sure, this is an easy way to do that and retain the intent, though this whole thing could be cleaned up with just a simple decimalPlaces = new string('0', 2), which would make the concatenation less confusing to read. Related, while I was checking the documentation on the .NET formatting strings, I learned that they have a per-mille format specifier which requires writing a unicode sigil on most keyboards. I'm sorry, but seeing string perMilleFmt = "#0.## " + '\u2030'; in my code would be TRWTF. [Advertisement] Picking up NuGet is easy. Getting good at it takes time. Download our guide to learn the best practice of NuGet for the Enterprise.

## I Built a Python Compressor Using OpenAI's Tokenizer. Here's What Happened

DevFeed: [I Built a Python Compressor Using OpenAI's Tokenizer. Here's What Happened](<https://devfeed.tech/articles/i-built-a-python-compressor-using-openai-s-tokenizer-here-s-what-happened-92542.md>)

Original publisher: [Read original article](<https://hackernoon.com/i-built-a-python-compressor-using-openais-tokenizer-heres-what-happened?source=rss>)

Author: Lê Đức Minh

Published: 2026-10-21T07:28:58Z

Content type: article

Language: en

Sources: [HackerNoon](<https://devfeed.tech/sources/hackernoon.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>), [OpenAI](<https://devfeed.tech/topics/openai.md>), [Large Language Model](<https://devfeed.tech/topics/llm.md>)

Tags: [1-3](<https://devfeed.tech/tags/1-3.md>), [adaptive](<https://devfeed.tech/tags/adaptive.md>), [algorithm](<https://devfeed.tech/tags/algorithm.md>), [allowed](<https://devfeed.tech/tags/allowed.md>), [amazon-documentdb](<https://devfeed.tech/tags/amazon-documentdb.md>), [api](<https://devfeed.tech/tags/api.md>), [batch](<https://devfeed.tech/tags/batch.md>), [beats](<https://devfeed.tech/tags/beats.md>), [benchmarking](<https://devfeed.tech/tags/benchmarking.md>), [bits](<https://devfeed.tech/tags/bits.md>), [blog](<https://devfeed.tech/tags/blog.md>), [blogging](<https://devfeed.tech/tags/blogging.md>), [bpe-tokenization](<https://devfeed.tech/tags/bpe-tokenization.md>), [brotli](<https://devfeed.tech/tags/brotli.md>), [career](<https://devfeed.tech/tags/career.md>), [content-creation](<https://devfeed.tech/tags/content-creation.md>), [entropy](<https://devfeed.tech/tags/entropy.md>), [field-notes](<https://devfeed.tech/tags/field-notes.md>), [large-language-models](<https://devfeed.tech/tags/large-language-models.md>), [llm](<https://devfeed.tech/tags/llm.md>), [llm-tokenization](<https://devfeed.tech/tags/llm-tokenization.md>), [machine-learning](<https://devfeed.tech/tags/machine-learning.md>), [notes](<https://devfeed.tech/tags/notes.md>), [openai](<https://devfeed.tech/tags/openai.md>), [python](<https://devfeed.tech/tags/python.md>), [teaching](<https://devfeed.tech/tags/teaching.md>)

### AI overview

TokPress is a pure-Python lossless compressor that tokenizes raw bytes with OpenAI's o200k_base, applies LZ77 to token IDs, then codes them with rANS. Its strongest reported result comes from batching: 150 schema-similar JSON records compressed as one adaptive stream to 0.0875x their original size, while compressing them separately produced a 1.19 ratio. A trained TokDict adds match history and prebuilt entropy tables, but depends on data resembling its training domain; on held-out logs, TokPress remained 1.3x larger than zstd using the same training data. The author reports wins over gzip on prose and some wins over zstd, while stressing that tokenization preserves information: gains come from modeling, entropy coding, and shared dictionaries. Compression is slower because the encoder evaluates multiple modes; decompression is reported at thousands of records per second.

### Source excerpt

Field notes from a weekend spent teaching an entropy coder to speak LLM.

## BM25 is only as good as your tokens

DevFeed: [BM25 is only as good as your tokens](<https://devfeed.tech/articles/bm25-is-only-as-good-as-your-tokens-66824.md>)

Original publisher: [Read original article](<https://neon.com/blog/bm25-is-only-as-good-as-your-tokens>)

Author: Carlota Soto

Published: 2026-10-07T12:00:00Z

Content type: tutorial

Language: en

Sources: [Neon Docs](<https://devfeed.tech/sources/blog-neon-docs.md>)

Topics: [hybrid-search](<https://devfeed.tech/topics/hybrid-search.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>), [Query (disambiguation)](<https://devfeed.tech/topics/query.md>), [cosine similarity search](<https://devfeed.tech/topics/cosine-similarity-search.md>)

Tags: [bm25](<https://devfeed.tech/tags/bm25.md>), [database](<https://devfeed.tech/tags/database.md>), [lakebase](<https://devfeed.tech/tags/lakebase.md>), [neon](<https://devfeed.tech/tags/neon.md>), [product](<https://devfeed.tech/tags/product.md>), [search](<https://devfeed.tech/tags/search.md>)

### AI overview

The article explains how tokenization shapes BM25 search results in Lakebase Search. It introduces the `lakebase_tokenizer` extension, which lets developers define synonym and stop-word dictionaries in SQL tables, and shows how matching vocabulary can improve ticket search when users use different terms for the same concept. It also describes how token choices affect BM25 relevance scores.

### Source excerpt

Lakebase Search is the search primitive of the Neon backend. One of the best things about it is that it ranks keyword results with BM25. That said, BM25 can only score the terms it's given.

## So many tokens, so little time: Introducing a faster, more flexible byte-pair tokenizer

DevFeed: [So many tokens, so little time: Introducing a faster, more flexible byte-pair tokenizer](<https://devfeed.tech/articles/so-many-tokens-so-little-time-introducing-a-faster-more-flexible-byte-pair-tokenizer-67617.md>)

Original publisher: [Read original article](<https://github.blog/ai-and-ml/llms/so-many-tokens-so-little-time-introducing-a-faster-more-flexible-byte-pair-tokenizer/>)

Author: Hendrik van Antwerpen

Published: 2024-12-12T13:51:13Z

Content type: article

Language: en

Sources: [GitHub Blog](<https://devfeed.tech/sources/github-engineering.md>)

Topics: [tokenization](<https://devfeed.tech/topics/tokenization.md>), [Python](<https://devfeed.tech/topics/python.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>)

Tags: [ai-ml](<https://devfeed.tech/tags/ai-ml.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [database](<https://devfeed.tech/tags/database.md>), [denial-of-service](<https://devfeed.tech/tags/denial-of-service.md>), [efficiency](<https://devfeed.tech/tags/efficiency.md>), [llms](<https://devfeed.tech/tags/llms.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [tokens](<https://devfeed.tech/tags/tokens.md>)

### AI overview

GitHub describes an open source Rust byte-pair encoding tokenizer designed for incremental tokenization and efficient token counting. Its algorithm uses a compatibility property and dynamic programming to achieve linear runtime, and includes encoders for appending or prepending text, full-text encoding, and token counts over subranges. The post reports benchmark results against tiktoken-rs and Hugging Face tokenizers.

### Source excerpt

We released a new open source byte-pair tokenizer that is faster and more flexible than popular alternatives.

## The Three Cs: 🤝 Concatenate, 🗜 Compress, 🗳 Cache

DevFeed: [The Three Cs: 🤝 Concatenate, 🗜 Compress, 🗳 Cache](<https://devfeed.tech/articles/the-three-cs-concatenate-compress-cache-45662.md>)

Original publisher: [Read original article](<https://csswizardry.com/2023/10/the-three-c-concatenate-compress-cache/>)

Author: Harry Roberts

Published: 2023-10-17T00:00:00Z

Content type: article

Language: en

Sources: [CSS Wizardry](<https://devfeed.tech/sources/css-wizardry.md>)

Topics: [concatenation](<https://devfeed.tech/topics/concatenation.md>), [Cache](<https://devfeed.tech/topics/cache.md>), [Compression](<https://devfeed.tech/topics/compression.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [Network](<https://devfeed.tech/topics/network.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [caching](<https://devfeed.tech/tags/caching.md>), [compression](<https://devfeed.tech/tags/compression.md>), [concatenation](<https://devfeed.tech/tags/concatenation.md>), [http](<https://devfeed.tech/tags/http.md>), [network](<https://devfeed.tech/tags/network.md>), [networking](<https://devfeed.tech/tags/networking.md>), [resource-loading](<https://devfeed.tech/tags/resource-loading.md>), [speed](<https://devfeed.tech/tags/speed.md>), [web-performance](<https://devfeed.tech/tags/web-performance.md>)

### AI overview

This article examines three web-performance practices: concatenating files on the server, compressing them over the network, and caching them on users' devices. It explains how HTTP/2 changed the tradeoffs around bundling and parallel requests.

### Source excerpt

We know we should do it, but do we know how?

## The --var: ; hack to toggle multiple values with one custom property

DevFeed: [The --var: ; hack to toggle multiple values with one custom property](<https://devfeed.tech/articles/the-var-hack-to-toggle-multiple-values-with-one-custom-property-52124.md>)

Original publisher: [Read original article](<https://lea.verou.me/2020/10/the-var-space-hack-to-toggle-multiple-values-with-one-custom-property/>)

Author: Lea Verou

Published: 2020-10-12T00:00:00Z

Content type: article

Language: en

Sources: [Lea Verou's blog](<https://devfeed.tech/sources/lea-verou-s-blog.md>)

Topics: [Web Development](<https://devfeed.tech/topics/web-development.md>), [User interface design](<https://devfeed.tech/topics/ui-design.md>), [if statement](<https://devfeed.tech/topics/if-statement.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>)

Tags: [all](<https://devfeed.tech/tags/all.md>), [allowed](<https://devfeed.tech/tags/allowed.md>), [apply](<https://devfeed.tech/tags/apply.md>), [background](<https://devfeed.tech/tags/background.md>), [blog](<https://devfeed.tech/tags/blog.md>), [border](<https://devfeed.tech/tags/border.md>), [box](<https://devfeed.tech/tags/box.md>), [but](<https://devfeed.tech/tags/but.md>), [button](<https://devfeed.tech/tags/button.md>), [call](<https://devfeed.tech/tags/call.md>), [can](<https://devfeed.tech/tags/can.md>), [code](<https://devfeed.tech/tags/code.md>), [color](<https://devfeed.tech/tags/color.md>), [css](<https://devfeed.tech/tags/css.md>), [css-variables](<https://devfeed.tech/tags/css-variables.md>), [custom](<https://devfeed.tech/tags/custom.md>), [hack](<https://devfeed.tech/tags/hack.md>), [multiple](<https://devfeed.tech/tags/multiple.md>), [original](<https://devfeed.tech/tags/original.md>), [property](<https://devfeed.tech/tags/property.md>), [tips](<https://devfeed.tech/tags/tips.md>), [toggle](<https://devfeed.tech/tags/toggle.md>), [values](<https://devfeed.tech/tags/values.md>), [var](<https://devfeed.tech/tags/var.md>), [with](<https://devfeed.tech/tags/with.md>)

### AI overview

The excerpt describes a CSS custom-property toggle: set a variable used in `var()` fallbacks to `initial` to activate the fallback values, or to whitespace (`--foo: ;`) to leave surrounding declarations unchanged. This can append or enable values across properties and rules using one variable, such as styling a raised button. The technique only supports appending values or choosing a whole value versus `initial`; it cannot express arbitrary alternatives such as red versus white backgrounds. The author notes readability concerns and suggests comments or named constants like `--ON` and `--OFF`. A proper CSS `if()` is described as a future alternative under discussion.

### Source excerpt

What if I told you you could use a single property value to turn multiple different values on and off across multiple different properties and even across multiple CSS rules? What if I told you you could turn this flat button into a glossy skeuomorphic button by just tweaking one custom property --is-raised, and that would set its border, background image, box and text shadows in one fell swoop? How, you may ask? The crux of this technique is this: There are two custom property values that work almost everywhere there is a var() call with a fallback. The more obvious one that you probably already know is the initial value, which makes the property just apply its fallback. So, in the following code: background: var(--foo, linear-gradient(white, transparent)) hsl(220 10% 50%); border: 1px solid var(--foo, rgb(0 0 0 / .1)); color: rgb(0 0 0 var(--foo, / .8)); We can set --foo to initial to enable these "fallbacks" and append these values to the property value, adding a gradient, setting a border-color, and making the text color translucent in one go. But what to do when we want to turn these values off? Any non-initial value for --foo (that doesn't create cycles) should work. But is there one that works in all three declarations? It turns out there is another value that works everywhere, in every property a var() reference is present, and you'd likely never guess what it is (unless you have watched any of my CSS variable talks and have a good memory for passing mentions of things). Intrigued? It's whitespace! Whitespace is significant in a custom property. When you write something like this: --foo: ; This is not an invalid declaration. This is a declaration where the value of --foo is literally one space character. However, whitespace is valid in every CSS property value, everywhere a var() is allowed, and does not affect its computed value in any way. So, we can just set our property to one space (or even a comment) and not affect any other value present in the declar

## Learning PHP: Concatenate Strings and Variables Efficiently

DevFeed: [Learning PHP: Concatenate Strings and Variables Efficiently](<https://devfeed.tech/articles/learning-php-concatenate-strings-and-variables-efficiently-121171.md>)

Original publisher: [Read original article](<https://wpshout.com/php-concatenate-strings/>)

Author: David Hayes

Published: 2019-06-04T17:42:36Z

Content type: article

Language: en

Sources: [Back-End Development - WPShout](<https://devfeed.tech/sources/back-end-development-wpshout.md>)

Topics: [PHP](<https://devfeed.tech/topics/php.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>), [Tutorial](<https://devfeed.tech/topics/tutorial.md>)

Tags: [back-end-development](<https://devfeed.tech/tags/back-end-development.md>), [efficiently](<https://devfeed.tech/tags/efficiently.md>), [php](<https://devfeed.tech/tags/php.md>), [strings](<https://devfeed.tech/tags/strings.md>), [variables](<https://devfeed.tech/tags/variables.md>), [wps](<https://devfeed.tech/tags/wps.md>), [wps-nf](<https://devfeed.tech/tags/wps-nf.md>)

### AI overview

PHP concatenates strings with the `.` operator, which joins quoted strings and variables; simple numbers are converted to strings automatically, while arrays and objects need extra work. Double-quoted strings can interpolate variables directly, including with braces for clarity, while single-quoted strings require concatenation. The text says interpolation's performance overhead is small and benchmark differences from concatenation are negligible and expression-dependent. The `.=` operator appends to an existing string. The author recommends using concatenation thoughtfully: templates are often better for assembling HTML than building large HTML strings in code.

### Source excerpt

A slightly weird term you'll hear people use around PHP: "concatenate." I still remember the first time I heard that word, having no earthly idea what it meant. It turns out it was a common and useful task in PHP: join two strings together so that we get a single string or something that we... Read More "Learning PHP: Concatenate Strings and Variables Efficiently

## The Difference Between :x:element and :x:primitive

DevFeed: [The Difference Between :x:element and :x:primitive](<https://devfeed.tech/articles/the-difference-between-x-element-and-x-primitive-22031.md>)

Original publisher: [Read original article](<https://codebeforethehorse.tumblr.com/post/35419887698>)

Author: Codebeforethehorse

Published: 2012-11-10T18:16:00Z

Content type: article

Language: en

Sources: [Stefan Parker](<https://devfeed.tech/sources/stefan-parker.md>)

Topics: [class](<https://devfeed.tech/topics/class.md>), [HTML](<https://devfeed.tech/topics/html.md>), [REST API](<https://devfeed.tech/topics/rest-api.md>), [concatenation](<https://devfeed.tech/topics/concatenation.md>)

Tags: [ajax](<https://devfeed.tech/tags/ajax.md>), [class](<https://devfeed.tech/tags/class.md>), [custom](<https://devfeed.tech/tags/custom.md>), [html](<https://devfeed.tech/tags/html.md>), [json](<https://devfeed.tech/tags/json.md>), [render](<https://devfeed.tech/tags/render.md>), [xhp](<https://devfeed.tech/tags/xhp.md>), [xss](<https://devfeed.tech/tags/xss.md>)

### AI overview

The excerpt recommends using `:x:element` by default: its `render()` method returns more XHP, and rendering recurses through the tree until `:x:primitive` nodes are reached, whose `stringify()` method returns strings. It says HTML nodes provide XSS protection so long as output remains HTML nodes. Use a primitive for a custom HTML node by extending `:xhp:html-element` and defining its tag name, or for non-HTML output such as an AJAX JSON response. The shown response example gathers rendered children into an `html` field and JSON-encodes it with `payload` and `errors`. The excerpt says primitives are usually the final step before sending a response.

### Source excerpt

I was recently asked to clarify the differences between :x:element and :x:primitive, and when to use each one. It's actually pretty simple; the basic rule of thumb is this: always use :x:element. If you're only doing simple things in XHP you can stop reading now, but for the rest of you I'll get into the rare instances where you might use :x:primitive. First, the main difference. :x:element implements the render() method, which returns more XHP while :x:primitive implements to stringify() method, which returns a string. When you echo XHP to the page, it recursively calls render() on itself until it returns an :x:primitive. It will continue to do this to any children of an :x:primitive as well. Once the entire tree is just :x:primitives (usually meaning just HTML nodes) it stringify()s it. So why the difference? The big reason was that we can put XSS protection in all HTML elements and so long as you just return HTML nodes you'll never have to worry about input sanitization again. There are two cases where you would want to create an :x:primitive though. The first being if you wanted to create a custom HTML node. Let's say you wanted to create a <foo> tag for your own purposes. All you would need to do is extend :xhp:html-element (which extends :x:primitive) and define its tag name. class :foo extends :xhp:html-element { protected $tagname = 'foo'; } Pretty simple. You could define custom attributes and children restrictions too if you so desired. The other reason you would extend :x:primitive is if you wanted to return something other than HTML. Consider an AJAX response that returns a JSON object. You might construct an object that behaves like this: class :ajax:response extends :x:primitive { attribute array payload; attribute array errors; protected function stringify() { $html = ''; foreach ($this->getChildren() as $child) { $html .= :x:base::renderChild($child); } $response = array( 'payload' => $this->getAttribute('payload'), 'errors' => $this->getAttribute('e