News for hackers. Stuff that matters.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by ofrzeta on Sunday December 20, 2020 @05:52AM (#25485357)
Everytime I read about D I think it fits the definition of the oft-quoted "boring technology" perfectly. One has to wonder why it did never take of like say Go. This has to be one of the greatest historical accidents in the evolution of programming languages.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by mhh__ on Sunday December 20, 2020 @07:48AM (#25485894)
D has the unfortunate issue of being ahead of its time (i.e. using niche programming languages only really became a thing a few years ago), so it's not "cool". It's a shame really, because I see a lot of languages throwing around D features like C++ interop saying theirs is the best when D's C++ interop is both years old now and battle tested every single day.

D also solves a problem you can't really know you have unless you have a deep knowledge of programming. The idea that if you want to write small code vs. fast code rather than both in the same language in very strongly ingrained because we traditionally teach people C++ and/or Python and that's it unless you do advanced courses (to learn something like Haskell which still doesn't help), even though both are fairly crummy programming languages.

If all goes to plan I may be working to help popularise the language soon, so we'll see about all that.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by chromatin on Sunday December 20, 2020 @10:12AM (#25486721)
Good luck.

Our academic group adopted it because it allows us to be both incredibly productive and have performant code, and both python and Go programmers were able to get up to speed quickly.

With respect to being ahead of its time, there are many features that have been in D for years slowly making their way to other languages, including C++. In that respect it is successful, but certainly I would like it to be successful on its own.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by gkya on Sunday December 20, 2020 @06:12AM (#25485457)
D is featureful and harmonious but it's inevitably complex. With Go, you learn the grammar in one or two days and from then on almost all you'll ever need is the library docs. It has a Scheme-like quality in that aspect, but it combines that with a usual procedural imperative approach and a standard library that has more than call-cc.

A lot of languages have a lot of "syntactic sugar" but actually what's important is more invisible basics: good GC, good concurrency primitives, good method dispatch, good and comprehensive standard library, supportive compiler, etc. Go has a few warts (the whole select / <-chan syntax, god-mode functions like `make', the interface{} problem, the whole go mod / dep kerfuffle), but it does tick all those boxes.

Ofc all that modulo the Google factor, but then there's Dart...

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by mhh__ on Sunday December 20, 2020 @07:53AM (#25485913)
There aren't really that many gotchas in D, either.

I may be misremembering, but when I was learning D the only thing the spec was useful for was for metaprogramming, everything else was pretty obvious.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by gkya on Sunday December 20, 2020 @08:16AM (#25486015)
Not exactly gotchas, but things to learn. Syntactic complexity is the first barrier to entry to any language, and it's the hardest part to learn as you go, because in general looking up functions (or classes, etc.) as you need them is easier than looking up syntax (and esp. syntactic patterns, like `<type> <name>(){}' or `val ? branch : branch'.

I.e., say we need ten features to make up any language. Perl arranges six of these into syntax. Go arranges say two of these into syntax. C++ arranges five into syntax. For D, I've had little exposure but for better or worse let's say it arranges 4 into syntax. For each, the rest are in the std lib. The extreme cases would be, maybe Scheme for 1/10; can't think of any 10/10 syntax languages.

In that light, we can say that Go requires less upfront investment in order to become productive and read code easily: learn two features + how to lookup docs. Versus in D: learn 4 features + how to look up docs.

That's pretty ad hoc, but I hope it helps get the point across.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by raverbashing on Sunday December 20, 2020 @07:35AM (#25485837)
To me the weirdest thing about Go is the package/directory thing

It's a weird way of enforcing structure and the last time I looked into it I couldn't get my head around it

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by gkya on Sunday December 20, 2020 @08:06AM (#25485965)
That's supposed to have gotten better but yeah, IIRC I dabbled in Go about five or six years ago and that was one of the big headaches, together with the whole $GOPATH thing.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by nerdponx on Sunday December 20, 2020 @07:51AM (#25485905)
ASDF in Lisp does it too. I absolutely hate it and I agree it doesn't make any sense.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by pjmlp on Sunday December 20, 2020 @06:28AM (#25485533)
Dart tried to replace JavaScript and faced oppposition from Apple, Mozilla and Microsoft on that regard.

Just like we have WebAssembly because those same companies did not bought into PNaCL.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by attractivechaos on Sunday December 20, 2020 @10:17AM (#25486769)
I wrote a blog post in 2012 [1]. It gives my thoughts on the topic. In brief, D was quite popular around 2008 when no decent C++98 replacements existed. However, the D1-to-D2 transition, the Phobos/Tango (two core libraries) drama and the non-open-source components have ruined its reputation. I still love D but with the standardization of C++11 and the rise of Go and Rust, D won't have a chance again.

[1]: https://attractivechaos.wordpress.com/2012/02/28/timeline-of...

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by crazypython on Sunday December 20, 2020 @01:12PM (#25488242)
Note: D2 is now stable, and also open-source. There are no plans for a D3.

Remember when Python went from 2 to 3? It was incredibly painful. But the transition is over now. Depending on who you ask, Python is now the most popular[0], third most popular[1], or second most popular language[2].

When I started learning Python, it was not popular.

[0]: https://www.tiobe.com/tiobe-index/ [1]: https://www.northeastern.edu/graduate/blog/most-popular-prog... [2]: https://insights.stackoverflow.com/survey/2019

Python is old.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by attractivechaos on Sunday December 20, 2020 @04:54PM (#25489890)
The Python 2-to-3 transition worked because Python is too big to fail. D has never reached that momentum. Rust is a more modern language in comparison to D and the trend will continue without D3. Also the drama back to ~2009 was pretty bad and the community got hurt. Three of my colleagues wrote long programs in D but have abandoned the ship.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by cxr on Sunday December 20, 2020 @04:51PM (#25489865)
> There are no plans for a D3.

I say this in all seriousness: this is probably a mistake, and the Dlang crew should make plans to exploit the opportunity to do a D3/3D release to the greatest extent possible—if only for marketing purposes and while holding onto the secret that there are no breaking changes involved.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by teleforce on Sunday December 20, 2020 @01:04PM (#25488179)
Don't rush to conclusion mate, it is still early by programming language standard, and jury is still out on Go and Rust.

Remember where was Python when 20 years old? It's just another scripting programming language on the block and was playing second fiddle to Perl and TCL. Ruby was hot on its heels due to RoR hipsters [1]. Replace Perl/Rust, TCL/C++, Ruby/Go and RoR/Kubernetes, see the pattern emerging for interpreted/compiled programming languages diaspora.

But now look how far Python has come despite the transition from Python 2 to 3 fiasco. At least D has passed the stage of growing pain while transitioning from D1 and D2 with minimum damages.

[1]https://insights.dice.com/2018/03/09/hipsters-ruined-ruby-fi...

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by pjmlp on Sunday December 20, 2020 @11:24AM (#25487317)
Additionally C# and Java have been getting better AOT compilation story, value types support and native memory handling, so metaprogramming is the last big feature standing.

Which is quite unfortunate, as the language is quite appealing and the community always has interesting discussions.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by WhoCaresLies on Sunday December 20, 2020 @11:51AM (#25487566)
dotnet and Java stand no chance in the modern world

They are heavy, bloated, and try to do everything, at the end of the day they pick the lowest common denominator, for everything, and they ship it

They want compile to a small executable, they are stuck and ended up just zipping everything and calling it a day

They want to interop with native world, but they introduce runtime overhead and their GC/memory model is a barrier

They want to AOT compile, but their runtime and libraries rely a lot on runtime reflection

They want to be tiny, but they have ton of legacy package that makes them very heavy

Just look at the success story of go, it invalidates any attempts to make both dotnet and java attractive, it is too late, even more too late in an ARM world where relying on a JIT is a weakness

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by vips7L on Sunday December 20, 2020 @12:17PM (#25487787)
> They are heavy, bloated, and try to do everything, at the end of the day they pick the lowest common denominator, for everything, and they ship it

What does this even mean?

> They want compile to a small executable, they are stuck and ended up just zipping everything and calling it a day

Both can compile executables the same size as go? See core-rt or the graalvm native-image compiler.

> They want to interop with native world, but they introduce runtime overhead and their GC/memory model is a barrier

Java's GC's are probably better than any on the market, including go's. And I will agree that currently native interop from the JVM is more expensive than it should be, but they're working on it.

> They want to AOT compile, but their runtime and libraries rely a lot on runtime reflection.

Easily solved by just declaring what you reflect upon or using runtime agents to find it. It's more difficult than a language than was designed to do it from the start, but eventually all of the big libraries will have it declared already. Hibernate already does [0][1]

[0] https://github.com/hibernate/hibernate-orm/blob/5eedda9a467f...

[1] https://github.com/hibernate/hibernate-orm/blob/5eedda9a467f...

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by pjmlp on Sunday December 20, 2020 @02:05PM (#25488670)
I should resist to answer trolls, but then again, I can offer a presence to the audience.

Java has had AOT compilation since around 2000, in fact the free beer AOT compilation and JIT caches now available on OpenJDK originate from BEA J/Rockit.

Likewise in what concerns the free beer AOT and JIT cache on J9, it originates from WebSphere Real Time JVM.

As most FOSS people weren't willing to pay for them, so urban myths about Java compilation support models get cargo culted, while those of us that don't have any issues working for the man got to enjoy them.

Likewise .NET has had support for AOT compilation since the beggining with NGEN, then Windows 8 adopted the Bartok compiler from Singularity and Windows 8 .NET Native steems from Project N based on Midori learnings.

And then there are the older ones from CosmOS, Mono, IL2CPP and the upcoming CoreRT.

The success stories of Go are called Docker and Kubernetes, it hardly matters for anything else, while Java, .NET, alongside C++ and JavaScript, own the enterprise.

Even Google has decided to replace the Go written parts in Fuchsia with either C++ or Rust.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by WhoCaresLies on Sunday December 20, 2020 @08:29PM (#25491227)
I should also resist to answer to delusionists

Java AOT story is all over the place, and it's not even good, remember the 300+mb executable from Excelsior? AOT low profile? yeah sure it invalidates the whole language features

Dotnet AOT? i don't call experiments, products, and they have the same limitations as Excelsior AOT, they produce insanly large executables, or if you want to target something like GO, you need to give up on the language features, i don't call this a good experience

Il2CPP, it's a transpiler; and same story as Excelsior AOT, it produces insanly large executable, the GC, and the code produced is very poor quality due to the nature of the language (lot manipulations at runtime, including reflection)

Go success story is that it now go beyong docker and k8s, people write cli tools in GO (github cli one good example), they write all their servers in GO (Riot for example), and some start to do gamedev with GO (ebiten)

Google is still using GO, it's not a system language it has a GC

And since the Rust guy left, their rust effort vanished, at least publicly https://github.com/google

oh and BTW, we'll see wich one get flagged, the one who call someone a TROLL because he give valid arguments, or someone who call someone a delusionist

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by pjmlp on Monday December 21, 2020 @01:33AM (#25492611)
Yeah, just the fact that you talk about the Rust guy at Google shows how much you understand about programming languages.

XBox, Windows 8, 8.1 and Windows 10 aren't experiments, rather products used by more people than any software that you have probably ever produced.

So what that IL2CPP is a transpiler? So were Objective-C and C++ on their early days, and yet they have a market share that Go is yet to achieve.

Also it shows there is some learning required on the compiler design front.

People also write CLI tools in almost every language, hardly a measure of success of any form.

And for Go not being systems, that is actually something that it definitely is, as proven by F-Secure and Google.

https://www.f-secure.com/en/consulting/foundry/usb-armory

https://blog.arduino.cc/2019/08/23/tinygo-on-arduino/

Which still isn't the same as PTC Perc, Aicas JamaicaVM or Meadow.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by bobthebuilders on Monday December 21, 2020 @12:05AM (#25492274)
I'm not sure where you're seeing this Rust data, but Rust development on Fuschia is alive and well. And I wonder why Go isn't more popular than, checks list, Python, JavaScript, Java... Oh wait.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by skocznymroczny on Sunday December 20, 2020 @08:53AM (#25486204)
Main issue is, D is suffering from "Lisp curse" [0]. Read the Lisp curse article, but exchange Lisp for D and you'll have a good idea of the problem.

D is very similar to Lisp in many aspects. It's a powerful language which allows you to create your own minilanguage within a language. In Lisp, you'd do it with macros, in D you can use templates. This makes it a secret weapon which appeals to lone wolf programmers, but it makes it harder to interact within a wider community. Similar with the language features. D allows multiple paradigms, as a result, many libraries don't interact well together. Some people code in OOP fashion, some people refuse to use the garbage collector, some people even reject the entire runtime (betterC_mode).

[0] http://www.winestockwebdesign.com/Essays/Lisp_Curse.html

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by kazinator on Sunday December 20, 2020 @12:15PM (#25487770)
The Lisp Curse is an ignorant diatribe that was written by a (then) junior web developer with no Lisp experience, and has basically been disowned by its author.

His request to "please stop submitting this to Hacker News!" should be interpreted in its strongest form; i.e. including comments. It's right there, at the top: the first thing you read.

D looks fine. It suffers from the curse that we cannot have 1000 languages be popular simultaneously. Popularity is a game of musical chairs. People who don't get chairs when the music stops are not always the clumsy ones who lack athleticism and reflexes. Sometimes, in that crucial moment, the nimble one is just far from the closet chair relative to the klutz whose butt is inches from the seat.

In popular culture, popularity wanes fairly quickly. Yesterday's idol is quickly forgotten. Like Billy Joel's line in "The Entertainer": "But I know the game, you'll forget my name / I won't be here in another year / If I don't stay on the charts."

In computing, we can't swap tools quite that fast. So for fairly long periods of time, popularity begets more popularity. Something is popular today because it rose to popularity some years ago. (Some things have longer cycles, some shorter.) Anyway, that alone creates a barrier to entry, similar to a monopolistic barrier. No matter how good something is that you create, it just doesn't have ... the popularity to make it popular.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by appleflaxen on Monday December 21, 2020 @06:33AM (#25493949)
> junior web developer with no Lisp experience, > and has basically been disowned by its author.

I see the comment at the top about not re-submitting to HN, but I don't see disownership or disavowal.

Is it posted somewhere?

Because asking not to resubmit (which GP didn't), is not the same thing as saying "my conclusions were wrong".

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by mattarm on Sunday December 20, 2020 @12:50PM (#25488078)
The Lisp Curse essay is an interesting read.

I don't think I agree with its basic conclusion that language flexibility leads to a kind of social problem akin to a "curse."

From what I've seen over my career, both C and C++, which the essay claims are not cursed, have many libraries that don't interoperate well, re-invent wheels, are under documented, solve only part of a problem, and are basically solo/hobby efforts. In every job, the first thing I have to learn is how I'm allowed to write C or C++ at the company, since each provides such a huge surface.

The difference between C/C++ and Lisp/D is, I think, not language flexibility. They are all incredibly complex and flexible languages in their own way. The difference is funding and critical mass. C and C++ persist because companies pay people to use them and to improve them. Or, in terms of the curse essay, companies pay people to cooperate. The result is an enduring dominance. Those languages work better because more people use and improve them, so they stay relevant. Neither Lisp nor D seem to benefit significantly from that, so you have what is left: people without the time or interest in producing truly polished solutions.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by kazinator on Sunday December 20, 2020 @01:11PM (#25488234)
C came from the Unix environment, gained momentum in the 1980's. The 1980's was a time when microcomputers exploded.

Unfortunately, these microcomputers only had the memory and CPU power of big iron from 25 years before that. The best applications and games for these machines were written by assembly language wizards.

The C language played right into that. C came from an environment of "mid-grade iron" from about ten years before that. It was developed for the efficient programming of machines that Unix ran on, which were roughly similar in power to the consumer-grade microcomputers of the 1980's.

There were tools like Pascal and Modula also, but C came shrouded with a naive mystique thanks to its cryptic syntax, reputation for bending to the programmer, and creds due to its Unix connection. Naive programmers believed that expressions like i++ were faster than i := i + 1, or else, in any case, they liked it better. Moreover, in some situations, an expression stuffed with side effects in C would actually generate better code than less densely coded equivalent (the only equivalent available in a Pascal family language), due to the limitations of compiler capability. Coders whose ego was built on writing big programs in assembly language and getting them debugged were less threatened by a cryptic language in which you could write programs that were hard to understand, and those used to macro assemblers would also have liked the preprocessor. The ability to abuse the language to get the compiler to do what you want also would have helped. "C gets out of the way so you can get the machine to do what you mean (unlike those other things from the Wirthian family). Before there was an ANSI standard, that would have applied double. The printf function with its format strings also blew away Pascal and Fortran.

On the latter point, I started to learn C at about the same time I enrolled in engineering. There was a mandatory Fortran course in the engineering curriculum. In one of the assignments, I wanted the Fortran program to have numeric output with dynamic column widths. It was really difficult; I can't remember whether I even got it working. I also remember the issue that Fortran's output would replace a fixed field with * characters when the value would not fit, instead of just expanding it. A few months later when I was learning C, I made it a point to try to do that with printf. Wow, I was easily able to do that. I was thinking, why would anyone use Fortran for number crunching if we have C?

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by crazypython on Sunday December 20, 2020 @05:08PM (#25489981)
C became popular because it's easy to implement– the syntax is easy to write a compiler for.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by glouwbug on Monday December 21, 2020 @09:27AM (#25495205)
It really isn't... The grammar isn't formal. For instance:

person * me;

Is this a multiplication statement, or a pointer to a person typedef?

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by kazinator on Monday December 21, 2020 @12:57PM (#25497425)
But that's the easy part of writing a compiler anyway. All we do is, right in the lexical analyzer (not ever the parser) look up the person identifier in the table of declared identifiers in the current scope. It then returns the identifier as a type-identifier, object-identifier or undeclared-identifier. These are then referenced in the grammar phrase structure rules as necessary.

I think there was an aspect of writing a C compiler that was easier, which was namely that certain optimizations in C were just left to the programmer. To get good code out of C, you depended on the basics, like decent instruction selection and peephole optimization, and jump-threading, and maybe elimination of dead code.

Then to otherwise get good code out of C, you stuffed multiple side effects into a single expression, which allowed the compiler the generate the computation and storage accesses any order without analyzing whether any particular order is correct (ensuring they are all correct was left to the programmer, who often didn't care as long as the one compiler he or she were using gave them the right results).

Even the assignment of local variables to registers was programmer-hinted: C had the (now deprecated) register keyword. With the register keyword, your compiler just had to place those variables in registers which were marked with it, and screw the rest. No analysis about which ones should be in registers: particularly good in register-starved architectures. The microcomputer world was characterized mainly by register-starved architectures, with the notable exception of the Motorola 68K series.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by kazinator on Monday December 21, 2020 @12:45PM (#25497278)
C is no easier to write a compiler for than Modula 2 or any such C alternative that was relevant in the 80s.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by qalmakka on Sunday December 20, 2020 @01:14PM (#25488255)
I think that the dispute around Phobos in 2010 together with C++11 froze the enthusiasm that was brewing around it. Rust nowadays got much more mindshare than D ever had, and C++17/20 while extremely complicated is "good enough" for a lot of folks out there.

Also, I think that stuff such as garbage collection and reference types seriously fell out of fashion, because there's no way in hell lots of C folks will ever consider a language with them, sadly.

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by skocznymroczny on Tuesday December 22, 2020 @04:58PM (#25511778)
Rust did a good thing by creating its own niche. D has constantly tried to appeal C++ programmers, implementing features such as better interop with C++ and a lot of advanced template structures. But C++ programmers won't go to D anyway, any language with a GC is dead in C++ programmers' eyes, even if it's reasonable argument or not.
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by pjmlp on Sunday December 20, 2020 @04:25PM (#25489666)
Depends who you ask, yeah certainly not fashionable in UNIX circles, but that is more to computing than that.

And since we are speaking about games here,

https://docs.unrealengine.com/en-US/ProgrammingAndScripting/...

Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by qalmakka on Sunday December 20, 2020 @05:10PM (#25490003)
Sadly, "being fashionable in UNIX circles" is more important than it sounds, because those circles have quite a lot of skilled people, mindshare and staying power and they contribute to lots of critical components that only now are (partially) considering to accept contributions in a different language than C, and that's because that language is Rust (see Linux, GNOME, etc). The refusal of C++ from those "UNIX circles" has led to decades of reinventing the wheel from people that reimplemented all sorts of weird hacks in C for reasons that basically boil down to a strong, unsatiable desire to avoid C++ at all cost (see Glib, Gtk+, etc).
Re:Rebooting a 15 year-old game written in D – Part 1 Compiling by benibela on Sunday December 20, 2020 @05:01PM (#25489934)
I wonder the same about Delphi/Object Pascal