Live data from Hacker News

Ask HN: Is there a simple and minimal language like C but without its footguns?

news.ycombinator.com

31–40 of 41 posts

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#31

I encourage you to reconsider the idea that C has footguns. Having written quite a lot of C, I no longer fear the rougher edges of C. Avoiding them takes time to get used to, but they're the price you pay for the ultimate simplicity of C.

When a comment like this[1] with a complete historical account of the origins of C has to be written in order to explain a weird behavior, you know you have footguns.

[1] https://news.ycombinator.com/item?id=28954260

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#32

"Java is far from minimal" My web servers run with like 300MB of RAM and work fine on t2.nano serving thousands of users?? And also Java gives you full access to primitive types if you don't like OOP

With a WM, and a rather complex language.

And of course if you had written that in C it would probably have taken up a lot less.

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#33

You don't seem to like garbage collectors, or manual memory management (with which you'll get segfaults and double-free issues) or complexity (where the intermediate ground between manual and automatic memory management comes in, with compiler hints, etc.) This doesn't seem like a satisfiable set of constraints. I'd recommend removing "not garbage collected" from the constraints, as automatic memory management mostly…

That set is easily satisfied by giving up dynamic memory allocation. Barring compiler bugs or hardware errors, COBOL and Fortran in their original versions never ran out of memory (applications might report that a data set was too large to handle, but the OS knew how much memory the application needed and gave it to them), didn’t segfault, nor had double-free issues.

With 64-bit CPUs and virtual memory, that might even be a viable approach for some applications. You would have to decide up-front how many Foo’s, Bar’s, etc. to support, but you can set those limits very high (the old solution to that was to replace a card dimensioning some arrays and recompile)

Weird? Yes, for current thinking, but you would get a simple language.

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#34
post #11

Seems like Go might be able to fit your bill. AFAICT the designers of Go has gone out of their way to avoid adding cruft to the language. Yes it has GC. What is it that you want to build though? Will GC be in the way? If so, I would consider Rust instead. C is simple, true – but in many cases it seems like that fact pushes the complexity up to higher layers instead. C still has it’s place in embedded. And our best ke…

OP:

  > C++, Java, Rust are far from minimal. Go feels minimal but it too has a lot of features compared to C and it has a garbage collector too.
You:

  > Seems like Go might be able to fit your bill.
  > I would consider Rust instead.
That's exactly what OP did not want...

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#35
post #34
post #11

Seems like Go might be able to fit your bill. AFAICT the designers of Go has gone out of their way to avoid adding cruft to the language. Yes it has GC. What is it that you want to build though? Will GC be in the way? If so, I would consider Rust instead. C is simple, true – but in many cases it seems like that fact pushes the complexity up to higher layers instead. C still has it’s place in embedded. And our best ke…

OP: > C++, Java, Rust are far from minimal. Go feels minimal but it too has a lot of features compared to C and it has a garbage collector too. You: > Seems like Go might be able to fit your bill. > I would consider Rust instead. That's exactly what OP did not want...

True! But if OP wants a dialogue about language choices then IMHO it could be good to motivate the reasons. E.g. they didn’t explain why they didn’t want GC.

As others have pointed out in this thread, there are good reasons why Rust is designed the way it is.

With that said, I hope the OP will find a language that they like and can be productive in. Hopefully they input from this thread can be of guidance.

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#36
There are two publicly available contenders: Odin and Zig.

Each one has its own way in which it deviates from C in a way that some people might not like. Odin is probably a lot closer to C than Zig. Zig tries to bring some of the more recent ideas into the low level programming space (compile time null checking, builtin "T or error" types, etc.

https://odin-lang.org/

https://ziglang.org/

Of course there are some other contenders, but having looked at them, either they are not even serious enough, or they deviate from C way too much, with GC, closures, etc.

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#37
Yes, it is called C with Experience. Write code like a fantasy scientist: track what you're doing, document what works and what does not, and maintain that reference-sheet across multiple projects. Like a scientist is supposed to work. Your foot guns will vanish.

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#38

Earlier quoted context omitted.

I’m not sure if Ada counts as “simple” as C (maybe so, maybe not depending on where you find complexity, but I find it funny at at this point the Ada spec is smaller than the C++ spec.

Ada is definitely more complex than C, but not as complex as C++. If you can draw the parallel between .h/.c and .ads/.adb files, you're halfway to using Ada-as-C. If you then learn the basic procedural syntax and just enough about packages to be dangerous, you can use Ada as a moderately safer C. You have to learn the type system, task and protected types, and a few other things to really get the advantages of Ada,…

Yeah I guess part of my line of thinking was the the undefined behavior of C is a sort of complexity you may not get in Ada.

I actually love the language, and am kinda sad it doesn’t see much use anymore. I saw a job some weeks back that involved porting a bunch of Ada code on VAX to C#/Windows and I just didn’t have the heart to apply lmao.

Re: Ask HN: Is there a simple and minimal language like C but without its footguns?

#39

"Java is far from minimal" My web servers run with like 300MB of RAM and work fine on t2.nano serving thousands of users?? And also Java gives you full access to primitive types if you don't like OOP

I think he means that Java is not a small language, rather than it doesn't take up much space in RAM. Personally, I still think that C is a very good compromise between size (both of the language and of its RAM usage) and it's level of abstraction. The size of a language can be judged by the size of a definitive text on learning the language. Compare how small the K&R book "The C Programming Language" is [230 pages]…

I respect this argument but I'm curious as to how the smallness of a language would be beneficial to a developer, if the goal is to be able to rapidly build applications which are still quite performant.

C, when run on the same exact machine as Java, is only a few x faster in the best case scenario to my understanding. And as complexity of the application grows, there is a chance that you don't manage your memory properly, something which a garbage collected language usually does well enough.

Couple in the rich libraries for both languages, I think I would still choose java unless I was writing an embedded system.

Post reply on HN