News for hackers. Stuff that matters.
Re:The Odin Programming Language by jitl on Friday January 31, 2020 @01:06PM (#22203861)
Odin seems rather similar to Zig: https://ziglang.org/

It would be interesting to hear from anyone who has spent time in both about the differences in experience.

It’s a trend of “Better C than C” languages that don’t go as far as Rust or C++ in terms of either complexity (or safety) but are more opinionated and modern than C. I think Nim can squeeze into this category, too, but maybe not? Nim is confusing to me.

Jon Blow is also working on one of these, but it isn’t released yet: https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md

Re:The Odin Programming Language by Gene_Parmesan on Friday January 31, 2020 @02:37PM (#22204821)
You can add Beef to that list: https://www.beeflang.org/

I've actually enjoyed playing around with Beef, the dev basically took C++ and gave it the syntax and core library design of C#. Here's a page from the guide just to give an example of the look and feel: https://www.beeflang.org/docs/language-guide/memory/

Note that despite the appearance, there's no GC, no ref-counting, explicit manual memory management, and so on.

Re:The Odin Programming Language by rafaelvasco on Friday January 31, 2020 @04:16PM (#22205830)
This is one of the languages I've liked the most, though I may be biased since I love C#; Beef is actually made by a legendary PopCap developer ;) Loved popcap back in the day. PopCap Framework, HGE Game Engine etc. Good times;
Re:The Odin Programming Language by totalperspectiv on Friday January 31, 2020 @02:57PM (#22205004)
I hadn't seen Beef before. Is it 'as fast as C'? The docs look nice.
Re:The Odin Programming Language by Gene_Parmesan on Friday January 31, 2020 @03:22PM (#22205256)
I can't speak to whether it's literally as fast as compiled C code. I imagine that there will be common uses cases where it's very slightly less efficient due to its support for things like dynamic dispatch; but I don't see any reason in my brief experience with it why it couldn't at least be as fast as equivalent C++ code. It uses LLVM for its backend.

One of my favorite things about it is the way it handles memory during debug runs. (My #1 favorite thing is that it was all developed by one guy working solo - Brian Fiete, a cofounder of PopCap Games.) First, it's able to trace allocated memory during debug execution and immediately report on memory leaks, along with the location in code where the leaked memory was allocated. Second, it can guard against use-after-frees in debug by marking the memory freed, but not actually reclaiming it. Any subsequent writes/reads to that location will immediately fail with the object's allocation stack trace.

Both of these are turned off during normal builds but seem to be excellent debugging tools.

The IDE is also cool and was developed in conjunction with the language. It's not the most feature-rich application and there are some bugs as you'd expect, but it's a perfect example of dogfooding as it was written in Beef. Hot code reloading is also supported.

Note that I have zero connection with this language, other than that I really enjoy it so far, and that I reported a minor issue that is probably very specific to me and me alone, and Brian replied to me personally and we had a pleasant brief exchange.

Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @06:13PM (#22206949)
Odin can achieve the same feature of checking memory leaks with it's custom allocator system. You can very easily have a custom allocator track the allocations of everything, including its source location. This is because Odin was heavily designed around custom allocators as a core feature.

And coupled with the implicit `context` system, it can very easily profile third party Odin code's allocations too!

Re:The Odin Programming Language by beefdev on Friday January 31, 2020 @06:45PM (#22207182)
BeefLang will report leaks as they occur, not when the program shuts down. There's a tracing "GC" in debug mode for detecting unreachable memory in realtime. It's also used for reliably detecting use-after-free since memory is held when there are references and released when the last reference goes away -- again, a debug-only feature.
Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @06:57PM (#22207260)
This is totally possible with custom allocators in Odin too. You'll be surprised by how much custom allocators can do, but so many people know little about them.
Re:The Odin Programming Language by omaranto on Friday January 31, 2020 @10:19PM (#22208418)
Am I understanding correctly that in Odin feature could even be provided by a third party library implementing such a custom collector? If so, that's seriously cool.
Re:The Odin Programming Language by beefdev on Friday January 31, 2020 @03:52PM (#22205590)
Thanks for the mention, Gene. Thanks for being an early adopter, and keep those bugs and feedback coming in!

As far as performance vs C - there's not a lot of features that incur dynamic dispatch: virtual method calls, dynamic casts (as/is keywords), and direct interface dispatch. When you use interfaces as generic constraints, those monomorph into static dispatches unless the implementing method itself is virtual.

For C-style code, however, the performance should be the same as the C equivalent in Clang. File a bug if it isn't!

Re:The Odin Programming Language by UncleMeat on Friday January 31, 2020 @06:48PM (#22207205)
> One of my favorite things about it is the way it handles memory during debug runs. (My #1 favorite thing is that it was all developed by one guy working solo - Brian Fiete, a cofounder of PopCap Games.) First, it's able to trace allocated memory during debug execution and immediately report on memory leaks, along with the location in code where the leaked memory was allocated. Second, it can guard against use-after-frees in debug by marking the memory freed, but not actually reclaiming it. Any subsequent writes/reads to that location will immediately fail with the object's allocation stack trace.

Existing C++ tooling (sanitizers) achieve this too.

Re:The Odin Programming Language by tomcam on Friday January 31, 2020 @05:00PM (#22206314)
It’s also cross platform as hell. Amazing at this stage of development.
Re:The Odin Programming Language by AndyKelley on Friday January 31, 2020 @01:19PM (#22203978)
I had the pleasure of meeting gingerBill at Handmade Seattle:

https://mobile.twitter.com/odinlang/status/11957620628419379...

It was really fun to hang out and talk shop

Re:The Odin Programming Language by abnercoimbre on Friday January 31, 2020 @04:30PM (#22205997)
I'm making it a point to generally have independent compiler authors at Handmade Seattle. You two were class acts -- thanks for attending!
Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @04:34PM (#22206040)
Thank you for inviting us! It was a brilliant event, and thank you for all your hard work.
Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @01:27PM (#22204068)
It was a pleasure meeting you too, Andy.
Re:The Odin Programming Language by rehemiau on Friday January 31, 2020 @01:34PM (#22204143)
Jonathan Blow's language is the most interesting from these three for me because it will have nice metaprogramming features. The document you linked to seems slightly outdated. One of the beta testers has published some more up to date videos with his language introduction and initial experience: https://youtube.com/watch?v=i1vbvikDiI8&index=1&list=PLhEuCy...
Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @03:38PM (#22205425)
Personally, I agree with Jon in that he is not too bothered about being the "winner" with regarding to his language. He wants a tool that can help him actually solve problems he has. And he wants to make sure that his tool is good before releasing it to the public. Releasing a product before it is done is can of worms in itself, not to mention the problems related to open source software itself. So it is entirely respectable for why Jon has not been as opened up his language to the public yet.

I created Odin for the very same reason that I wanted a tool that made me more productive and helped me solve the problems that I actually have. Even if Odin only benefited myself, I would class that as a success, but it has been helping so many people create amazing things.

Re:The Odin Programming Language by andyroid on Saturday February 01, 2020 @12:54AM (#22208973)
> Releasing a product before it is done is can of worms in itself

Perhaps, but a programming language which is released when “done” is essentially dead on arrival. I’d guess the people who created amazing things with Odin helped the language move forward, right? Nothing wrong with keeping something to oneself, but promising for a long time to move something into an open source model with no set date.. I’ve rarely seen that end well. Hope I’m proved wrong though!

Re:The Odin Programming Language by 7thaccount on Friday January 31, 2020 @07:25PM (#22207442)
Is there a link to success stories?
Re:The Odin Programming Language by rishav_sharan on Friday January 31, 2020 @02:21PM (#22204657)
well Jai is probably the least interesting language for me as the others actually exist. When Jai ever gets released, only then I can see all its warts and glories.
Re:The Odin Programming Language by jjuel on Friday January 31, 2020 @03:01PM (#22205041)
I mean it obviously exists. He livestreams coding on the language and in the language. Sure very few people can actually use it right now, but existence is not in question.
Re:The Odin Programming Language by siver_john on Friday January 31, 2020 @03:08PM (#22205099)
But existing for someone else, and existing where I can use it are two different things. I'm sure there are lots of cool tools and things that exist at big companies like Google (or more interestingly say the NSA) but for all my intents and purposes they don't because I can't interact with them.

A reverse corollary to Russell's Teapot? So what if there is a teapot orbiting Jupiter, I can't get it so it allows me no ability to serve tea. Therefore it might as well not exist!

Re:The Odin Programming Language by boardwaalk on Friday January 31, 2020 @04:58PM (#22206290)
Respectfully speaking, I don't think we need to get anywhere near some weird "reality is relative" argument here.

Just say it's not useful to you because you can't use it. No need to say it doesn't exist, even if it just doesn't exist "for you."

(As an aside, I think a lot of societal problems in the world today have roots in relativism and such -- so it's a bit of a bugbear.)

Re:The Odin Programming Language by siver_john on Friday January 31, 2020 @05:28PM (#22206574)
I understand that. However my comment was just a statement that the existence the person above me was implying was useful existence. As in we can all be excited about this new tool, or game, or whatever, but if we never get to use it, its usefulness is moot. So while the language certainly exists we can observe him working on it, and he could even create a game using it that would have some societal impact, the current usefulness of the language to anyone except him is as if it did not exist at all.

Of course you could make the argument that its mere existence and him highlighting certain aspects could have influences on other language designers... and wow am I going down a tangent spiral now...

Anyways: TL;DR reality is objective but words can have complex semantics

Re:The Odin Programming Language by AnIdiotOnTheNet on Friday January 31, 2020 @03:14PM (#22205159)
But that's a big deterrent for a lot of people. Odin, Zig, and the like are languages that can be used right now. Yeah, they're not mature yet, but you don't have to wonder what it is like to program in them, and you can start building familiarity with them today.
Re:The Odin Programming Language by beagle3 on Friday January 31, 2020 @02:28PM (#22204727)
It’s been a while since I was following Jai descriptions, but IIRC, Nim exists today and has all the meta programming features Jai is supposed to - and to a large extent so does D.
Re:The Odin Programming Language by Cyph0n on Friday January 31, 2020 @04:28PM (#22205969)
Jai has no GC though, which is critical in game dev.
Re:The Odin Programming Language by shakna on Friday January 31, 2020 @07:20PM (#22207417)

    nimc --gc:none
Nim has 5 GCs to choose from, as well as being able to have none at all.
Re:The Odin Programming Language by jug on Saturday February 01, 2020 @03:17AM (#22209405)
The GC can also run incrementally to meet deadlines. It’s not like a Java GC. It has been used in microcontrollers. People should probably learn more about it before shooting it down based on the word GC.
Re:The Odin Programming Language by pjmlp on Saturday February 01, 2020 @02:48PM (#22212770)
Java GC also has been used in microcontrollers, with soft real time deadlines, there are plenty of JVM vendors out there, including a couple that are only focused on embedded development like PTC, Aicas, Gemalto, microEJ, Virtenio.
Re:The Odin Programming Language by Cyph0n on Friday January 31, 2020 @09:00PM (#22208024)
That’s great, but can you use the Nim stdlib with no GC?
Re:The Odin Programming Language by beagle3 on Saturday February 01, 2020 @03:52AM (#22209511)
Yes, with some relatively minor caveats, mostly having to release memory yourself.

Also, the arc/orc GC is shaping up and already allows you to use exclusively reference counted memory management - so, efficient and perfectly deterministic timing but still get automatic memory management. (As usual, if you introduce cycles, it becomes more complicated)

And the Nim compiler elides many ref/unref ops, as well as keeping objects thread-local, so most performance objections to ref counting don’t actually apply. (.... and you have a choice of other automatic GC modes, including “none”)

Re:The Odin Programming Language by Cyph0n on Saturday February 01, 2020 @12:46PM (#22211854)
Good to know. Thanks for the explanation.
Re:The Odin Programming Language by shakna on Saturday February 01, 2020 @03:31AM (#22209453)
Yes, but you'll need to call dealloc [0] on the result of any call, unless you want to leak memory.

[0] https://nim-lang.org/docs/system.html#dealloc%2Cpointer

Re:The Odin Programming Language by renox on Saturday February 01, 2020 @04:31AM (#22209626)
And D has the DasBetterC mode, but I'm not sure that's good enough: when the language has a GC by default, all the libraries use it, the APIs relies on it..

What good is a language if you can't (easily) use its libraries?

Re:The Odin Programming Language by beagle3 on Saturday February 01, 2020 @04:45AM (#22209664)
Nim’s relationship with GC is very different than any other language that I’ve used.

It has very different selectable GC systems - Boehm, Bacon/Dingle, reference counting, or real-time deadline mark-and-sweep, and “none”. Perhaps I forgot one. Some libraries rely on a specific GC behavior but most work with any (with the caveat that “none” requires you to manually deal with garbage).

Nim’s mark-and-sweep is suitable for embedded systems and games, unlike Java’s, and so is the ref counting one; but even if none of the GCs work for you, the fact that there’s many of them and they are mostly interchangeable means that the dependency on them is much, much weaker than you are used to (although it still exists)

Re:The Odin Programming Language by pjmlp on Saturday February 01, 2020 @02:50PM (#22212777)
Just like Java actually, each implementation has its own set of algorithms including none.
Re:The Odin Programming Language by nimmer on Tuesday February 04, 2020 @12:43PM (#22238517)
You can use Nim in games using deterministic, real-time GC. Also, the new ARC memory management will replace GC https://forum.nim-lang.org/t/5734
Re:The Odin Programming Language by olah_1 on Friday January 31, 2020 @02:28PM (#22204724)
I like Jai's `use` keyword.

Fun fact: Odin has this exact same thing with `using`. https://odin-lang.org/docs/overview/#using-statement

Re:The Odin Programming Language by hota_mazi on Friday January 31, 2020 @07:01PM (#22207294)
Kotlin also has it as "apply":

    Windows().apply {
      width = 100
      height = 200
    }
Now, I can't help but see the following kind of code:

    val someStructure = ...
    someStructure.x = ...
    someStructure.y = ...
    someStructure.name = ...
as an immediate language code smell
Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @07:04PM (#22207313)
Odin's `using` comes from Pascal's `with`, of which was block based. Odin's `using` can be applied to a load more than just scopes:

https://odin-lang.org/docs/overview/#using-statement

Re:The Odin Programming Language by hota_mazi on Friday January 31, 2020 @07:10PM (#22207354)
Yes, the general idea is not new but the devil is in the details.

As far as I can tell, Odin's `using` is applicable in the same areas as Kotlin's, but I still favor Kotlin's scoped version. When I see "using foo;" in Odin, it's not quite obvious to me where the scope of applicability is.

Any reason why you didn't do something like

    entity.use {
      // "this" is now the entity instance
    }
    // back to your regular "this"

?
Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @07:18PM (#22207407)
You can easily do the same in Odin, if you would like. However, `using` works for a lot more than that just this. `using` allows for many for type system features beyond a basic scope import like Pascal's with. `using` can be applied to procedure parameters, struct field declarations allow for subtype polymorphism (even of pointers), scope imports, and more.

Koltin's approach is limited to purely the same Pascal's `with` allowed.

But if you want to be clear:

    { using entity;
        // the fields of "entity" are not usable in this scope 
        x = 123;
    }
    entity.x = 123;
Re:The Odin Programming Language by gingerBill on Saturday February 01, 2020 @04:50AM (#22209677)
* are now usable typo
Re:The Odin Programming Language by WalterBright on Friday January 31, 2020 @09:34PM (#22208209)
> Better C than C

The D programming language can be used as a better C:

https://dlang.org/spec/betterc.html

and only requires the C runtime library to link to.

Re:The Odin Programming Language by GavinMcG on Friday January 31, 2020 @01:22PM (#22204009)
Not to go too far afield, but I agree that Nim is in that category and I'm curious what parts of it are confusing to you.
Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @01:37PM (#22204183)
Nim is a cool language but it does have a lot of things about it by default where it is not targeting itself as being a C alternative, such as garbage collection (by default).

Nim is also a very complex language with numerous features to it making it a lot more complicated compared to C. So for someone who might like C might not like Nim. However, I recommend everyone try out as many languages to see what they like.

Being that I am the Odin creator, I do think you should give Odin a go because it is much more focused on being a C alternative and tackling the kinds of problems it solves.

Re:The Odin Programming Language by Touche on Friday January 31, 2020 @02:28PM (#22204731)
I really like Nim but GC makes it a nonstarter for embedded devices. So to me Nim is in the same category as Go.
Re:The Odin Programming Language by ezquerra on Friday January 31, 2020 @02:57PM (#22205000)
The nim team is currently working on removing the garbage collector by means of a new reference counting based “garbage collector mode” called “arc” (for automatic reference counting). You can get more info in the following link, where it is described as “plain old reference counting with optimizations thanks to move semantics”:

https://forum.nim-lang.org/t/5734

The objective is to make nim suitable for embedded programming and other use cases for which garbage collection is a non starter. This new —gc:arc mode is already available in the nightly builds and the benchmarks are already impressive. I believe that the plan is to make arc the default “garbage collector mode” in nim 1.2.

Re:The Odin Programming Language by gingerBill on Friday January 31, 2020 @03:43PM (#22205480)
One of the issues with Nim is that ARC is still a form of automatic memory management, of which many domains do not want. This is why Odin has been designed to take advantage of custom allocators so that programmers have a huge control of how memory is allocated at all levels. And coupled with the `context` system, you can also have control over and track third-party code in how it allocates things.

Custom allocators are a pleasure to use, and allow for so much control. Along with the temporary allocator, you can make Odin feel like it's a dynamic language whilst being extremely fast. Custom allocators are an under-utilitized thing in programming in general, and I hope more people release what is possible with them that is not possible with automatic memory management schemes.

Re:The Odin Programming Language by gavinray on Friday January 31, 2020 @03:56PM (#22205629)
Hey, I am going to show my stupidity for a moment but I have to ask:

Why is garbage collection considered a negative thing?

I have no experience programming low-level languages, but I do follow and try new/obscure languages for fun.

Zig, Nim and V were the few I found + tried first, but I learned about Odin and Scopes recently and found them both interesting.

Re:The Odin Programming Language by danbolt on Friday January 31, 2020 @06:39PM (#22207140)
I write C++ for video games, and garbage collection is often shunned in performance-critical systems since it's often nondeterministic and GC pauses can become too long. I think garbage collection could work in games, but it's commonly implemented for use cases that are not video games (eg: servers, desktop applications, etc.)

A programmer writing managed C# in an engine like Unity will often spend a lot of programming time ensuring that the code will not allocate every frame, as the additions to the heap will eventually trigger a pause.

That said, every game and its requirements are different, and some game development might not mind that as much. A C++ engine programmer on a Nintendo Switch is in a very different situation than a hobbyist in JavaScript or a server backend programmer on a mobile game.

Re:The Odin Programming Language by pjmlp on Saturday February 01, 2020 @03:29AM (#22209445)
Just like doing virtual calls or using OS memory allocator used to be shunned by early C++ adopters on the game industry.

I still remember when doing games in Basic/Pascal/C was considered to be like Unity nowadays, real games had to be written in Assembly.

As you say, every game and its requirements are different, and many 8/16 bit games were perfectly doable in C, Pascal, Basic and eventually the community moved along, just like it happened with C vs C++ a couple of years later.

I see the use of GC enabled languages the same way, and C# belongs to those languages that also offer other means of memory allocation, not everything needs to live on the GC heap.

Re:The Odin Programming Language by danbolt on Saturday February 01, 2020 @03:02PM (#22212855)
I think you’re absolutely right here. The reason people often dismiss garbage collection in game programming is the pauses, but if the pauses aren’t noticeable then the reason to dismiss goes away. Computer performance gains over time can totally help dismiss that, much akin to virtual calls or default allocators. The writing on the wall was there after games like Minecraft became a huge hit.
Re:The Odin Programming Language by billforsternz on Friday January 31, 2020 @04:40PM (#22206083)
Garbage collection is not so much considered a negative thing, but a thing that's inappropriate for the embedded domain. The problem is that garbage collection entails some system code periodically scanning lists of memory allocations to identify stuff that's now garbage that can be recycled. Embedded Devs worry about the scheduling of that code, and how long it could take to run worst case, and whether it will spoil their real time guarantees. There are various mitigation strategies, but for good or evil many individuals and organisations apply a simple "no, we're not going to use GC ever" policy.
Re:The Odin Programming Language by gavinray on Friday January 31, 2020 @07:31PM (#22207485)
@danbolt @billforsternz

Thank you guys for the response, super appreciate it.

I guess, I can understand from an abstract perspective that you can manually tune performance and optimize to a higher degree if you can control memory allocation yourself.

And for a lot of purposes where performance is imperative, like games or embedded devices it can make or break the ability of software to function properly.

But my question then is, if languages like Crystal, Nim, or D (or any other GC lang with similar speed) can operate either at/near the performance of C, why exactly do you need manual memory management?

And if you do need it, I assume many languages that cater to this audience provide some sort of symbolic annotation that allow you to manually control GC where you feel you need it, aye?

Re:The Odin Programming Language by scott00 on Friday January 31, 2020 @11:43PM (#22208725)
I think you are correct in your basic assertion that no one wants manual memory management for its own sake. What they really want is sufficient performance for their use case. The benchmarks you usually see are throughput oriented, and on small heaps. If you have tight latency budgets and/or huge heaps, the performance is not close.

Optional manual memory management sounds great, but I'm skeptical it would work well in practice. The reason is that if the language default is GC, libraries won't be designed for manual memory management, meaning it will be hard for your manual code to interact with data structures created by non-manual parts.

Re:The Odin Programming Language by dotbmp on Friday January 31, 2020 @07:51PM (#22207646)
"Near C" performance is often not good enough, and usually misleading. You can write poorly performing applications in C, and certain benchmarks may favor or disfavor certain elements of a language. Generally they're created to be "similarly written" in all benchmarked languages, which may seem like the fairest comparison at face value. But what that means is that they are often naively written in one or more of the languages. Expertly written, hand-tailored-to-the-problem-domain C code is almost always going to outperform other languages by a significant margin, especially languages without manual memory management. You can do things in C like use arena allocators to significantly reduce memory performance overhead - things which require low-level control and a non-naive understanding of the problem domain. Garbage collectors can be quite performant, but they aren't capable of this kind of insight. Code that is written in C similarly to a garbage collected language will be similarly naive (another malloc call for each and every allocated thing, versus allocating out of an arena, for instance).
Re:The Odin Programming Language by billforsternz on Friday January 31, 2020 @11:36PM (#22208701)
As I said, mitigation strategies exist, including manual control of GC etc. It's not true that using GC is universally impossible in embedded / real-time situations. It is true that it can cause performance and non-determinism issues (which are potentially solvable), and it's also true that some developers avoid GC so they don't have to deal with those potential issues. They would prefer to deal with the issues associated with manual memory management.

Who's to say who's right and who's wrong? Ultimately life (and the subset of life that is software development) is a massively complex strategy and tactics game with a myriad of possible playing strategies and no agreed perfect solution.

Re:The Odin Programming Language by Reelin on Saturday February 01, 2020 @01:23AM (#22209059)
> if languages like ... can operate either at/near the performance of C

That depends entirely on how you define and measure performance. If total throughput is your metric, then it's no problem - for example, Go is perfectly acceptable for web services.

Predictability of latency, however, is absolutely _not_ on par with C code. For example, 3D rendering with a GC can easily result in perceptible stuttering if care isn't taken to minimize allocations and manually trigger the GC at appropriate times.

> some sort of symbolic annotation that allow you to manually control GC

It's not that simple. D tried to sell this at one point, but it just doesn't work for large multithreaded programs and things aren't single threaded these days. Manually controlling a global GC means manually balancing, for example, one block of threads that perform lots of allocations and deallocations (and will starve if the GC doesn't run regularly) with soft real time networking code and hard real time VR rendering code. And (for example) you certainly don't want your rendering loop pausing to scan the _entire heap_ (likely multiple gigabytes) on each frame! Alternatively, in the case of Go (and depending on your particular workload) you might not appreciate the concurrent GC constantly trashing the caches.

Custom allocators and non-atomic reference counting are fantastic though.

Re:The Odin Programming Language by pjmlp on Saturday February 01, 2020 @03:23AM (#22209429)
Religon against GC and cargo cult.

Several companies have been selling Java, Oberon and now Go runtimes targeted to bare metal deployment on embedded scenarios.

Some of them are more than 20 years old, so apparently they might have one or two customers keeping them alive.

The hate against GC feels like the hate against high level languages on 8 and 16 bit platforms back in the day, because anyone doing "serious" stuff naturally could only consider Assembly as a viable option.

Re:The Odin Programming Language by renox on Saturday February 01, 2020 @04:39AM (#22209648)
Being able to use a GC in some embedded cases (not too hard constraints on memory use or latency), doesn't mean that you're able to use GC in every embedded cases. I work on telecoms just above the FPGA/DSP even a 1ms pause would be a big issue.
Re:The Odin Programming Language by pjmlp on Saturday February 01, 2020 @06:09AM (#22209912)
Agreed, however there is a big difference between stating that it doesn't work at all, and accepting that there are plenty of use cases where having a soft real time GC tailored for embedded development is perfectly fine, and actually does improve productivity.

Since you mention telecommunications, I would consider network switches running Erlang a use case of embedded development.

Other examples would be the Gemalto M2M routers for messaging processing, or some of the NSN base station reporting platform.

So while it doesn't fit your scenario, it does fit other ones, this is what some in anti-GC field need to realise.

This isn't an all or nothing equation.

Re:The Odin Programming Language by pkolaczk on Saturday February 01, 2020 @02:03AM (#22209174)
Because garbage collection, and in particular tracing garbage collection, adds significant overhead both in CPU cycles and memory. This overhead is also very unpredictable and depends heavily on memory allocation and object lifecycle patterns. Simple GCs can pause the program for a very long time, proportional to the size of the used memory, and this may be several tens of seconds for large heaps, so quite unacceptable. There are ways to mitigate these long pauses with incremental or concurrent GC, but they increase complexity of the runtime system and have even more average overhead, and although in the average case they may perform acceptably, they tend to have very complex failure modes. In addition to that, a tracing GC typically needs some additional memory "room" to operate, so programs using GC tend to use much more memory than really needed.

There is also a common misbelief that compacting GC helps make heap allocations faster than malloc. While technically true - the allocation itself is simple and fast, because it is only a pointer bump, a problem occurs immediately afterwards - this new heap memory hasn't been touched since the last GC, and it is very likely not cached. Therefore you get a cache miss immediately after the allocation (managed runtimes initialize memory on allocation for safety). Because of that, even allocating plenty of short-lived objects, which is the best case for GC, is not actually faster than a pair of malloc+free.

There are also other overheads:

* Managed runtimes typically use heap for most allocations and make stack allocation harder or not possible in all cases - e.g. it is much harder to write Java code with no heap allocations than C.

* To facilitate GC, objects need additional word or two words of memory - e.g. for mark flags or reference counts. This makes cache locality worse and increases memory consumption.

* During heap scanning, a lot of memory bandwidth is utilized. Even if GC does that concurrently and doesn't pause the app, this process has significant impact on performance.

* Tracing GC prevents rarely used parts of the heap to be swapped out.

Re:The Odin Programming Language by typ on Friday January 31, 2020 @11:15PM (#22208615)
At least for my use scenario in embedded systems, performance is not necessarily worse with GC and nondeterminism is not a showstopper either. The problem is avoidable by proactively minimizing allocations in the hot paths or arranging 'critical sections' that disable GC temporarily. The deal-breaker is the memory footprint.
Re:The Odin Programming Language by mratsim on Monday February 03, 2020 @06:53PM (#22230734)
Nim memory management is tied to the type you use.

You either use:

- an object. Which is on the stack and is either trivial or uses destructors and is suitable for embedded due to deterministic memory management

- a pointer object. Which is a raw pointer like C *. Managed directly via raw malloc/free or Nim malloc/free. Suitable for embedded

- a reference type. Which is managed by one of Nim GC or is an error if you use gc:none

Re:The Odin Programming Language by Touche on Friday January 31, 2020 @03:34PM (#22205378)
That's cool but arc is a form of GC.
Re:The Odin Programming Language by beagle3 on Friday January 31, 2020 @02:39PM (#22204840)
Nim could always work without a GC, and it’s getting better at it all the time. Most of the standard library does depend on GC availability, but this is being worked on.
Re:The Odin Programming Language by Touche on Friday January 31, 2020 @02:52PM (#22204956)
Yeah having 2 ecosystems where some stuff depends on GC and some stuff doesn't is always going to be a turnoff to me. Glad that Odin and Zig made the decision to not.
Re:The Odin Programming Language by pjmlp on Saturday February 01, 2020 @03:17AM (#22209404)
Gemalto, PTC, Aicas, microEJ, Astrobe seem pretty fine selling Java and Oberon based tooling and runtimes for embedded devices deployments across industrial automation, robotics and military.

FSecure's foundry USB security key, runs bare metal Go, TamaGo.

Re:The Odin Programming Language by nimmer on Tuesday February 04, 2020 @01:00PM (#22238729)
This is incorrect. Nim has 5 default GC methods and the upcoming automated reference counting.

It runs even on the smallest microcontrollers.

Re:The Odin Programming Language by wiremine on Friday January 31, 2020 @01:18PM (#22203967)
> It’s a trend of “Better C than C” languages that don’t go as far as Rust or C++ in terms of either complexity (or safety) but are more opinionated and modern than C.

I don't see C going away anytime soon, but it's exciting to see people attempting to replace it over the long term. Fun to see where it goes!

Re:The Odin Programming Language by bvrmn on Saturday February 01, 2020 @04:22AM (#22209599)
Zig has a very small "core" idea. Explicit allocator, basic C semantics, clear UB, errors and comptime. All other features implemented in stdlib in zig itself.

Odin fills like go with "special" runtime. For example dynamic arrays are implemented as compiler component in C++.

Re:The Odin Programming Language by gingerBill on Saturday February 01, 2020 @11:38AM (#22211417)
Odin's '"special" runtime' as you call it is extremely minimal and is still easy to swap out with your own, and also only gets used if you use those features.

Zig has a runtime of its own now since it has added coroutines (async/await) as a core feature, but that is still extremely minimal aw well.

Re:The Odin Programming Language by pankajdoharey on Saturday February 01, 2020 @01:04PM (#22212017)
I wonder the same why is everyone trying to replace C, but hardly anyone beside Rust is trying to replace C++, does everyone think C is an easier target?
Re:The Odin Programming Language by dooglius on Friday January 31, 2020 @05:11PM (#22206419)
Being "opinionated" is a step back IMHO, one of the big selling points of C is that it doesn't get in the programmer's way.
Re:The Odin Programming Language by einpoklum on Friday January 31, 2020 @05:26PM (#22206558)
C doesn't get in your way in the same sense that PDP-7 Assembly doesn't get in your way.
Re:The Odin Programming Language by jug on Saturday February 01, 2020 @03:09AM (#22209376)
Nim has an advantage in being so mature. Unfortunately with it maturing, my feeling of it sharing Python’s simplicity slowly faded away.
Re:The Odin Programming Language by BubRoss on Friday January 31, 2020 @02:55PM (#22204978)
I don't think anything has beat the designs of Clay or V, but they aren't really usable. Then again zig intentionally breaks on windows text files so I couldn't say it is widely usable either.
Re:The Odin Programming Language by AnIdiotOnTheNet on Friday January 31, 2020 @03:19PM (#22205208)
Even notepad can do \n-only newlines these days. Zig can't do UTF-16 files either, but no one complains about that.
Re:The Odin Programming Language by earenndil on Friday January 31, 2020 @08:29PM (#22207865)
Cyclone was definitely there. Sadly no longer maintained, and not at all practical to get working on modern systems (I did some work on it, then gave up).
Re:The Odin Programming Language by mottosso on Saturday February 01, 2020 @04:24AM (#22209605)
> Then again zig intentionally breaks on windows text files

Too true. I ran into this after about 10 minutes of trying the language. Copy pasting from a GitHub issue? Better hope those invisible newlines are what you expect.

Re:The Odin Programming Language by renox on Saturday February 01, 2020 @04:41AM (#22209650)
I view this as a good idea!
Re:The Odin Programming Language by BubRoss on Saturday February 01, 2020 @05:15PM (#22213617)
You think alienating 90% of your potential users is a good idea?