top | item 44555924

Writing a competitive BZip2 encoder in Ada from scratch in a few days (2024)

110 points| etrez | 7 months ago |gautiersblog.blogspot.com

See also part 2: https://gautiersblog.blogspot.com/2025/07/writing-bzip2-enco...

68 comments

order

danbruc|7 months ago

For those only having a quick look, the charts do not have the y axis start at zero, the differences are much smaller than it looks.

Sesse__|7 months ago

Also, they seemingly already had a BWT lying around (which is seemingly not counted in “from scratch in a couple of days”), and there is no mention of speed.

etrez|7 months ago

The data in question cannot be compressed to zero, or close to zero, by far.

tombert|7 months ago

I know the history of why Ada failed, but it always seemed like such a neat language that shouldn't have failed.

It seemed like it should have been the standard for a lot of desktop applications for the 90's and 2000's.

imglorp|7 months ago

Failed what? In its domain, it succeeded in its goals: a high reliability platform for aerospace, defense, and other mission critical domains. It was mandated by the US DoD for all software in the nineties and used in Airbus avionics and aboard the ISS, etc.

Its syntax and concepts were considered solid and so was selected as the basis of the VHDL hardware description language, also successful in its domain.

IshKebab|7 months ago

It was held back by all of the compilers being commercial for a long time.

Also the main advantage it has over C is safety, and nobody really took that seriously until recently (and it doesn't really have an answer for use-after-free which is a huge class of bugs).

steveklabnik|7 months ago

I am curious, knowing that history, why do you think that it shouldn't have?

I have my own thoughts that I'd be happy to share, but I don't want to spoil your opinion with them.

(This goes for basically anyone who's interested in talking about it, I think it's a fascinating bit of history.)

MisterTea|7 months ago

> I know the history of why Ada failed,

Do you have sources you could point to? I once read that it's a great language mired by a designed by committee ecosystem. I really liked the language when I tinkered with it a bunch around 2010 but moved on after work pushed me to other languages like C# for GUI stuff. First language I used with simple built in concurrency.

myth_drannon|7 months ago

Ada was getting a lot of traction in USSR (so commercial license prices were not a concern) and was pushed in many domains. My father studied it in university in the 80's. But with the Soviet Union collapse all those efforts fizzled.

jksmith|7 months ago

It failed because the C family is far superior - in mindshare and commodity dev experience. Ada may end up with a win to some degree if it plays to a narrative that all software needs to be mission-critical, no matter what the domain. Maybe in degrees, but that's actually true these days.

I did some consulting at a major US car manufacturer, and helped with a coding seminar, mostly in java. A fair chunk of those developers struggled with a fizzbuzz exercise. All I can say is this: don't leave your baby in the back seat of an autonomous car just to get out and recharge unless you have consequential trust reciprocation with the manufacturer tantamount to shutting them down if anything tragic happened. Of course, even that price is too low.

burnt-resistor|7 months ago

As used in zillions of aircraft, defense, and aerospace systems, it succeeded wildly. It's not Javascript because not every language needs to serve all stakeholders. Tools in the toolbox, not all-or-nothing religious factions that only "matter" if they ride a hype popularity train. There are many critical technologies all around that are little known.

rustcleaner|7 months ago

Why did Mozilla reinvent the wheel with Rust when we had Ada/SPARK?

steveklabnik|7 months ago

Glibly, because they’re not the same language.

I don’t think I’ve ever heard Graydon comment on Ada specifically, but early Rust was very different than today’s Rust. Funny enough, I’d argue that early Rust was much closer to Ada than the Rust we ended up with.

One thing that makes Ada and current Rust different is that Ada does a lot more checks at runtime than rust does, and is more okay with features that have more of a runtime than Rust is.

Another is that Ada doesn’t guarantee memory safety at compile time, or at least, it did not at that time. I believe that with the new Spark features that are inspired by Rust that recently landed may bring parity here, but I haven’t had time to investigate those yet.

But really, they're just very different languages from each other. There's no reason they can't coexist.

Jtsummers|7 months ago

SPARK 2012 was what made SPARK viable for a broader audience. Earlier versions of SPARK were not really properly integrated into Ada (SPARK annotations were in comments). SPARK also restricts what is expressible to what is provable within SPARK (which expands over time), this has some important consequences for concurrency and parallelism (using the "concurrency is not parallelism" distinction). So it would have been hard for Graydon Hoare to use SPARK 2012 in 2006 when he started on Rust, and the limitations around concurrency in SPARK 2012 would have been a non-starter for the objectives of Rust as adopted by Mozilla.

whartung|7 months ago

Well that was disappointing. I was hoping to see a discussion about writing a zip encoder in Ada. How the language was used, values of the language for this kind of work. How it’s easier or harder to do. Maybe a bunch of Ada source code.

Simply as one who does not use Ada I had hoped to be a bit more informed about it.

etrez|7 months ago

Thanks for the feedback. Multiple posts are planned on that topic. For parts 1 and 2 (so far the only ones existing) I preferred explaining the context and the remarkable simplicity of the BZip2 format. In part #4, I will try to show why the customisable types in Ada fit so well compression software. Be patient: writing articles about writing software takes much more time than writing the software itself! In the meantime, there is a short preview of that in recent presentations - notably FOSDEM 2025: https://fosdem.org/2025/schedule/event/fosdem-2025-5148-adve... , last slide.

cashsterling|7 months ago

I think Ada is a great language and it is completely possible that Ada will experience a resurgence in coming years.. especially as LLM's are used more and more to generate software. ADA/Spark can provide very robust guide rails for correctness (so can Rust) of 'AI' generated code.