Live data from Hacker News

Zig: software should be perfect [video]

youtube.com

81–90 of 141 posts

Re: Zig: software should be perfect [video]

#81
post #53
post #22

Earlier quoted context omitted.

There are stupid warnings about nothing to fix, at least in gcc. It's not making the software better. One warning I recently disabled on $workproject is -Wtrigraphs.

Trigraphs can readily be formed unintentionally, so having a warning when they change the meaning of the program seems valuable. There is a good reason they were removed entirely in C++17.

They are as good as removed from C.

No compiler I care about has had them enabled by default in more than two decades.

Re: Zig: software should be perfect [video]

#82
post #21

It is actually a nice informative video, but the title is as dumb as dumbness itself. Software should not be perfect. It should be useful. In places where perfection increases usefulness (s.a autopilot), go ahead make it perfect. In most cases, striving for "perfection" is a profound misallocation of resources.

Agreed.

However, I interpret the message from the video as "Let's make it really easy to achieve perfection".

In other words if we keep improving development tools and technologies, we may eventually be able to achieve perfection in each individual project nearly for free.

Whether this is realistic or not, I do not know.

Re: Zig: software should be perfect [video]

#83
post #80

Earlier quoted context omitted.

Many of those are ruled out as modern successors (in my mind, at least), when they continue to make “the billion dollar mistake” (to use its inventor’s own words[1]) of null references. Rust, Zig, Kotlin, Swift, and many other modern languages can express the same concept of a null reference, but in a fundamentally superior way. In modern languages like these, the compiler will statically guarantee the impossibility…

Null isn't that bad -- or rather, the concept of a missing value. Certain languages handle null better than others, but even then, it seems like the more costly mistake has been the accumulation of made-up data to satisfy non-null requirements.[0] More costly for non-programmers who have to deal with the programmers' lazy insistence that not knowing a value for some data in their system is forbidden, anyway. In any c…

I think the author of that blog post fundamentally misunderstands the point: The damage of nullable pointers is not that they are nullable, but that compilers allow you to write code everywhere that assumes they’re not null (in fact, this is the only possible way to code, when the language cannot express the notion of a non-nullable reference!)

For example, most older languages with “the billion dollar mistake” have no complaint whatsoever when your write “object.method();” where it’s unknown at this scope whether “object” is null or not.

The fact that such code compiles is the billion dollar mistake; not the fact that the pointer is nullable.

I don’t care if you want to write nullable references everywhere, or whatever else you prefer or your application demands. That’s fine, so long as:

1. Non-nullable reference types must exist.

2. Nullable references types must exist as statically distinct from #1.

3. The compiler must not let you write code that assumes a nullable reference is not null, unless you check via a control flow statement first.

Now to take a step back, the principle behind this certainly applies beyond just nullability (if that was the point you were trying to make): Generally, dynamic, untyped invalidation states are dangerous/bad, while statically typed invalidation states are ideal. And yes, this does include bad states internal to a non-null reference, just as much as to a null reference.

Sum types are the key to being able to statically declare what range of values a function may return (or accept), and ensure at compile time that these different cases are all accounted for. If you aren’t aware of how elegantly sum types solve this, you should look into it — and I suspect it will be quickly clear why nullable references are useless, outdated, and harmful.

But at the very least, we’ve solved the pain of null dereference — and virtually without compromise. So, it’s irresponsible or ignorant IMO to create a new language that doesn’t include this solution in its core.

Re: Zig: software should be perfect [video]

#84

There's a certain irony that the presenter quickly dismisses exception-based error handling, and then the first example handles an error by printing a message and exiting -- exactly what an unhandled exception does. This is more than a small piece of irony with a somewhat artificial example. Often, there simply isn't very much you can do with an error. In a SaaS world, you might not be able to tell the user what wron…

I made this argument in the talk: the only problem with exception-based handling is the lack of explicitness. It's too easy to call functions without being aware of the set of possible errors. Many c++ projects disable exceptions entirely. Writing "exception safe" code is tricky and non-obvious. Functions which should be guaranteed to never fail often can throw std::bad_alloc. Try-catch syntax forces incorrect nestin…

> It's too easy to call functions without being aware of the set of possible errors.

Yes, and that's a very good thing.

> Many c++ projects disable exceptions entirely.

Yes, and they're objectively wrong.

> Writing "exception safe" code is tricky and non-obvious.

The word 'exception' here is redundant.

Re: Zig: software should be perfect [video]

#86
post #60

Earlier quoted context omitted.

There are a lot of contenders. My own unsorted list is Nim, Rust, C++20xx, D, Objective C, Pony, Zig, Crystal, Red, and maybe a form of Lisp (why not Common Lisp). Even more unlikely a maybe and only for the C/C++ trenches of embedded systems, some form of Forth. If Jai ever ships I might consider adding it (at least as a contender to the C/C++ trenches of games and game engines), but it's absurd to think it will hav…

Many of those are ruled out as modern successors (in my mind, at least), when they continue to make “the billion dollar mistake” (to use its inventor’s own words[1]) of null references. Rust, Zig, Kotlin, Swift, and many other modern languages can express the same concept of a null reference, but in a fundamentally superior way. In modern languages like these, the compiler will statically guarantee the impossibility…

> Many of those are ruled out as modern successors (in my mind, at least), when they continue to make “the billion dollar mistake” (to use its inventor’s own words[1]) of null references.

Well, you're in luck then! You don't even need a 'modern' successor, C++ (even the ancient versions) disallow null references.

Re: Zig: software should be perfect [video]

#87

Earlier quoted context omitted.

I made this argument in the talk: the only problem with exception-based handling is the lack of explicitness. It's too easy to call functions without being aware of the set of possible errors. Many c++ projects disable exceptions entirely. Writing "exception safe" code is tricky and non-obvious. Functions which should be guaranteed to never fail often can throw std::bad_alloc. Try-catch syntax forces incorrect nestin…

> It's too easy to call functions without being aware of the set of possible errors. Yes, and that's a very good thing. > Many c++ projects disable exceptions entirely. Yes, and they're objectively wrong. > Writing "exception safe" code is tricky and non-obvious. The word 'exception' here is redundant.

> The word 'exception' here is redundant.

Exceptions make it much harder.

Re: Zig: software should be perfect [video]

#88

There's a certain irony that the presenter quickly dismisses exception-based error handling, and then the first example handles an error by printing a message and exiting -- exactly what an unhandled exception does. This is more than a small piece of irony with a somewhat artificial example. Often, there simply isn't very much you can do with an error. In a SaaS world, you might not be able to tell the user what wron…

I made this argument in the talk: the only problem with exception-based handling is the lack of explicitness. It's too easy to call functions without being aware of the set of possible errors. Many c++ projects disable exceptions entirely. Writing "exception safe" code is tricky and non-obvious. Functions which should be guaranteed to never fail often can throw std::bad_alloc. Try-catch syntax forces incorrect nestin…

> the only problem with exception-based handling is the lack of explicitness. It's too easy to call functions without being aware of the set of possible errors.

That's the whole point of exceptions.

Re: Zig: software should be perfect [video]

#89
post #9

Javascript (programming language) and Browser (runtime environment) is a perfect piece of combination. With JS, you have many choices of implementation. With Browser, runtime error doesn't crash user's device.

Same is true for the JVM or Python, no?

Yeah. BTW it's also true for native apps running in user-mode.

Re: Zig: software should be perfect [video]

#90
post #75

I'm watching Zig and Jai closely. We need a better C and C++ isn't it. Good luck!

I'm betting on Jai.

I hadn't heard of Jai yet, but wow! That's a lot of hype (and even tool support) for something that doesn't work yet.

At first glance, Zig vs Jai reminds me a lot of the Linux vs GNU Hurd thing (or a lot of other "worse is better" examples). A couple of geniuses locking themselves up telling the world "Just wait! It'll be awesome!" seldomly produces something that lasts.

Post reply on HN