News for hackers. Stuff that matters.
Re:Sadly, I must say goodbye to Leaf, my programming language by Bekwnn on Tuesday August 07, 2018 @10:35PM (#17712794)
Games are still in need of a better language. I have some skepticism and hope for Jai. I really wish D as better C worked better in that realm, but it's missing a few crucial things. Rust asserts too much control over memory. I'm all ears for anything that's somewhere between C and C++ as an alternative to write games in.

Most new languages just don't get the things right that C++ did, which is why despite it having a ton of deficiencies when it comes to game development, it's still what everyone in AAA is using. Companies in AAA spend so much money on software to even just somewhat improve places where C++ has gaping flaws. A better language should have been developed by now and I don't even want to think about how much money C++ has cost the industry as a whole, even just purely on iteration speed.

Re:Sadly, I must say goodbye to Leaf, my programming language by AnIdiotOnTheNet on Tuesday August 07, 2018 @11:46PM (#17713064)
I was almost like OP for a while. Working on game, fed up with existing languages (even C), wanted a better C. I was excited about Jai, but as time goes on I'm finding it looks less and less what I want from a language. Seriously considered making my own.

Then I started working with Zig[0]. It's about 90% the language I want and even though it's still immature and the syntax, std lib, and semantics are in flux, I still find the quality of life improvement so huge that all my current projects are in Zig.

Zig is a better C to Jai's better C++, I think. It's a small language, it favors simplicity and explicitness, it has entirely manual memory management to the point that there isn't even a default allocator (we pass one in to anything that requires one). It even lets you import C headers directly to interface with C libraries.

[0] https://ziglang.org/

(skip the "stable" 2.0 download, it's way out of date from master)

Re:Sadly, I must say goodbye to Leaf, my programming language by annywhey on Wednesday August 08, 2018 @12:15AM (#17713169)
Zig is on my "must follow" list right now. It's still early enough in the going that I don't want to maintain code in it, but it's developing in a promising direction and making the kind of commitments that are reasonable to keep.

A lot of language devs want to play with semantics but aren't into the whole "let's do the hard work of actually getting off of C as the baseline" idea so it's nice to have a project that does and has a fairly explicit goal of absorbing and replacing the existing infrastructure step by step.

Re:Sadly, I must say goodbye to Leaf, my programming language by ndh2 on Wednesday August 08, 2018 @04:29AM (#17714077)
Zig is Linux-first, though. I don't think they have any dev who runs Windows. For games especially, you don't want Windows to be an afterthought. Maybe they'll get to it eventually, but it doesn't seem a priority.
Re:Sadly, I must say goodbye to Leaf, my programming language by AnIdiotOnTheNet on Wednesday August 08, 2018 @07:09AM (#17714837)
I pretty much exclusively dev on Windows, and the only thing that's a problem for me is the lack of error and assert traces. Someone started implementing the support for it, but never finished it. It is complicated by the fact that Microsoft does not distribute DIA with Windows and Zig can't include it in its own distribution.
Re:Sadly, I must say goodbye to Leaf, my programming language by Bjartr on Wednesday August 08, 2018 @09:54AM (#17715957)
I expect this is a side effect of it being early in development.
Re:Sadly, I must say goodbye to Leaf, my programming language by Bekwnn on Wednesday August 08, 2018 @02:02PM (#17717988)
Thanks I'll check it out. First glance looks promising.
Re:Sadly, I must say goodbye to Leaf, my programming language by hzhou321 on Wednesday August 08, 2018 @01:03AM (#17713317)
Here is a direction if you are all ears : instead of a new language, add a new layer.

I tried creating my own languages before, some 15 years ago. While I had fun writing compilers, I missed a lot more writing actual programs. One day I suddenly realized I don't really need new language, what I needed is simply context dependent syntax and code block organization, which can easily implemented on the spot. It become MyDef and I have been programing with it entirely for more than 10 years now and wondering how others don't go down the same path.

Actually in a broad sense, Knuth's literate programing adventure is very similar to mine. He also wondered how others were not as excited as he was.

So rather than a new language, try a new dimension.

Re:Sadly, I must say goodbye to Leaf, my programming language by dajomu on Wednesday August 08, 2018 @06:36AM (#17714662)
This sounds really interesting, can you provide a link so I can read some more about it?
Re:Sadly, I must say goodbye to Leaf, my programming language by akuji1993 on Wednesday August 08, 2018 @07:35AM (#17714973)
This seems to be the Github repository for it: https://github.com/hzhou/MyDef
Re:Sadly, I must say goodbye to Leaf, my programming language by co_dh on Wednesday August 08, 2018 @08:50AM (#17715434)
The problem is, your coworker need to modify the generated code.
Re:Sadly, I must say goodbye to Leaf, my programming language by hzhou321 on Wednesday August 08, 2018 @08:58AM (#17715495)
Just share with coworkers the C (or whichever) code that MyDef translated. MyDef is not a language, it only dresses the code. So if coworkers don't like to work with the dresses, simply remove the dress.
Re:Sadly, I must say goodbye to Leaf, my programming language by humanrebar on Wednesday August 08, 2018 @07:23AM (#17714916)
How is MyDef not another language?
Re:Sadly, I must say goodbye to Leaf, my programming language by hzhou321 on Wednesday August 08, 2018 @08:53AM (#17715462)
Because when using MyDef, you are still thinking in the end language -- how the function, variable, type, stack works are all defined by the end language. With MyDef, you are just changing the way of expressing them -- just like giving creatures different clothes, but they are not new creatures.

Here is a short example:

    page: test, basic_frame
        module: c

        $local int A[3]
        $for i=0:3
           A[i] = i
        $dump A[0], A[1], A[2]
Despite the look, if you know c, you recognize it as c. And as you get familiar, you see it exactly as C. `basic_frame` is merely a custom template so one doesn't have to always write the main function signature. $for is shorthand for `for-loop`, `$dump` is simply printf with simple type translations.

Now that you had this meta layer, there is no limit on how you want to dress up your code. Examples:

    $local A[3]: int
    $sumcode(3) A[i]=i+3
    $foreach A
        $dump $(t)
or

    page: test, basic_frame
        $call declare
        $call init
        $call report

    subcode: declare
         $local pn_A[3] = {1, 2, 3}

    subcode: init
         $foreach pn_A
             $(t) = $(t)^2

    subcode: report
         $(set:print_to=stderr)
         $foreach pn_A
             $print "%d: %d", $(i), $(t)

There are lots of idioms and conventions, but it is not a problem as long as you recognize them only as clothing.

Lastly, when dressing up the code makes little sense or you simply don't know better way of dressing them, you can simply write vanila C (or any languages that you are writing). MyDef never tried to compile your language.

Re:Sadly, I must say goodbye to Leaf, my programming language by WalterBright on Wednesday August 08, 2018 @01:05AM (#17713323)
> I really wish D as better C worked better in that realm, but it's missing a few crucial things.

Like ?

Re:Sadly, I must say goodbye to Leaf, my programming language by nicwilson on Wednesday August 08, 2018 @12:50AM (#17713273)
> I really wish D as better C worked better in that realm, but it's missing a few crucial things.

Such as? We are always looking for for things that get in the way of use.

Re:Sadly, I must say goodbye to Leaf, my programming language by Bekwnn on Wednesday August 08, 2018 @02:03AM (#17713540)
Under "unavailable features" https://dlang.org/spec/betterc.html#consequences

3, 4, and 5 are all pretty sore points. 2 would be as well if it weren't extremely likely that for any game you create roll some sort of reflection system. It would be a sore spot for small projects.

3 - No access to classes and polymorphism is a bit of a downer. Although I'm a big believer of data-oriented design, I think there are still many cases where modelling things as objects is the best way to go, especially for things like scene actors and game objects.

4 - No built in threading (core.thread) puts a hamper on any sort of distributed updating or performance optimizations you'd want to do. I'd imagine the workaround is external multi-threaded dlls or something, but it sounds like a pain to manage and deal with in a workflow.

5 - No dynamic arrays. This container is used abundantly in game development. It shows up 5 or more times for every heap/stack/queue. This may not be an issue if you want to write a special memory environment and your own containers, which is common in game development, but not having access to a standard one certainly hurts when it comes to smaller projects or graphics programming experiments.

I may be somewhat off base here since what happened is that I read about those being missing and decided not to try it.

Another note is that a big thing I'm looking for is massively improved compile times, which is one of the biggest things Jai looks to have over C++ in addition to its compiler hooks and #run.

Re:Sadly, I must say goodbye to Leaf, my programming language by p0nce on Wednesday August 08, 2018 @07:45AM (#17715020)
I have a smallish D game on Steam and trust me, you can absolutely use the D runtime instead of -betterC. -betterC is a work in progress and not representative of D.

You will say that you don't want a GC but in reality the GC can be optimized as much as you wan't, and in the mean time you'll get precious _developement time_ to optimize further.

If you can afford the D runtime by all means take it ; for some products I'm doing without the D runtime, and the surprise was that it did't make things any faster _at all_ without the runtime (we did it for other reasons). The only real gain is memory consumption of GC vs manual and that is achievable without going through extreme coercitive measures like -betterC.

Re:Sadly, I must say goodbye to Leaf, my programming language by FeepingCreature on Wednesday August 08, 2018 @03:36AM (#17713892)
It seems to me like you should just be using D, not "Better C-style D"? All those features are not in BetterC because they need a garbage collector, but they are of course in D proper. For smaller projects, I'd recommend just ignoring the GC until you run into actual issues with it, then optimizing for the specific issues.
Re:Sadly, I must say goodbye to Leaf, my programming language by comex on Wednesday August 08, 2018 @04:57AM (#17714176)
That's easy to say, but as long as C++ and other languages can do those things without a garbage collector, D seems somewhat less attractive. (I'm not the OP but I've had a similar experience with D.)
Re:Sadly, I must say goodbye to Leaf, my programming language by WalterBright on Wednesday August 08, 2018 @02:41PM (#17718305)
You can do all of them without a garbage collector - you just have explicitly manage the memory yourself.
Re:Sadly, I must say goodbye to Leaf, my programming language by makomk on Wednesday August 08, 2018 @05:00AM (#17714190)
As I understand it, garbage collection is kind of a non-starter for games programming because it leads to unpredictable pauses in what should be a low-latency, interactive application.
Re:Sadly, I must say goodbye to Leaf, my programming language by qznc on Wednesday August 08, 2018 @08:00AM (#17715123)
You can put the low-latency stuff in a non-gc thread which will not be interrupted [0] and still use the convenient garbage collector for the rest.

[0] https://p0nce.github.io/d-idioms/#The-impossible-real-time-t...

Re:Sadly, I must say goodbye to Leaf, my programming language by p0nce on Wednesday August 08, 2018 @07:49AM (#17715042)
Infognition has found that if you keep the D GC heap under 100k the max pauses will be about 1 ms. The means to reduce GC usage have only grown more diverse in recent years:

- std.experimental.allocator

- @nogc to ensure, well, no GC usage

- various things built on placement new (`emplace`)

- GC profiling with -profile=gc, will display number of allocations and size

None of this existed when people were already making high-performance systems with D...

Re:Sadly, I must say goodbye to Leaf, my programming language by bausshf on Wednesday August 08, 2018 @05:16AM (#17714235)
It is optional however and you can use custom allocators to get around it.
Re:Sadly, I must say goodbye to Leaf, my programming language by xxs on Wednesday August 08, 2018 @08:03AM (#17715143)
You can have low pause, fully concurrent GC even in Java. A GC can utilize read barriers and overall eliminate stop-the-world pauses.

--- A popular example is minecraft that uses mainstream G1 GC.

Re:Sadly, I must say goodbye to Leaf, my programming language by atilaneves on Wednesday August 08, 2018 @07:39AM (#17714991)
That page should be updated.

I was suspicious about #3 since classes in D don't necessarily need the GC. For starters D supports C++ classes, so this works:

https://gist.github.com/atilaneves/b69ed0399efac21bb7a977afd...

I used `scope` with `new` to allocate on the stack, but `emplace` should just work as well to "placement new" a class in malloc'ed memory.

#4 is annoying but one could always use the OS threading API. It's doable to write a library solution to do that akin to boost or Qt before C++11. You do it once and it's there.

#5 No dynamic arrays are also annoying. But... writing a clone of std::vector isn't hard, and there's a unique array in my automem library that _should_ be usable in betterC (but I haven't checked): https://github.com/atilaneves/automem/blob/master/source/aut...

> Another note is that a big thing I'm looking for is massively improved compile times

You get that with D.

Re:Sadly, I must say goodbye to Leaf, my programming language by WalterBright on Wednesday August 08, 2018 @02:41PM (#17718294)
> 3,4,5

Those rely on the garbage collector. If you are willing to do C style memory management, they are all available with betterC.

Re:Sadly, I must say goodbye to Leaf, my programming language by z92 on Wednesday August 08, 2018 @04:38AM (#17714112)
These "unavailable features" are available in D. But NOT when you compile with a specific switch on.
Re:Sadly, I must say goodbye to Leaf, my programming language by moopsit on Wednesday August 08, 2018 @09:44AM (#17715845)
I feel like with languages (in games or anything else), it all boils down to "where there's a will, there's a way". People come up with a lot of reasons Language X won't be suitable for a project, but in the end it's the people who use whatever tools are at hand, who get the job done while the perfectionists are stuck at the starting line. Classic Tortoise vs. Hare situation.

If you want to write games, use your favorite language, and just START. All limitations can be circumvented somehow.

Re:Sadly, I must say goodbye to Leaf, my programming language by tdsamardzhiev on Wednesday August 08, 2018 @12:49AM (#17713269)
The AAA company I work for has tried everything possible to work around C++, and let me tell you, had they not started any such efforts, they'd have been way better off. Seeing the results of it all makes me super sceptical of any C++-killers.
Re:Sadly, I must say goodbye to Leaf, my programming language by seventhtiger on Wednesday August 08, 2018 @04:24AM (#17714053)
Pure OOP is a poor fit for implementing games, but it's a fine base to build a entity-component-system layer on top of which is excellent for games.
Re:Sadly, I must say goodbye to Leaf, my programming language by je42 on Wednesday August 08, 2018 @01:42PM (#17717815)
C++ is not pure OOP. you can write functional stuff quite well. the more recent C++ standard you are willing/are able to adopt the better it gets ;) C++17 is quite awesome.
Re:Sadly, I must say goodbye to Leaf, my programming language by pjmlp on Wednesday August 08, 2018 @02:32PM (#17718217)
Yep, one can even go Haskell like crazy if one feels like to.

The only nagging point is the copy-paste compatibility with C. :\

Re:Sadly, I must say goodbye to Leaf, my programming language by redahs on Tuesday August 07, 2018 @11:15PM (#17712955)
Use regular C, but write the code in literate programming files which can be rendered into a portable design document describing the implementation and interaction of every subsystem in the codebase. 'Standard written English' is the best language available for modeling abstractions.
Re:Sadly, I must say goodbye to Leaf, my programming language by tdsamardzhiev on Wednesday August 08, 2018 @12:51AM (#17713276)
Do you happen to know any open-source games that do this?
Re:Sadly, I must say goodbye to Leaf, my programming language by Razengan on Tuesday August 07, 2018 @11:50PM (#17713079)
> Games are still in need of a better language.

I find Swift to be the best so far, its strong ties to the Apple ecosystem notwithstanding.

Having tinkered with various environments since the Sinclair Spectrum's BASIC (though back then I had no idea what I was doing) I've successively fallen in love with Visual Basic (6.0, not the .NET impostor) and then C#, and now I'm smitten with Swift.

In Microsoft land I was let down by their usual dichotomies that did not allow you full access to all their APIs (or hardware performance) from anything but C++ (though I did manage to make playable DirectX games in VB6). I don't know how that has changed in the last decade since I jumped ship to Apple, but .NET was treated as a second-class citizen for too long.

With Swift, not only do I have access to everything that Apple's operating systems offer, it's also a modern language which feels naturally suited to game design patterns. Although until Swift 2 I often had to fight the language, since Swift 3 and especially now in Swift 4.2 I find it effortless to reason about most game architectures while sticking to the language's idioms.

I also appreciate it for enforcing good practices and getting rid of most sources of ambiguity (such as the ++/-- operators and the legacy `for` syntax, or being specific about %/modulo and so on), even if it may feel annoying in the beginning if you're coming from "looser" languages. It also compiles to native code and can easily interop with C [0], but best of all: I am glad to be able to finally leave semicolons behind. C# honestly feels archaic in comparison now.

As for the elephant in the room – that Swift is only good for iOS, macOS, tvOS and watchOS – well, those platforms have a combined userbase of over a billion users, and the most successful app market [1]; I don't feel that it's such a downside to be limited to those platforms. I do wish that the Apple TV came with a proper gamepad so we could only target that without losing users. It could be a serious contender to existing game consoles if Apple took that route.

If you're in love with Swift too, I'm writing an open-source game engine which offers an Entity-Component-System architecture on top of Apple's APIs [2].

[0] https://theswiftdev.com/2018/01/15/how-to-call-c-code-from-s...

[1] https://www.google.com/search?Apple+App+Store+payouts

[2] https://github.com/invadingoctopus/octopuskit

Re:Sadly, I must say goodbye to Leaf, my programming language by pjmlp on Wednesday August 08, 2018 @07:15AM (#17714870)
With UWP and .NET Native, .NET (C#/VB) is as first class as C++.

To the point the Windows UI team does all their graphics demos in C#.

Re:Sadly, I must say goodbye to Leaf, my programming language by Razengan on Wednesday August 08, 2018 @09:14AM (#17715612)
Ah. My crankiness towards MS may no longer be justified.

I’m too deeply entrenched in Swift though and disgusted by the sight of semicolons in a language anymore :P (maybe I’ll dip into VB.NET and see how it’s doing.)