News for hackers. Stuff that matters.
Re:Why I Don't Like Golang (2016) by gerbilly on Wednesday June 12, 2019 @05:41PM (#20169631)
Does anyone remember reading K&R for the first time?

To me seemed like C was such a tight, perfect little design.

Only thirty keywords, and simple consistent semantics.¹

When I first learned it, it was still pre ANSI, and you declared a function like this

int f(a)

char *a

{

}

The ANSI style function declaration was maybe the only innovation that came after that that significantly improved the language.

I remember in the late '80s knowing my compiler so well that I could tell you what the stack frame would look like pretty much anywhere in my code. It was awesome to have that level of familiarity.

Soon after that things started to get more complicated, and I did a lot of Java, and I never again felt as dialed in to those languages as the late 80s C that I started out with.

The K&R book is worth a read if anyone missed it. It's beautifully written. A far cry from the 'opinionated' copy that you often find on the Go website.

Personally, I don't think you can make similar claims about Go's design or the 'because I told you so' tone that surrounds it.

1: Yes, I know, undefined behaviour, but this is my post and this is how I feel about C.

Re:Why I Don't Like Golang (2016) by lmm on Wednesday June 12, 2019 @06:18PM (#20169944)
Can't say I got that feeling at all.

Smalltalk is a tight design. So is Lisp. So is Forth. So is APL. C's design just feels like a pile of... stuff. Arrays are almost but not quite the same as pointers. You can pass functions but not return them. There's a random grab-bag of control flow keywords, too many operators with their own precedence rules, and too many keywords given over to a smorgasbord of different integer types with arbitrary rules for which expressions magically upconvert to other ones.

Re:Why I Don't Like Golang (2016) by jolmg on Wednesday June 12, 2019 @08:28PM (#20170774)
> You can pass functions but not return them.

  #include <stdio.h>

  char *f(void) {
    return "Yes, you can...";
  }

  char *(*g(void))(void) {
    return f;
  }

  int main() {
    puts(g()());
    return 0;
  }
Re:Why I Don't Like Golang (2016) by User23 on Wednesday June 12, 2019 @08:58PM (#20170945)
Technically passing and returning function pointers is very different from passing and returning functions. This has implications for things like closures.
Re:Why I Don't Like Golang (2016) by jolmg on Wednesday June 12, 2019 @09:02PM (#20170968)
By the fact that lmm said "You can pass functions", they probably meant "function pointers", since that's the only way you can pass in something that could be referred to as a function in C.

EDIT: At least last I heard. The example I gave is C89, and I know C99 and some GNU extensions. I don't know if a new standard introduced something else that could be referred to as a function that can be passed in but not returned.

A quick google for "c lambda" and "c closure" as well as looking for those keywords in the Wikipedia articles of C11 and C18 turned up nothing, so I guess not.

Re:Why I Don't Like Golang (2016) by earenndil on Wednesday June 12, 2019 @10:19PM (#20171318)
GNU c can have lambda expressions[1]. And clang does even have closures[2].

1: http://walfield.org/blog/2010/08/25/lambdas-in-c.html

2: https://en.wikipedia.org/wiki/Blocks_(C_language_extension)

Re:Why I Don't Like Golang (2016) by saagarjha on Thursday June 13, 2019 @01:17AM (#20172001)
Note that the first example relies on multiple GCC-only features, one of which is the atrocity that is nested functions, and even then technically invokes undefined behavior.
Re:Why I Don't Like Golang (2016) by kazinator on Wednesday June 12, 2019 @11:45PM (#20171644)
GNU C has "downward funarg" closures, like Pascal. They have the same representation as function pointers, which requires the compiled code to generate trampolines (little pieces of machine code that find a PC-relative environment pointer) on the stack. Invoking them requires executable stacks (a linker-level executable option often now turned off by default in major GNU/Linux distros).
Re:Why I Don't Like Golang (2016) by jstimpfle on Thursday June 13, 2019 @10:33AM (#20175242)
> Arrays are almost but not quite the same as pointers.

There's a big misunderstanding here. Arrays and pointers are entirely different things. An array is a chunk of elements that lie next to each other in memory. A pointer is just a pointer.

The only thing that C does that causes confusion is pointer decay. If you use an array in an expression context, other than the sizeof operator, that expression evaluates to a pointer to the first element of the array.

And while it's confusing the heck of many people who never learned it properly, it's very useful. For example, string literals are arrays, too! Would you prefer to write printf(&"Hello, World\n"[0])?

That's it, in a nutshell.

Re:Why I Don't Like Golang (2016) by kevin_thibedeau on Wednesday June 12, 2019 @11:30PM (#20171586)
C makes more sense if you read Ken Thompson's B manual.

https://www.bell-labs.com/usr/dmr/www/kbman.html

Re:Why I Don't Like Golang (2016) by danbolt on Wednesday June 12, 2019 @08:21PM (#20170733)
Part of me wonders if a lot of that baggage comes from C's background compared to Lisp. Or, especially when C's origins were originally to operate a PDP-8 I wonder if the goals and ideas behind each contributed to why the way they are.
Re:Why I Don't Like Golang (2016) by fao_ on Wednesday June 12, 2019 @09:46PM (#20171183)
FYI: 2am possible rambling on design and software

Funny, I got the same feeling from Smalltalk and Lisp.

I own both "Common Lisp: The Language" and "Smalltalk-80: The Language and its Implementation", and while there are many ways those languages could be described as 'tight' (tightly-coupled, perhaps), at no point can you look at the C language and say "This could be smaller" without significantly removing functionality. Ok, perhaps there are some things around array/pointer syntax, etc. but the room for removing things from the language is very small.

LISP and Smalltalk are both 'kitchen-sink' languages. As I understand it (i.e. Unless I misread something or skipped a page) for an implementation to be a proper spec-conforming instance of Smalltalk-80, a screen and graphics server is required. Indeed, Smalltalk-80 requires a very specific model of graphics display that is no longer appropriate for the time. Steele's Lisp, has a number of functions that one could strip out and nobody would care or notice very much.

On the other hand, all of the C that is there serves a purpose.

Perhaps the only thing in your list that does feel like a tight design in addition to C, is FORTH. But FORTH puts the burden for the programmer to remember what is on the stack at any given time. It has some beauty, indeed, but all of the abstractions seem inherently leaky. I haven't programmed in FORTH, however, so I can't really talk more about how that plays out in practice.

If the "There is nothing else to remove" does not resonate with you, then I think the perspective of the OP, and myself, and others, when we call C a "small"/"tight" language, is that essentially, C was born out of necessity to implement a system. Conversely, the 'batteries included' aspect of Smalltalk and Lisp more or less presume the existence of an operating system to run. It feels like the designers often did not know where to stop adding things.

Most of the library functions in C, can be implemented very trivially in raw C. Indeed, much of K&R is just reinventing the library 'from scratch', there is no need to pull out assembly, or any more assumptions about the machine other than "The C language exists". Whereas, a lot of the libraries of Smalltalk and Lisp seem bound to the machine. Not to harp on too much about the graphics subsystem of smalltalk, but you couldn't really talk about implementing it without knowing the specifics of the machine. And while much of Lisp originally could be implemented in itself, Common Lisp kind of turned that into a bit of a joke. Half the time when using it, it is easier and faster to reimplement something than find whether it exists.

Apologies if this is repetitive or does not make much sense.

Re:Why I Don't Like Golang (2016) by nickloewen on Wednesday June 12, 2019 @11:41PM (#20171623)
I agree with you, but perhaps you are reading “tight” slightly differently than the way the original poster intended it?

To me, ANSI C is “tight” in the sense that it is made up of a small set of features, which can be used together to get a lot done. But the design of the features, as they relate to each other, can feel somewhat inelegant. Those different features aren’t unified by a Simple Big Idea in the way that they are in Lisp or Smalltalk.

Lisp and Smalltalk, then, have “tight” designs (everything is an s-expression/everything is an object) which result in minimal, consistent semantics. But they also have kitchen sink standard libraries that can be challenging to learn.

(Although to be fair, Smalltalk (and maybe Common Lisp to a lesser extent) was envisioned as effectively your whole OS, and arguably it is a “tighter” OS + dev environment than Unix + C...)

FWIW, I am learning Scheme because it seems to be “tight” in both senses.

Re:Why I Don't Like Golang (2016) by lmm on Thursday June 13, 2019 @05:22AM (#20173014)
It sounds like you're talking about the standard library rather than the language? The examples I gave have a very small language where you really can't remove anything, whereas in C quite a lot of the language is rarely-used, redundant, or bodged: the comma operator surprises people, for and while do overlapping things, braces are mandatory for some constructs but not for others, null and void* are horrible special cases.

Standard libraries are a different matter, but I'm not too impressed by C there either; it's not truly minimal, but it doesn't cover enough to let you write cross-platform code either. Threading is not part of the pre-99 language spec, and so you're completely reliant on the platform to specify how threads work with... everything. Networking isn't specified. GUI is still completely platform-dependent. The C library only seems like a baseline because of the dominance of unix and C (e.g. most platforms will support BSD-style sockets these days).

I'm actually most impressed by the Java standard library; it's not pretty, but 20+ years on you can still write useful cross-platform applications using only the Java 1.0 standard library. But really the right approach is what Rust and Haskell are doing: keep the actual standard library very small, but also distribute a "platform" that bundles together a useful baseline set of userspace libraries (that is, libraries that are just ordinary code written in the language).

Re:Why I Don't Like Golang (2016) by lispm on Thursday June 13, 2019 @05:56AM (#20173155)
> Steele's Lisp, has a number of functions that one could strip out and nobody would care or notice very much.

Common Lisp is kind of a language and a library. Parts of the library would be optional. Some standardization efforts (EuLisp, R6RS, ...) tried to defined a Lisp like-language in layers/modules/libs later on.

Re:Why I Don't Like Golang (2016) by jmspring on Wednesday June 12, 2019 @10:33PM (#20171385)
I think one's love/comfort with C depends one's path into software development. It was my first language (aside from Basic). It has it's quirks and you can do some really bad/dangerous things when writing large apps.

That said, given my comfort level and tendency to be more explicit rather than tricky, my C coding ends up surprising me a week or so later when I go back and realize "even at 2am" I did the right thing.

It's also a fun language to mess with junior programmers with.

Re:Why I Don't Like Golang (2016) by tx-0 on Wednesday June 12, 2019 @08:21PM (#20170732)
but you can't pass functions in C, you can only pass pointers-to-functions... and you can return them too.

the piles of stuff that C contains are the stuff of 20th century von Neumann architectures, the stuff that defines the undefined behaviors, and that's what has made C indispensible.

I'm not saying C's perfect, but you can't swap it out without replacing what it did and does.

Re:Why I Don't Like Golang (2016) by fao_ on Wednesday June 12, 2019 @09:50PM (#20171197)
Hi, I vouched for this comment, so people can see it. You're shadowbanned, it seems. I took a glance at your comments and I can't really see a reason for it, many of your comments are borderline but I've seen worse here by 'top rated' commenters.
Re:Why I Don't Like Golang (2016) by kazinator on Wednesday June 12, 2019 @11:46PM (#20171649)
That's the same with languages that have first class functions. The code part is still passed by reference, not by copying around the machine code.
Re:Why I Don't Like Golang (2016) by saagarjha on Thursday June 13, 2019 @01:24AM (#20172025)
Of course, almost every high-level language that compiles to native code ends up doing something that looks like sugared C for many of their features.
Re:Why I Don't Like Golang (2016) by kazinator on Thursday June 13, 2019 @01:26AM (#20172034)
That first class functions are passed by reference can be verified at the high level; e.g. with the eq function in Common Lisp.
Re:Why I Don't Like Golang (2016) by pjmlp on Thursday June 13, 2019 @01:05AM (#20171942)
UB is what makes C fast versus what PL/I variants and Fortran optimisers were already able to do without such tricks.
Re:Why I Don't Like Golang (2016) by jstimpfle on Thursday June 13, 2019 @10:46AM (#20175378)
UB is not what makes C fast. A good (and fast) program does not contain undefined behaviour, at least ideally.

The only speed advantage of Fortran, to my knowledge, comes from pointer aliasing information that C compilers have a harder time to infer. But that's more a consequence of the programming domain. Fortran is not a systems programming language. Fortran has specialized data structures for scientific computing built in (I think??). It's an apple and oranges comparison.

Re:Why I Don't Like Golang (2016) by pjmlp on Thursday June 13, 2019 @01:35PM (#20177006)
Fran Allen begs to differ.

Plus the experience from all from us that had access to early C compilers on CP/M and home micros.

IBM already had a LLVM like toolchain for their RISC research with PL.8 and respective OS.

Only later did they switch to UNIX due to the market they were after.

Surviving mainframes are still writen on their system languages.

As for Fran Allen point of view:

"Oh, it was quite a while ago. I kind of stopped when C came out. That was a big blow. We were making so much good progress on optimizations and transformations. We were getting rid of just one nice problem after another. When C came out, at one of the SIGPLAN compiler conferences, there was a debate between Steve Johnson from Bell Labs, who was supporting C, and one of our people, Bill Harrison, who was working on a project that I had at that time supporting automatic optimization...The nubbin of the debate was Steve's defense of not having to build optimizers anymore because the programmer would take care of it. That it was really a programmer's issue.... Seibel: Do you think C is a reasonable language if they had restricted its use to operating-system kernels? Allen: Oh, yeah. That would have been fine. And, in fact, you need to have something like that, something where experts can really fine-tune without big bottlenecks because those are key problems to solve. By 1960, we had a long list of amazing languages: Lisp, APL, Fortran, COBOL, Algol 60. These are higher-level than C. We have seriously regressed, since C developed. C has destroyed our ability to advance the state of the art in automatic optimization, automatic parallelization, automatic mapping of a high-level language to the machine. This is one of the reasons compilers are ... basically not taught much anymore in the colleges and universities."

-- Fran Allen interview, Excerpted from: Peter Seibel. Coders at Work: Reflections on the Craft of Programming

Re:Why I Don't Like Golang (2016) by jstimpfle on Thursday June 13, 2019 @05:18PM (#20178660)
Why do you keep sidestepping logical arguments with irrelevant quotes? Correct programs don't contain UB (even the fast ones), so UB is not what makes C fast.

Not checking for UB (aka invalid configurations) at runtime is what makes C (and any other language) fast - or more precisely, it's what allows compilers to emit efficient code.

Some languages / compilers rule out UB statically through the type system or other means, but that comes with tradeoffs that might, or might not, be worth making in your domain.

Re:Why I Don't Like Golang (2016) by pjmlp on Thursday June 13, 2019 @06:30PM (#20179174)
Because C guys keep spreading the false arguments that C was some kind of language sent by god to solve all performance issues, while we in the trenches when the language sprung into existence know it wasn't never the case.

Not to mention the fact that other programming languages, on the mainframe and workstation space, were already starting to collect the benefits of whole program optimizers.

Re:Why I Don't Like Golang (2016) by jstimpfle on Friday June 14, 2019 @05:00AM (#20181474)
...
Re:Why I Don't Like Golang (2016) by simias on Wednesday June 12, 2019 @07:28PM (#20170404)
>To me seemed like C was such a tight, perfect little design. Only thirty keywords, and simple consistent semantics.

Except that clearly history showed that it wasn't enough, and we ended up with about 50 millions (and counting) different meaning for "static" for instance. I like C but its simplicity is almost by accident more than by design. It's pretty far from "perfect" in my book.

There are so many weird features about the language that can bite you ass for no good reason. Why don't switch() break by default since it's what you want it to do the overwhelming majority of time (answer: if you generate the corresponding assembly jump table by hand "fall through" is the easiest and simplest case, so they probably kept it that way).

Why do we have this weird incestuous relationship between pointers and arrays? It might seem elegant at first (an array is a pointer to the first element or something like that) but actually it breaks down all over the place and can create some nasty unexpected behavior.

Why do we need both . and -> ? The compiler is always able to know which one makes sense from the type of the variable anyway.

String handling is a nightmare due to the choice of using NUL-terminated strings and string.h being so barebones that you could reimplement most of it under an hour.

Some of the operator precedences make little sense.

Writing hygienic macros is an art more than a science which usually requires compiler extensions for anything non-trivial (lest you end up with a macro that evaluates its parameters more than once).

Aliasing was very poorly handled in earlier standards and they attempted to correct that in more modern revisions while still striving to let old code build correctly and run fast. So you have some weird rules like "char can alias with everything" for instance. Good luck explaining why that makes sense to a newbie without going through 30+ years of history.

The comma operator.

Undefined function parameter evaluation order.

I suspect that with modern PL theory concepts you could make a language roughly the size of C with much better ergonomics. I'm also sure that nobody would use it.

Re:Why I Don't Like Golang (2016) by timClicks on Wednesday June 12, 2019 @07:35PM (#20170450)
> (answer: if you generate the corresponding assembly jump table by hand "fall through" is the easiest and simplest case, so they probably kept it that way)

If this is true, then that makes perfect sense. C was attempting to look after its target market: assembly programmers.

Re:Why I Don't Like Golang (2016) by Boxxed on Wednesday June 12, 2019 @07:56PM (#20170577)
> Why do we need both . and -> ? The compiler is always able to know which one makes sense from the type of the variable anyway.

I've often wondered this myself. The best I can come up with is that the underlying code generation includes an additional dereferencing step with ->, so having both . and -> makes the compiler a little more transparent.

Of course, in C++ you really need both because overloading -> is nice for e.g. objects that want to look like pointers.

Re:Why I Don't Like Golang (2016) by jkoudys on Thursday June 13, 2019 @04:31AM (#20172782)
This was solved in rust by approaching it from the other side. You need to be explicit everywhere that a value is "borrowed", so while you never need a `->`, you'll still know it's dereferencing in the more natural place - before the variable, not as an implied step after.
Re:Why I Don't Like Golang (2016) by paulddraper on Thursday June 13, 2019 @12:39AM (#20171839)
My guess is they liked the explicitness of it.
Re:Why I Don't Like Golang (2016) by lone_haxx0r on Thursday June 13, 2019 @02:15AM (#20172241)
> Why do we have this weird incestuous relationship between pointers and arrays? It might seem elegant at first (an array is a pointer to the first element or something like that) but actually it breaks down all over the place and can create some nasty unexpected behavior.

> Why do we need both . and -> ? The compiler is always able to know which one makes sense from the type of the variable anyway.

You're contradicting yourself in a way.

Maybe K & R thought: "Why can't arrays decay to pointers? The compiler is always able to know which one makes sense from context anyway."

I agree with the your opinion about arrays/pointers, but disagree about ./->. A programmer reading the code might confuse a pointer for a non-pointer if you conflate . and ->

Re:Why I Don't Like Golang (2016) by dralley on Thursday June 13, 2019 @12:05AM (#20171712)
Well, there's Golang (despite it's flaws, and the different target audience)

Or Zig (which is less superficially C-like on the surface, but is going for the same simplicity and low-level-ness).

Re:Why I Don't Like Golang (2016) by kps on Wednesday June 12, 2019 @11:38PM (#20171616)
K&R C didn't have ‘undefined behaviour’, and I've become convinced that the original ANSI committee didn't intend to create the monster they did.

The reason is that Dennis Ritchie wrote a submission to the committee¹ that described the ‘noalias’ proposal as “a license for the compiler to undertake aggressive optimizations that are completely legal by the committee's rules, but make hash of apparently safe programs”, and, that “[i]t negates every brave promise X3J11 ever made about codifying existing practices, preserving the existing body of code, and keeping (dare I say it?) ‘the spirit of C.’”

Those comments describe what ‘undefined behaviour’ turned in to. The only reason dmr and others didn't make the same objections to it is that nobody realized at the time what the committee wording implied.

¹ available here: https://www.lysator.liu.se/c/dmr-on-noalias.html

Re:Why I Don't Like Golang (2016) by axaxs on Wednesday June 12, 2019 @06:42PM (#20170095)
Same here. K&R C is probably still my favorite programming book. I will admit that most of the examples I had to stop and think about, they all seemed 'cleverly' written. But in each case, it gave me pause, and taught me a new, often simpler way.
Re:Why I Don't Like Golang (2016) by tzs on Thursday June 13, 2019 @12:00AM (#20171697)
At the time it was written, there was a good chance that the person reading it would not be doing so at a computer. Their computer access was quite likely via a terminal on a time sharing system, that they had to share with others. They couldn't hog a terminal while reading a book and typing in examples from it.

So books of that day where written so you could learn a lot just from reading the book and thinking seriously about the examples, and working out the exercises in your head or on paper

It helped if every couple of days or so you could get some computer time and try out the things you learned, but it wasn't actually necessary. In the case of K&R, you could go through the whole book without touching a computer, and then one or two sessions afterwards trying things out could be enough to correct your misunderstandings.

I wish more books were like that today. Nowadays, they assume you are a computer all the while you are reading the book, and often depend on that when writing the text.

Re:Why I Don't Like Golang (2016) by throwaway34241 on Wednesday June 12, 2019 @07:16PM (#20170333)
The 'K' in K&R actually wrote a book on Go, "The Go Programming Language". I haven't used it personally but it has good reviews, so it might be a good resource for people who are curious about Go and know they like that writing style.
Re:Why I Don't Like Golang (2016) by synthmeat on Wednesday June 12, 2019 @07:38PM (#20170465)
It's a bit looser than whitebook, but it's still very much in the spirit of it. K really writes well.
Re:Why I Don't Like Golang (2016) by bitmadness on Wednesday June 12, 2019 @10:09PM (#20171279)
It's excellent, highly recommend.
Re:Why I Don't Like Golang (2016) by ryl00 on Wednesday June 12, 2019 @06:53PM (#20170183)
> The ANSI style function declaration was maybe the only innovation that came after that that significantly improved the language.

"const" as well (back ported from C++ ?). And being able to declare variables anywhere (instead of just at the beginning of a block)

Re:Why I Don't Like Golang (2016) by tom_ on Wednesday June 12, 2019 @07:29PM (#20170411)
What about aggregate literals, designated initializer syntax, _Generic, and thread.h?
Re:Why I Don't Like Golang (2016) by astrange on Thursday June 13, 2019 @03:22AM (#20172493)
Variable-argument macros, function prototypes (well, modules would be better…), // comments, stdatomic instead of 'volatile' hacks, _Bool, aligned_alloc, …
Re:Why I Don't Like Golang (2016) by CalChris on Wednesday June 12, 2019 @09:42PM (#20171164)
I’d add the deprecation of register. Not an innovation but an improvement nonetheless.
Re:Why I Don't Like Golang (2016) by SilasX on Wednesday June 12, 2019 @10:19PM (#20171316)
Interestingly, the high level language you implement for the nand2tetris course has this constraint, which makes writing the compiler easier
Re:Why I Don't Like Golang (2016) by brian_cunnie on Wednesday June 12, 2019 @11:42PM (#20171629)
I took that course, too! I loved it. Learned more about computers than any other of the many courses I took.
Re:Why I Don't Like Golang (2016) by SomeOldThrow on Wednesday June 12, 2019 @11:21PM (#20171562)
C is great for some things, but not at others. For instance, the same simplicity you laud makes it very difficult to work with strings or serialization—both are highly manual operations. So—I agree generally with your sentiment, but it's very far from a perfect language. If you're working with word-sized integers it's pretty damn good.

Also, ironically, I feel like C presents an excellent case for an evolved language, not a designed language. Its very name is derived from BCPL, as are many of the semantics and notation.

Re:Why I Don't Like Golang (2016) by AlchemistCamp on Wednesday June 12, 2019 @06:07PM (#20169846)
I just started digging into C a few years ago and was struck by the same. It's amazingly simple and the only "flaw" that leaps out at me is the precedence of & and | being higher than comparison operators. Other than that, and maybe the macro system, everything frustrating about learning it was due to the frustration of dealing with the machine rather than anything C itself imposed on me.
Re:Why I Don't Like Golang (2016) by throwaway34241 on Wednesday June 12, 2019 @07:56PM (#20170578)
The modern aggressive undefined-behavior based optimizations ruins any remaining appeal of the "simplicity" of C for me. The extremely broad definition of undefined behavior may allow the compiler to, for example, silently delete explicit checks for signed integer overflow [1] among other things and still claim standards compliance, but I don't think that programming model can reasonably be described as simple.

It many ways Go feels like an updated C. It retains most of the basic abilities of C, while cleaning up some things (headers, etc), having more basic libraries included, and choosing some defaults around things like out-of-bounds array access that are probably more appropriate for the majority of most programs (outside of particular hot loops, etc) in an era where software is often connected to the network and security is a bigger concern.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475, http://blog.llvm.org/2011/05/what-every-c-programmer-should-...

Re:Why I Don't Like Golang (2016) by astrange on Thursday June 13, 2019 @03:50AM (#20172606)
Lots of programs don't need efficiency in "hot loops". You want efficient code size everywhere (usually smaller is faster), and realtime programs like games are CPU-bound everywhere not just in one loop.

Undefined behavior is a great way to help the language help you; for instance, most loops look like infinite loops without it. All you need to do is test with ubsan to see if you're dynamically undefined anywhere.

Re:Why I Don't Like Golang (2016) by throwaway34241 on Thursday June 13, 2019 @07:47PM (#20179561)
>realtime programs like games are CPU-bound everywhere not just in one loop

Isn't this a simplification? Even for games, I'd expect most often to be GPU bound, then memory bandwidth bound, and only then CPU bound. Although I get that the hot loop thing/10% rule is not universally true for every CPU bound program (especially after code has already been heavily optimized).

But I'm not sure what you are disagreeing with. I didn't mean to totally deny the usefulness of UB in C++ (although I think the core rendering code of AAA games are more performance sensitive than "the majority of most programs"). I was just pointing out that C is certainly not as simple as it first appears, and many people new to it are not familiar with the rules around UB.

Go's able to design around some of the performance aspects without UB (using the native word size for ints by default can help some of the signed integer stuff, range loops can elide bounds checks, etc), but probably can't generate as optimal code as C can without dropping to assembly language.

Re:Why I Don't Like Golang (2016) by WalterBright on Wednesday June 12, 2019 @06:54PM (#20170190)
I love C, but it's biggest mistake is clearly the unstoppable decay of arrays to pointers:

https://www.digitalmars.com/articles/b44.html

A mistake that C++ missed an opportunity to fix.

Re:Why I Don't Like Golang (2016) by gerbilly on Thursday June 13, 2019 @09:24AM (#20174572)
I read the article you linked. It's too bad they didn't decide to pass a fat pointer with the array dimensions.

But when the article implies that null terminated strings and the problems associated with them are caused by arrays decaying to pointers, I get more skeptical.

I mean it's not as if arrays in C are bounds checked anyway, so how would that have helped implement strings any better?

I guess you could have bounds checked them in the stdlib code, but you certainly wouldn't have gotten it for free just by knowing the array dimensions.

Re:Why I Don't Like Golang (2016) by WalterBright on Thursday June 13, 2019 @02:41PM (#20177528)
> I mean it's not as if arrays in C are bounds checked anyway, so how would that have helped implement strings any better?

I've written an awful lot of C code, and I have much experience with the D way which uses arrays instead of null termination.

When I review a section of code consisting of strlen/strcat/strcpy/etc. I routinely find bugs in it, always centered around a mistake with the 0 termination.

When the array bounds are available, the compiler can optionally insert array bounds checks.

As for getting it for free, avoiding doing the strlen()'s is a big time saver.

Re:Why I Don't Like Golang (2016) by wbl on Wednesday June 12, 2019 @11:40PM (#20171619)
Arrays are for FORTRAN is I think the reason.
Re:Why I Don't Like Golang (2016) by ChrisSD on Wednesday June 12, 2019 @07:11PM (#20170301)
C can be quite complex once you get into all the abstractions it's using. And even for newbies I think the whole syntax around pointers is unnecessarily confusing (or at least people are often confused by it in a way they usually aren't when learning assembly). Not to mention how many keywords and symbols are overloaded and depend on their context for meaning.
Re:Why I Don't Like Golang (2016) by carterehsmith on Wednesday June 12, 2019 @09:16PM (#20171036)
>> C can be quite complex once you get into all the abstractions it's using.

Perhaps you were referring to C++, or some newer C dialect?

What I mean is, the K&R C had very few (if any) abstractions, other than those defined by preprocessor.

Like, you could look a the C code and pretty much "see" what the assembly code would look like after compiler did its work.

Re:Why I Don't Like Golang (2016) by ChrisSD on Wednesday June 12, 2019 @09:45PM (#20171181)
Yeah, on reflection you're right about that. At the time when the language matched the hardware the abstraction was much more literal. It was only when they diverged that optimizing compilers were needed and all the complexity was introduced in order to maintain the fiction that the hardware was still as simple as PDP-11.
Re:Why I Don't Like Golang (2016) by AlchemistCamp on Wednesday June 12, 2019 @08:02PM (#20170617)
To be fair, I never learned it in its heyday and even now, I've just worked on some toy utilities and an 8088 emulator.

I've never used it for work or open source or anything "real".

Re:Why I Don't Like Golang (2016) by maxxxxx on Wednesday June 12, 2019 @09:17PM (#20171042)
"The K&R book is worth a read if anyone missed it. It's beautifully written."

Agreed. I read the whole thing in a weekend and had a pretty good idea about pointers and stuff afterwards. I feel a lot of people have trouble with pointers didn't read it.

Re:Why I Don't Like Golang (2016) by stevekemp on Thursday June 13, 2019 @01:33AM (#20172064)
My programming journey went roughly:

* ZX Spectrum BASIC

* Assembly language (Z80)

* FORTH

* C

* ..

Learning C when I already knew assembly language made it obvious what pointers were. I suspect a programmer these days might start with javascript then jump to C and be a little mystified.

Re:Why I Don't Like Golang (2016) by 50 on Thursday June 13, 2019 @01:21AM (#20172015)
To piggyback this comment, does anyone know of any co's building something interesting mainly w/ the C programming language (and maybe even w/ Rust)? Also, that are usually open to interns/entry level programmers?
Re:Why I Don't Like Golang (2016) by borgel on Thursday June 13, 2019 @01:27AM (#20172036)
It's fairly common for folks doing embedded work. What are you interested in?
Re:Why I Don't Like Golang (2016) by 50 on Thursday June 13, 2019 @01:46AM (#20172126)
At the moment, I don't know. Do you any resources where one maybe may possible find something one would be interested in, in the C programming language domain? I've not thoroughly looked into compilers (i.e. LVMM) and operating systems but IIRC, they both went over my head.
Re:Why I Don't Like Golang (2016) by gerbilly on Thursday June 13, 2019 @09:04AM (#20174391)
I don't know about companies, but the linux kernels is C, git is written in C.
Re:Why I Don't Like Golang (2016) by didibus on Thursday June 13, 2019 @02:06AM (#20172213)
Hum... Sow why did you stop programming in C?
Re:Why I Don't Like Golang (2016) by gerbilly on Thursday June 13, 2019 @09:07AM (#20174415)
Server side Java paid the bills. :-)

And in some ways the industry stopped programming in C as much.

Re:Why I Don't Like Golang (2016) by didibus on Friday June 14, 2019 @04:31AM (#20181352)
Ah, makes sense.
Re:Why I Don't Like Golang (2016) by pjmlp on Thursday June 13, 2019 @12:59AM (#20171919)
Yes and I wasn't that impressed, given that I already had a experience with several other languages, including for doing low level stuff.

What impresses me is reading Burroughs manuals, or the manuals, books and research papers from Xerox PARC and IBM in the 70's.