Truly independent web browser
Go to file
Andreas Kling a3e82eaad3 AK: Introduce the new String, replacement for DeprecatedString
DeprecatedString (formerly String) has been with us since the start,
and it has served us well. However, it has a number of shortcomings
that I'd like to address.

Some of these issues are hard if not impossible to solve incrementally
inside of DeprecatedString, so instead of doing that, let's build a new
String class and then incrementally move over to it instead.

Problems in DeprecatedString:

- It assumes string allocation never fails. This makes it impossible
  to use in allocation-sensitive contexts, and is the reason we had to
  ban DeprecatedString from the kernel entirely.

- The awkward null state. DeprecatedString can be null. It's different
  from the empty state, although null strings are considered empty.
  All code is immediately nicer when using Optional<DeprecatedString>
  but DeprecatedString came before Optional, which is how we ended up
  like this.

- The encoding of the underlying data is ambiguous. For the most part,
  we use it as if it's always UTF-8, but there have been cases where
  we pass around strings in other encodings (e.g ISO8859-1)

- operator[] and length() are used to iterate over DeprecatedString one
  byte at a time. This is done all over the codebase, and will *not*
  give the right results unless the string is all ASCII.

How we solve these issues in the new String:

- Functions that may allocate now return ErrorOr<String> so that ENOMEM
  errors can be passed to the caller.

- String has no null state. Use Optional<String> when needed.

- String is always UTF-8. This is validated when constructing a String.
  We may need to add a bypass for this in the future, for cases where
  you have a known-good string, but for now: validate all the things!

- There is no operator[] or length(). You can get the underlying data
  with bytes(), but for iterating over code points, you should be using
  an UTF-8 iterator.

Furthermore, it has two nifty new features:

- String implements a small string optimization (SSO) for strings that
  can fit entirely within a pointer. This means up to 3 bytes on 32-bit
  platforms, and 7 bytes on 64-bit platforms. Such small strings will
  not be heap-allocated.

- String can create substrings without making a deep copy of the
  substring. Instead, the superstring gets +1 refcount from the
  substring, and it acts like a view into the superstring. To make
  substrings like this, use the substring_with_shared_superstring() API.

One caveat:

- String does not guarantee that the underlying data is null-terminated
  like DeprecatedString does today. While this was nifty in a handful of
  places where we were calling C functions, it did stand in the way of
  shared-superstring substrings.
2022-12-06 15:21:26 +01:00
.devcontainer Meta: Add devcontainer configuration for use with Github Codespaces 2022-11-25 18:41:21 -07:00
.github Meta: Switch to clang-format-15 as the standard formatter 2022-12-03 23:52:23 +00:00
AK AK: Introduce the new String, replacement for DeprecatedString 2022-12-06 15:21:26 +01:00
Base AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
Documentation Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
Kernel AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
Meta Meta: Manually compute the length of the WASM JS REPL source string 2022-12-06 13:53:24 +00:00
Ports AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
Tests AK: Introduce the new String, replacement for DeprecatedString 2022-12-06 15:21:26 +01:00
Toolchain Toolchain: Add libxcrypt to serenity.nix 2022-11-13 19:38:14 +00:00
Userland LibJS: Intercept returns through finally blocks in Bytecode 2022-12-06 16:09:24 +03:30
.clang-format Meta: Switch to clang-format-15 as the standard formatter 2022-12-03 23:52:23 +00:00
.clang-tidy Meta: Disable readability-use-anyofallof clang-tidy check 2022-01-09 23:29:57 -08:00
.editorconfig Meta: Add .editorconfig 2022-09-10 17:32:55 +01:00
.gitattributes Repository: Protect port patches from CRLF/LF normalization 2022-01-12 01:08:38 +01:00
.gitignore Meta: Ignore vim's .exrc config 2022-10-06 16:06:50 +01:00
.mailmap Meta: Add mattco98's full name to mailmap 2022-11-23 17:13:49 +00:00
.pre-commit-config.yaml Meta: Add a post-commit commit message linter hook 2021-05-02 16:28:01 +02:00
.prettierignore LibJS: Handle empty named export 2022-09-02 02:07:37 +01:00
.prettierrc Meta: Move prettier config files to the root of the repository 2020-08-24 18:21:33 +02:00
.ycm_extra_conf.py Meta: Make YCM work when the current dir is not the root of the tree 2022-10-30 23:57:25 +01:00
azure-pipelines.yml CI: Disallow test failures on macOS Lagom :^) 2022-01-14 22:39:06 +01:00
CMakeLists.txt Toolchain: Update LLVM to 15.0.3 2022-10-24 15:33:58 +02:00
CONTRIBUTING.md Meta: Update all references of clang-format-14 to clang-format-15 2022-12-04 09:13:24 -07:00
LICENSE Meta: Update year range in LICENSE :^) 2022-01-02 18:08:02 +01:00
README.md Meta: Add Gregory Bertilson to the contributors list :^) 2022-11-30 10:12:11 +01:00
SECURITY.md Meta: Add a security policy 2022-06-29 03:29:27 +00:00

SerenityOS

Graphical Unix-like operating system for x86 computers.

GitHub Actions Status Azure DevOps Status Fuzzing Status Sonar Cube Static Analysis Discord

About

SerenityOS is a love letter to '90s user interfaces with a custom Unix-like core. It flatters with sincerity by stealing beautiful ideas from various other systems.

Roughly speaking, the goal is a marriage between the aesthetic of late-1990s productivity software and the power-user accessibility of late-2000s *nix. This is a system by us, for us, based on the things we like.

You can watch videos of the system being developed on YouTube:

FAQ: Frequently Asked Questions

Screenshot

Screenshot as of b36968c.png

Features

  • Modern x86 32-bit and 64-bit kernel with pre-emptive multi-threading
  • Browser with JavaScript, WebAssembly, and more (check the spec compliance for JS, CSS, and WASM)
  • Security features (hardware protections, limited userland capabilities, W^X memory, pledge & unveil, (K)ASLR, OOM-resistance, web-content isolation, state-of-the-art TLS algorithms, ...)
  • System services (WindowServer, LoginServer, AudioServer, WebServer, RequestServer, CrashServer, ...) and modern IPC
  • Good POSIX compatibility (LibC, Shell, syscalls, signals, pseudoterminals, filesystem notifications, standard Unix utilities, ...)
  • POSIX-like virtual file systems (/proc, /dev, /sys, /tmp, ...) and ext2 file system
  • Network stack and applications with support for IPv4, TCP, UDP; DNS, HTTP, Gemini, IMAP, NTP
  • Profiling, debugging and other development tools (Kernel-supported profiling, detailed program analysis with software emulation in UserspaceEmulator, CrashReporter, interactive GUI playground, HexEditor, HackStudio IDE for C++ and more)
  • Libraries for everything from cryptography to OpenGL, audio, JavaScript, GUI, playing chess, ...
  • Support for many common and uncommon file formats (PNG, JPEG, GIF, MP3, WAV, FLAC, ZIP, TAR, PDF, QOI, Gemini, ...)
  • Unified style and design philosophy, flexible theming system, custom (bitmap and vector) fonts
  • Games (Solitaire, Minesweeper, 2048, chess, Conway's Game of Life, ...) and demos (CatDog, Starfield, Eyes, mandelbrot set, WidgetGallery, ...)
  • Every-day GUI programs and utilities (Spreadsheet with JavaScript, TextEditor, Terminal, PixelPaint, various multimedia viewers and players, Mail, Assistant, Calculator, ...)

... and all of the above are right in this repository, no extra dependencies, built from-scratch by us :^)

Additionally, there are over two hundred ports of popular open-source software, including games, compilers, Unix tools, multimedia apps and more.

How do I read the documentation?

Man pages are available online at man.serenityos.org. These pages are generated from the Markdown source files in Base/usr/share/man and updated automatically.

When running SerenityOS you can use man for the terminal interface, or help for the GUI.

Code-related documentation can be found in the documentation folder.

How do I build and run this?

See the SerenityOS build instructions. Serenity runs on Linux, macOS (aarch64 might be a challenge), Windows (with WSL2) and many other *Nixes with hardware or software virtualization.

Get in touch and participate!

Join our Discord server: SerenityOS Discord

Before opening an issue, please see the issue policy.

A general guide for contributing can be found in CONTRIBUTING.md.

Authors

And many more! See here for a full contributor list. The people listed above have landed more than 100 commits in the project. :^)

License

SerenityOS is licensed under a 2-clause BSD license.