As an embedded engineer I found the github page incredibly frustration, and it's tempting to just write it off. If the original author, or anyone else putting a putting together a language page, here's question I shouldn't have to dig for:
1. Where's an example this has been used professionally? (or out side an academic setting) I'm pretty risk adverse since FW/embedded systems are harder to OTA, and changes once we've approved the HW design blows up projects. If it hasn't been, be upfront about it.
2. What's the plan for the project? Is the language stable? Is a standard library next? I use a vendors language/BSP to avoid writing everything little thing from scratch, like printf()
3. Give me a comparison to other languages, why should I use T1 over any other embedded solution. Include size, and maybe the performance hit.
4. Show me some code. If I'm picking this for a project I need to think of everyone else I need to teach the language too, and how they'll accept it. It really helps for a quick glimpse at the syntax to see how foreign it is. Even if it's just Hello World.
5. How do I access peripherals/HW? For example if I need flash/nvram persistent storage, access to the serial port am I back to C to write driver or interface to the BSP? If so I now need good C skills, T1 skills and good binding skills.
Thanks for everyone for the slides, reading the hacker comments pretty much answered 1-5:
From https://github.com/t1lang/t1lang.github.io/blob/master/North... slides, are telling for the language analysis to see why they think it's necessary to develop this:
- Only with TinyGo*
- Limited language/runtime support*
- "support for goroutines and channels is weak"
- Maps can ony have up to 8 (eight!) entries
- GC: only for ARM, other platforms "will just allocate memory without ever freeing it" (but GC is required for proper string management)
- Inherits all memory-safety features of Rust
- Heap is optional
- But without the heap, everything is allocated on the stack
- Supports ARM Cortex-M and Cortex-R, RISCV, and MSP430 (experimental)
- Not other architectures that LLVM does not support
- Typically more stack-hungry than C
- Lots of automatic magic
- Many incompatible implementations
- It's more a concept than a language (there is an ANSI standard)
- You are support to "write your own Forth"
- Very compact, with low RAM usage
- Even less safe than C and not portable
btw, on the magic bit the T1 design does go on to talk about Generics support and a rich type system.
Edit: this comment sounds too negative, and that wasn't really my intent. I just wanted to better understand some of the considerations that were used in deciding to make this new language.
- No automatic magic, anything that looks like a function or memory allocation is, anything that doesn't, isnt.
- Good compile time code generation capabilities including reflection, much nicer than C macros.
- Runtime safety features, such as bounds checking, but not as intrusive as Rust's borrow checker (which makes less sense for single threaded embedded applications). These can be turned off in release builds.
- Very good C interop for use with manufacturer HAL libraries etc, includes a C compiler.
- Better error handling than C, without needing full exceptions, instead the "try" and "defer" macros nicely replace C's "goto" for error handling.
- No garbage collection
- Embedded is a first class target, unlike Go/TinyGo
- Working async support on all platforms.
- Sadly not as popular as others, one full time developer currently I think.
also I figured out how to have safe recursion, taking advantage of the stackless coroutines: https://github.com/ziglang/zig/issues/1006
this is relatively straightforward to solve in a non-llvm backend. The LLVM abstraction gets leaky fast when you try to tackle this problem.
There is a tool in rust I just found that makes LLVM emit this information for rust code, but it stores it within the .stack_sizes section in the emitted .elf instead. Possibly a similar trick could be added to Zig
Zig is a very simple language. Its strength is not in the features it has, but in the features it lacks. Also, Zig encourages stricter control over allocation than Rust, and it's C interop is virtually seamless.
Zig is very young and may well end up disappointing, but its careful selection of features that provide what seems to me to be a great combination of power and simplicity (a single feature represented by a single keyword does the work of generics, value templates, constexprs and macros, all without the complications macros introduce). Anyway, I find it to be a very interesting take on what modern low-level programming can be.
This is a false and inflammatory statement, and unhelpful. It's more complex than C, but has very different set of features and type capabilities from C++ that makes it far simpler. Even for C, I would say it really is a different set of complexity. Rust brings that complexity to the fore-front, whereas C and C++ both have a significant amount of hidden complexity.
> It appeals to those who already like C++
Perhaps, but I absolutely abhor C++ (after years of working with it) and completely love Rust, so :shrug:
> Zig is a very simple language
It is. It also doesn't make many of the same safety guarantees as Rust. So there are trade-offs.
> I find it to be a very interesting take on what modern low-level programming can be.
As do I! Though, I do think people keep looking for greener fields unnecessarily.
It's complex enough that we don't have a formal model of the full language, which is definitely an issue. Traits are perhaps the most complex feature (ignoring things like macros, etc.) and they've caused quite a few unsoundness problems in the past.
I think it's neither false nor inflammatory, but a neutral, objective observation. I think that if you asked people what languages in more-or-less regular use are about as complex as Rust (or more), they'll give you a very short list (I can think of no more than three: C++, Ada and Scala). That does not make it bad or unsuitable -- in fact, it might well be great for some -- but it does make it less attractive to those who value language simplicity.
> It also doesn't make many of the same safety guarantees as Rust. So there are trade-offs.
Sure, and if a low-level programmer's primary goal is to write software that's free of certain technical bugs that correspond to C's undefined behavior, then a language that can more-or-less guarantee they don't exist (with some caveats) may be the best way to achieve that. But I don't think that is most people's primary goal. Even for those who value correctness in high-assurance domains, the elimination of undefined behavior, which always comes at a cost, is not necessarily the best way of achieving correctness. Zig, too, puts an emphasis on writing safe code, it just goes about it a different way than ensuring certain guarantees, soundly, in the language itself.
Now, let me take this opportunity to also explain why it's uncertain that Rust's approach to correctness is the better one. I saw some report from Microsoft that 70% of their security bugs are due to undefined behavior in C++. Let's assume that all UBs are equally to blame, we'll assume that reducing security bugs is the only thing we care about, and we'll assume that Rust completely eliminates all UB (which isn't necessarily true because of unsafe and because there could be bugs in Rust and/or LLVM, but I'm willing to accept that Rust's approach is the best at eliminating UB). By choosing Rust and developing the software at cost X (it doesn't matter for now whether X is smaller or greater than the cost of developing in C++) we eliminate at 70% of security bugs. Now, there can certainly be a different approach that doesn't eliminate all UB and still reduces security bugs by more than 80%. I'm not saying we know for what that approach is, but what I am saying is that it is not at all certain -- it has neither been justified theoretically nor confirmed empirically -- that soundly eliminating all UB, which comes at some cost, is the best approach of reducing those bugs.
I, for one, believe that Zig's approach -- of language simplicity plus some strong safety features -- is a better approach to correctness than Rust's. I don't know that, I just believe that, but those who believe that Rust's approach to safety is better don't have stronger grounds to stand on.
So Zig does not trade off correctness; it trades of the sound guarantee for lack of UB, which isn't a goal in an of itself. It's a means to achieving some goal, and some may believe it's the best means, but there is so far little evidence to suggest that it is. Yeah, Rust is better than Zig at eliminating UB, but that doesn't mean it's better at correctness. It could well be worse.
> Perhaps, but I absolutely abhor C++ (after years of working with it) and completely love Rust, so :shrug:
Rust is an improvement over C++, but C++ isn't a hit in embedded development, either.
> I do think people keep looking for greener fields unnecessarily.
Why unnecessarily? You don't like C++ but found what you want in Rust; I'm not crazy about C++, either, but Rust doesn't even begin to solve my main problems with C++ (a "better C++" is not what I need), so why is my hope for greener fields less necessary than yours?
I would be happy if people gradually shifted from C++ to Rust -- at least we'll have fewer UBs -- but I don't think it will ultimately make a big change in low-level programming; maybe in some sub-niches of it.
I think Rust's emphasis on sound safety guarantees came at a cost elsewhere, and that cost is too heavy for some. Some like it, some prefer a different approach. I have no problem with people who like Rust, and they shouldn't have a problem with those who don't. Anyway, you asked why some might not see Rust as the answer to their wishes, and I answered.
I think we're going to disagree on that take, but you're not wrong that in terms of language syntax, it's often compared to C++.
> Why unnecessarily?
You're correct, much of this is personal taste and preference, "unnecessarily" is probably the wrong word I was reaching for. But there are many who quickly move on from languages at even the slightest discomfort.
> you asked why some might not see Rust as the answer to their wishes, and I answered.
Yes, I did. I'm trying to understand the difference between language features and capabilities vs. language preferences and personal taste.
It is of course valid to state that one language isn't to your taste, but I often see that interlaced with statements that imply that the language isn't capable because of those personal tastes.
It's the features and capabilities I'm more interested in, less the personal preference.
BTW, I'm not disappointed with Rust for some "slight discomfort," but because it doesn't even begin to address my main discomfort with C++. Rust isn't my cup-of-tea for the same reason C++ isn't (and I program C++ all day, every day).
The original post lists rust as having a lot of "hidden magic", which zig explicitly states it does not have. I am unsure how much Rust actually has of this tbh.
Also, are you sure Rust has "a C compiler built in?" If I look at the official guide, it recommends compiling your C code to a static library, though there are crates to add this to the build process. Rust requires bindings to be generated too, which can be automated , but in Zig it just requires including the header file and optionally converting the error codes into proper errors, no extra packages.
Finally, I don't rule out Rust as an option, especially due to its much higher popularity, mindshare and hence ecosystem. But I think a comparison is interesting when discussing other languages for embedded development.
Memory safety, safety from reference invalidation, async etc. etc. There are lots of reasons to care about the Rust featureset even in single-threaded code.
It depends on how you look at it I guess. Rust can represent C FFI directly in the language and has many great tools for incorporating C into the language elegantly, like bindgen, which you allude to. I'm not sure I would call this a gap having worked with incorporating Rust into C projects and also C into Rust projects.
Doesn't the MIT license require that it be reproduced with all derivative works, including the copyright line (which includes the author)?
BTW, that requirement is the reason why Boost, 1-clause BSD and 0BSD licenses are a thing.
> If the waiver isn’t effective for any reason, then CC0 acts as a license from the affirmer granting the public an unconditional, irrevocable, non exclusive, royalty free license to use the work for any purpose.
Example code: https://bearssl.org/gitweb/?p=BearSSL;a=blob;f=src/x509/asn1...
The slides are also much more educative: https://t1lang.github.io/NorthSec-20190516.pdf
Every interview of Chuck Moore that I've read has contained zero push-back for his rather wild claims. It's entirely possible for an industry to do go down the wrong path for a while, but at some point, if Forth and stack processing were the giant killers they were cracked up to be, you would see them enter and dominate at least some portion of the mainstream. You can't say they haven't been given enough time.
It seems there are many "Forth curious" programmers out there, but they aren't being given the full picture with the various puff pieces and vanity projects floating around that never really go anywhere. It's almost a culture of victimhood.
As an aside, there is probably a different argument to had about whether a stack-based VM as the mental model of a language is beneficial, but as a said, that is a vary different argument than discussing the technical ability to transpire a stack-based VM to a register-based one.
 ‘Virtual Machine Showdown: Stack Versus Registers’. Ertl, Gregg, et al. 2005. https://www.usenix.org/legacy/events%2Fvee05%2Ffull_papers/p...
 ‘Implementation of Stack-Based Languages on Register Machines‘. Ertl, Dissertation. 1996.
I still don't get the positives of why the programmer should be presented with a stack machine SW model when there is no stack machine type stack to be found in the HW. Programmers with no stack machine / language experience probably think (as I did at one point): "the stack on my HP calculator stack works great, why not base a language on that?" but it scales poorly, it gets really hairy if the stack is the only place to store things, and it's a major headache keeping the stack from going out of sync (hence Forth's clear I/O comments regarding subroutine stack use).
Correction aside, I, at some level, agree with you. The question of appropriateness/benefits of a SM model is different than considerations of the effectiveness of the code. In terms of the Forth SM model and its explicitly imperative model, I am familiar with the various complaints/arguments/critiques for varying reasons. I certainly acknowledge there is at least some burden placed due to the stack mechanics. I happen to be particularly attracted to the approach and enjoy programming that way, but that is just a preference of mine. However, I also tend to look at Forth as imperative language with which to program in what Backus describes as ‘function level programming.’ I find the benefits as listed by Jon Purdy, author of the Kitten language, in his talk about concatenative code to be compelling enough that exploration and refinement of this idea space to be valuable.
All that said, I am perfectly willing to consider that, as presented in Forth and presumably in the proposed language, SM mechanics and models are a hurdle for users of the language.
Forth makes more sense when you can be like Chuck and design your own hardware. At that point Forth is more of a minimalist stack-based philosophy that consists of the minimal hardware + software design to accomplish something.
Is his way better? It likely has somewhere near the bare possible code and is very efficient system wise. If you wanted a minimal solution and could devote years to the project, then this is nice.
Does it make the best usage of developer time? Obviously not in many cases. In today's business world, you just slap some components together, do minimal acceptable testing, push it out and go to the next thing. Cost is important to the customer, so as long as somebody is willing to do that kind of work, everyone has to. Of course the downside is that we've accreted all this tower of abstractions and complexity going from OS to JVM to libraries and source. We already have tons of COBOL that can barely be maintained. Next will be the large Java and Python codebases.
I actually have designed my own FPGA soft core barrel processor, it's a special blend of register and stack machine. The blend occurs by placing stacks under the registers themselves. I believe this allows a low register count, 2 operand architecture to be more efficient than it otherwise would be, which minimizes opcode size, and sidesteps most the crazy you get when trying to shoehorn most processes into a single stack environment.
But has clear downsides as well, the main one being the stacks can become easily corrupted by any process using them - this is true of any stack machine but you strangely never hear it come up in conversations with Forth types. Stack processors can eliminate much traditional processor state, but the stacks themselves contain state, which is often overlooked.
Moore is an incredible salesman, I'll give him that.
Also, the chips he made before GA were 32-bit. He deemed it unnecessary, and the GA chips run miles around them.
32 bits are unnecessary?!? I suppose a 18 bit machine would run a lot "faster" than a 32 bit machine given certain data sets and loads, but I wouldn't want to do any audio DSP with it.
Entire computers? What decade is it again?
A core and a computer aren't the same, and while Intel processors have multiple cores, sometimes many, they don't have multiple computers within.
COMPLETE SYSTEMS: We refer to our chips as Multi-Computer Systems because they are, in fact, complete systems. Supply one of our chips with power and a reset signal, and it is up and running. All of our chips can load their software at high speed using a single wire that can be daisy chained for multiple chips; if desired, most can be bootstrapped by a simple SPI flash memory. Application software can be manufactured into a custom chip for a modest cost to further simplify overall system design. External memory is not required to run application software, but our larger chips have sufficient I/O to directly control external memory devices if desired.
Contrast this with a Multi-Core CPU, which is not a computing system until other devices such as crystals, memory controllers, memories, and bus controllers have been added. All of these things consume energy, occupy space, cost money, add complexity, and create bottlenecks. Most multi-core CPUs are designed to speed up conventional operating systems, which typically have hundreds or thousands of concurrent processes, by letting a handful of process execute in parallel as opposed to only one. They are not, typically, designed for significantly parallel processing, and they are even less well suited for simple applications than are their less expensive single-core progenitors.
It's meant for hyper-parallel applications, unlike Pentium cores.
"Postfix source code can be readily serialized into an executable format running on threaded code, a
well-known code generation method that can allow for a very small compiled code footprint"
What's that method?
What files? This will run on top of an operating system? Why bother with a new language then.
A very cheap way to add storage to low volume productions is to add a microSD card. At that point it’s easier to go for something like FAT and work with that
I sure have never seen that