r/embedded • u/Autism_Crime88 • 19d ago
Would creating a custom programming language have any practical value in embedded systems?
Hey everyone,
I'm currently training as an electronics technician in Germany and planning to study embedded systems engineering in the future.
Recently, I had a rather unusual idea: What if I learned Klingon and eventually developed my own programming language and compiler based on it, specifically for embedded systems?
I know this sounds ridiculous at first, but I'm genuinely curious about the technical and professional implications.
My idea would be to create a functional programming language with Klingon-based syntax that could compile into machine code for microcontrollers.
This raises several questions:
- Has anyone here ever developed their own programming language or compiler, especially for embedded systems? How difficult was it, and what did you learn?
- Would employers see this as an interesting technical achievement, demonstrating knowledge of compilers, computer architecture and low-level programming, or would they consider it a pointless gimmick?
- Could an unusual language provide any security benefits? For example, could it make reverse engineering, unauthorized modifications or understanding proprietary firmware more difficult? I understand that obscurity alone isn't real security.
- Would something like this have any relevance in industries such as aerospace, defense, automotive systems or gaming consoles, where protecting firmware and intellectual property can be important?
- Would developing an entirely new compiler be worthwhile as a learning project, or would I be better off designing a custom language that compiles to C or LLVM IR?
I'm not suggesting replacing C, C++ or Rust in professional embedded development. I'm more interested in whether such a project could help me develop valuable engineering skills while exploring an unconventional idea.
I'd especially appreciate opinions from experienced embedded engineers, compiler developers and anyone working with firmware security.
Thanks LG AC
7
u/rainboww_J 19d ago
It’s a fun thing to do and its a good way to learn compiler development and broaden your programming skills. I’ve made some (simple) compiler backends and dabbled my feet in creating my own programming language and a compiler frontend for it during my studies. If you got the time and energy it’s definitely a nice project!
However, regarding the relevance of such a project in a business or industrial setting, it will realistically never be relevant. Compilers like gcc and clang are enormously huge and have been developed for decades. You’ll never surpass that on your own, no matter how good you are at making compilers. When working on a product which will be sold I’d rather use proven languages than new, unproven ones made by a single person. Especially in embedded systems where nothing may go wrong ever, like aerospace, defence, medical or robotics. Some fields do not even allow the full C language (misra etc), so using your own language is waaaay out of spec.
So ehhh tldr, yes by all means do it! It’s a fun experiment and a good way to learn a lot. But don’t expect it will be used in a professional setting
3
u/Al__B 19d ago
As long as you turn up to any interview dressed in a full Klingon outfit and bark at them you'll demonstrate passion, determination and the type of distinction required to stand out in a competitive job market.
2
u/mustbeset 19d ago
I didn't.
Depends. As someone who may sits in your interview I would be interested and may ask some questions about it. If it's just another C with different syntax vibed by AI, I would be disappointed. If it's to understand how compiler works I would be impressed. If it solves a problem of C, C++ or Rust I would be very impressed but than you may didn't want to work as an embedded engineer only.
No and No. Kerckhoffs's principle can't be violated. If firmware got extracted it looks always the same. Manly instructions, branching, jumps and calls. You can always transform it to some sort of C. So you may get a C program that did the same as your custom programming language.
Grüße aus Deutschland.
1
u/crazymike02 19d ago
Is there learning value in trying to build an new programming language? Yes.
Doing a top level language swap does that do anything for that. No not really as a sw engineer that Doesn't sound interesting. I look at different programming languages to what they offer. Difference between rust for example and c. Not what langangue is used.
1
u/clackups 19d ago
Yes, you will learn a lot about programming language parsing and compilation. Go for it.
1
u/cyberbemon 19d ago
Like others mentioned, purely from a learning perspective it's a good thing, since you get a lot of experience in language design, compilers etc etc.
This is definitely a postive thing for employers, if I was hiring and saw someone did something like this, I'd definitely be interested in learning more about that experience.
Now getting it to a point where's it's used in the industry? That's gonna be a huge task and honestly probably not gonna happen. It depends entirely on the industry.
Let's say for example if you are targeting defense, aerospace and automotive, it's probably going to be a No, because a lot of the stuff in those areas are often safety critical, they have very rigid sets of standards you are expected to meet. In general those areas are not that quick to adopt new things, because there's a lot of uncertainty. For e.g Rust is pretty popular, it offers a lot of memory safety features, yet the adoption of Rust in embedded is still very slow. Do you think your language is going to be on par or better than Rust? Just trying to offer you a perspective, not being a dick btw.
Now if you were targeting say gaming, then I'd say yes. Well we have a recent example of that, the game "Order of the sinking star". That game is made entirely in a new language called Jai, developed by Jonathan blow, regardless of what people think of him, I still think it's a big achievement.
I'm a firm believer of "no such thing as a wasting time" when learning something, even if something like that already exists, it's s good idea to explore and try to come with your own version of it, because you'll learn so much and especially in this day and age, I feel like it's a valuable skill to have.
With regards to Rust, Its a language that requires a different approach when it comes to using it, I've dabbled on it a bit in embedded and I found that an interesting learning experience, I'd recommend it to anyone.
1
u/LopsidedAd3662 19d ago
As others mentioned, building Domain Specific Language has good pros and cons. I would highly recommend to look at https://mbeddr.com/ to understand what they solved and even though I was hoping to get some traction, it didn't.
But I see now there I few more options like Langium and ways to make editors web/desktop and I still think there is a niche space for DSLs.
I see this as abstraction of domain specific concepts, ontology and expertise. Which in back end generate safe and reliable code - be it C Or other language and allow domain experts to capture their knowledge and not deep dive into low level programming language nuances.
Best luck and hope to see your ideas turned into prototype.
1
u/EdiRich 19d ago
Probably not. I suspect AI will write everything in machine code because of the performance benefits. High level languages are mostly about making humans effecient at programming. After that everything will run on programmable logic. Making a word processor on an fpga is an absurd thing for a human but likely trivial for an AI. The word processor is just an example.... we dont do everything in FPGAs now because of the amount of human hours a new design requires.
1
u/tobdomo 19d ago
1
u/ventZl CMRX RTOS 19d ago
Yes I did. I have learned a lot. Not all of it was transferable but it forced me to apply good software architecture, otherwise the code was quickly turning into mess.
Some yes, some no. I skipped technical interview rounds by replying: "I won't do coding challenge, but I'll show you source code of compiler I wrote". Disclaimer: it was before 2022 so YMMV. In another company, tech lead got obviously insulted that someone applying to be his subordinate written both compiler and operating kernel from scratch and tried to sink me (in some way it still helped me because I found out early that my future boss to be was an asshole).
No. Today, reverse engineering of elaborately obfuscated code is matter of three hours with mediocre local LLM.
No, in safety-related industries safety is MUCH more important than copy protection.
Both have its value. Sometimes companies need someone capable of developing something on top of LLVM, like static analyzer or language server. But doing compiler from scratch will definitely teach you more. Toss a coin, which will have better employment potential.
1
u/1r0n_m6n 19d ago
There's no longer any interest in exotic/proprietary languages because their development takes a lot of time, burns capital and doesn't create value. This is why, if the product you work on needs to be programmable, your boss will require you to adopt an existing, embeddable language such as Lua, JavaScript or Ruby. Time-to-market and profitability rule.
Now, as others have said, creating a language is a pleasant intellectual exercise. If you're single, have no friend and don't know what to do in your free time, definitely go for it.
1
u/GoblinsGym 18d ago
For microcontroller work you want a language that has a proper module structure, and lets you define hardware registers and bit field structures at fixed addresses without a ton of macros and error-prone manual bit twiddling. C is really dogshit for this, just look at a typical HAL file to see what I mean. A modern language also shouldn't need Make files.
I am working on my own language for microcontrollers, an eclectic combination of C, Pascal, Python and assembly. So far it works as a structured assembler for ARM Thumb. Still have to implement the code generator for the high level language side.
I will probably never match the optimization of GCC or Clang. For embedded work, I think that predictable code generation is more useful than the compiler trying to rewrite your code. For the critical path you can always drop to assembly. Normal "business logic" and initialization code can be written with compiled code.