14

In the Star Trek franchise, a number of characters "reprogram a computer" or "write a holodeck program" or do similar sorts of programming. Has is ever been identified what sort of languages are in use in this universe?

Thunderforge
  • 51,516
  • 43
  • 212
  • 431

2 Answers2

27

C++

No, seriously, they still use C++. Heck, they're even still doing their own memory management!

In Star Trek: Discovery 1x03 "Context is for Kings", Stamets asks Burnham to "reconcile these two pieces of code". When she later shows the location where the error is, it's clearly C++, or something remarkably similar to it.

Star Trek: Discovery uses C++ code

Here are the last few lines of the code:

LPVOID _stdcall VirtualAlloc(LPVOID ipAddress, SIZE_T dwSize, flAllocationType, DWORD flProtect);
HANDLE _stdcall CreateMutexW(LPSECURITY_ATTRIBUTES ipMutexAttributes, BOOL bInitialOwner; LPCWSTR ipName);
UINT _stcall SetErrorMode(UINT uMode);
BOOL _stdcall FreeLibrary(HMODULE hLibModule);

VirtualAlloc, CreateMutex (but not CreateMutexW), SetErrorMode, and FreeLibrary are all part of C++ recognized by Microsoft Windows in our time.

And yeah, you could probably argue that this C++ is placeholder for just "really complex-looking code", but given that Burnham debugging this specific piece of code is a plot point in the episode, I'm going to count it.


Thanks to Jules in the comments for finding the source of this code!

.. interestingly, that code appears to be the real-world source code for the standard Windows system component, kernel32.dll. Or a very near replica of it. Possibly an automated reverse engineering of it, given the poor choice of variable names.

The function that's shown in full (rather than just as a header) is GetCurrentProcess -- the windows documentation for that shows that it is part of kernel32.dll. Wikipedia comments that kernel32.dll mostly just delegates functionality to ntdll.dll, which you can see is exactly what the code shown is doing: it loads a reference to ntdll.dll, finds a pointer to a function from it, then calls it.

So apparently, they're still using Microsoft Windows in the 23rd Century and bugs are preventing Starfleet's science division from getting any work done! So much for Gene Roddenbery's dream of a utopic future!

Thunderforge
  • 51,516
  • 43
  • 212
  • 431
  • 13
    It's C+++ in the 22nd century... – Machavity Jan 15 '18 at 00:10
  • There's a difference of two centuries between question and your answer. During the time of Discovery, Holodeck didn't even exist. – user931 Jan 15 '18 at 00:39
  • 1
    @Bat I meant the Star Trek franchise, not a particular show. Plus, Episode 6 shows that Discovery pretty much has their own holodeck #DiscoveryBreaksContinuity – Thunderforge Jan 15 '18 at 00:40
  • 1
    Are we sure that Discovery is part of the canon? It’s very likely non-canon. Just look at the Klingons, for Pete’s sake. – Ham Sandwich Jan 15 '18 at 01:30
  • 1
    @HamSandwich Wikipedia says it's canon. I think the explanation that the showrunners gave is that Klingons have all sorts of appearances and that this is just a subgroup of Klingons we haven't seen before. Whether you are satisfied with that or not is up to you, but it's just as canon as every other TV show is. – Thunderforge Jan 15 '18 at 01:37
  • 1
    But it’s so ridiculous. – Ham Sandwich Jan 15 '18 at 03:32
  • If you actually meant the entire Star Trek franchise, then it's clear that the programming language used in the TNG era is any natural language that can be translated by the universal translator. We've witnessed hundreds of programs and other one-off instructions created and modified simply by speaking to the computer. – Ellesedil Jan 15 '18 at 08:18
  • 3
    The difference is that the code shown is 99% commented out, but Trek AI computers are able to read the comments and just do what the programmer really wanted. – The Photon Jan 15 '18 at 19:35
  • Anyway by the time of TOS they'd progressed to programming computers by just plugging the correct colored block of jello into a slot. – The Photon Jan 15 '18 at 19:37
  • @Bat - Holodecks absolutely existed by the time of Discovery if this is prime universe. Do you mean "Federation" holodecks? http://memory-alpha.wikia.com/wiki/Unexpected_(episode), http://memory-alpha.wikia.com/wiki/The_Practical_Joker_(episode) – NKCampbell Jan 15 '18 at 21:54
  • 2
    ... interestingly, that code appears to be the real-world source code for the standard Windows system component, kernel32.dll. Or a very near replica of it. Possibly an automated reverse engineering of it, given the poor choice of variable names. – Jules Jan 15 '18 at 22:03
  • 5
    @Thunderforge - the function that's shown in full (rather than just as a header) is GetCurrentProcess -- the windows documentation for that shows that it is part of kernel32.dll. Wikipedia comments that kernel32.dll mostly just delegates functionality to ntdll.dll, which you can see is exactly what the code shown is doing: it loads a reference to ntdll.dll, finds a pointer to a function from it, then calls it. – Jules Jan 15 '18 at 22:09
  • 3
    Ouch, so not only do they still run C++, it's still on a MS OS... Trek is actually a dystopia. Who knew? – WeRelic Jan 15 '18 at 23:43
  • 1
    Let me get this straight. Destiny runs on Windows? – Jorge Córdoba Jan 18 '18 at 22:53
  • 4
    @JorgeCórdoba Yup. I look forward to the episode where Discovery gets a blue screen of death because Windows has 300 years of legacy code, so they decide to switch to simpler tech (explaining why the Enterprise computers ten years later are so "retro"). – Thunderforge Jan 18 '18 at 23:47
  • ...Which is actually why using a language like C++ makes sense, @Ellesedil. If the computer is advanced enough that it can turn any arbitrary command into a program to perform said command, it's liable that the compiler is insanely good at optimisation, too. Thus, since language complexity/learnability is only a minor issue, optimisability becomes the most important factor. C++ is close to C in terms of raw performance potential, while providing a few features which would be major quality-of-life improvements if the optimiser is writing the program (e.g., templates and exceptions). – Justin Time - Reinstate Monica Oct 05 '20 at 17:19
  • Rust users get triggered by it. – João Farias Aug 05 '22 at 10:17
  • Not only are thye using C++, they're running Windows. – user253751 Aug 25 '22 at 13:42
12

In Discovery Season 2, Episode 8 (If Memory Serves), they talk about

"...multiple SQL Injections".

It's 2250 and people still don't clean user input.

Valorum
  • 689,072
  • 162
  • 4,636
  • 4,873
João Farias
  • 221
  • 2
  • 3
  • Cleaning input is the wrong way to solve SQL injection, anyway. It was 2019 and people still commented that user input should be cleaned! – user253751 Aug 25 '22 at 13:43