Live data from Hacker News

The Unreasonable Effectiveness of C

damienkatz.net

371–380 of 394 posts

Re: The Unreasonable Effectiveness of C

#371
post #368

Earlier quoted context omitted.

I think you mean: $ echo "$PARENT" | sed 's_r/x_r$/_' P.S. It's a bit hard to believe I misread that... thanks.

My sed knowledge isn't very advance. What is your invocation supposed to do?

You can use any separator you want in an s/../../ expression, not just /, in this case the separator is _ (this technique allows you to use / without creating a "picket fence": s/r\/x/r$\//).

So the regex just means replace "r/x" with "r$/".

Re: The Unreasonable Effectiveness of C

#372
post #349

Earlier quoted context omitted.

No, he meant: $ whoami | sed 's/hr$/x/'

I think you mean: $ echo "$PARENT" | sed 's_r/x_r$/_' P.S. It's a bit hard to believe I misread that... thanks.

Random tip: in Bash (at least), you can execute the previous command with some changes using ^..^..^, e.g.

  $ echo john regehr | sed s/hr/xx/
  john regexx
  $ ^r/x^r$/^
  echo john regehr | sed s/hr$/x/
  john regex
(The second last line is just bash printing the new command.)

Re: The Unreasonable Effectiveness of C

#373
Thank you for writing that. It makes me feel like I'm not completely insane because there are other people who think the same. If you know what you are doing - C is your best option. The problem is that there are thousands of people these days who do not know what they are doing and basically they do not understand how computers and operating systems work. They need very high levels of abstraction which is costly and usually introduces a whole bunch of new problems. Add all those weird frameworks/libraries on top of that and you end up paying 10x more for hardware and get 10x slower product. Though, it's really hard to find a decent and productive C programmer today, so people settle for what's easily available. Another problem is that those "cheaper resources" are defining what programming is these days. I think there is a huge difference between programming and scripting... Call me Dino. BTW, loved the banana example :)

Re: The Unreasonable Effectiveness of C

#374
post #277

I'm a language design buff, so you might be able to guess my biases: FP is good, OO is bad, every language should have higher-order functions, yadda yadda. I finally decided to get a deeper knowledge of C, something I've been saying I "should do" for years. I'm learning it via Zed Shaw's Learn C The Hard Way and I'm very impressed by the language. It does what it does very well. I wouldn't use it for a complex web ap…

I'd be interested to hear what you think of D.

I don't know much about it.

What's its niche? C's major win is the ability to explicitly manage (and, thereby, reason about) memory. Garbage collection is great but I tend to associate it with high-level languages like Python, Haskell and Clojure.

I'm sure there is a niche for GC'd mid-level languages (e.g. Go) but I'm not yet experienced with them enough to know what it is.

Re: The Unreasonable Effectiveness of C

#375

I'm a language design buff, so you might be able to guess my biases: FP is good, OO is bad, every language should have higher-order functions, yadda yadda. I finally decided to get a deeper knowledge of C, something I've been saying I "should do" for years. I'm learning it via Zed Shaw's Learn C The Hard Way and I'm very impressed by the language. It does what it does very well. I wouldn't use it for a complex web ap…

What do you think about Factor?

Re: The Unreasonable Effectiveness of C

#376

Earlier quoted context omitted.

"it is still the most practical language" Only in extremely limited contexts: low-level code for operating systems that happened to have been written in C. Otherwise, there is a better language for pretty much every use-case of C.

low-level code for operating systems that happened to have been written in C You say that like it is an accident that just about every major OS today is written in C or C/C++

"You say that like it is an accident that just about every major OS today is written in C or C/C++"

Is there some technical feature of C or C++ that makes those languages good for writing OSes, or that made OSes written in those languages overwhelmingly successful? You might argue that the simplicity of a C compiler made Unix successful because it helped with portability, but C is by no means unique in this regard -- a Lisp compiler can be equally simple, and can be used to bootstrap a more sophisticated compiler. Really, Unix won because the only real competition Unix vendors faced in the minicomputer and workstation market came from other Unix vendors; C was riding on the coattails of Unix. One would be hard-pressed to argue that Windows won because C++ is a great language, especially considering how Windows was plagued with bugs and security problems during its rise to prominence in the 90s (many of which resulted from bad pointer mechanics, which is what happens when you use a language that requires you to juggle pointers).

Re: The Unreasonable Effectiveness of C

#377
post #375

I'm a language design buff, so you might be able to guess my biases: FP is good, OO is bad, every language should have higher-order functions, yadda yadda. I finally decided to get a deeper knowledge of C, something I've been saying I "should do" for years. I'm learning it via Zed Shaw's Learn C The Hard Way and I'm very impressed by the language. It does what it does very well. I wouldn't use it for a complex web ap…

What do you think about Factor?

Stack languages look really cool to me. I have no idea whether they're practical.

For language beauty, the ones with simple syntax (e.g. Lisps, Forth, q) win. However, for a large production system, I'd be more inclined to use something with static typing.

Static typing falls down in a different way with large systems-- compile speed-- but if the thing's not being changed on a regular basis, that's not a huge issue.

Re: The Unreasonable Effectiveness of C

#378
post #132

Earlier quoted context omitted.

The Burroughs was a stack machine, but that's only the beginning. Look at how it handled addressing hunks of memory. Bounds checked memory block references were a hardware type, and they were the only way to get a reference to a block of memory. So basically, null pointers didn't exist at the hardware level, nor out of bounds writes to arrays or strings. Similarly, code and data were distinguished in memory (by high…

>C defines a virtual machine consisting of a single, contiguous block of memory with consecutive addresses, and a single core processor that reads and executes a single instruction at a time. This is not true of today's processors, thanks to multicores, multiple pipelines, and layers of cache. Which is true, for a rather stretched definition of "virtual machine"(which falls apart at the kernel level, because it's pre…

FYI when discussing the ISO C standard the term "virtual machine" is well understood to be the abstracted view of the hardware presented to user code. Things well defined in it are portable, things implementation defined are non-portable, and things undefined should be avoided at all costs.

Re: The Unreasonable Effectiveness of C

#379
post #361

The C language is wonderful is because you can look Quake I, II, III, and instantly see the intent. In C++ you can't.

Quake3 is written in C++

Although Quake 3 contains some C++ code (in splines/ iirc), it's probably 99% pure C code so I don't think it can be labeled as being written in C++ .

https://github.com/id-Software/Quake-III-Arena

Re: The Unreasonable Effectiveness of C

#380

Earlier quoted context omitted.

> C is the language that doesn't force any preconceived notions about how the world should work onto you Some preconceived notions forced upon you by C, off the top of my head: - problems should be solved by describing a linear sequence of steps (as opposed to logic/declarative programming) - a variable can have different values at different times in the execution of a program (in contrast to standard mathematical co…

problems should be solved by describing a linear sequence of steps (as opposed to logic/declarative programming) Linear sequences of steps processing data arrayed in some linear fashion or others is what computers do. It is certainly what a single core does. So you would rather have someone else write a C program for you that abstracts it away and calls it a new way to program? That's k, just know that you'll still h…

> Linear sequences of steps processing data arrayed in some linear fashion or others is what computers do

No, it's what some computers do. It's almost certainly not what the computer you are using currently does. It's quite possible it's not what any computer you've ever used does.

> So you would rather ...

I'm not expressing a preference. If you think I was, you've misunderstood my comment. I'm making observations, not judgements. I'm not anti-C, it's a fine language for many things; however I do think that the articles author is not being as even-handed as he claims when it comes to some of the short-comings of C.

> Your problem is nomenclature?

Again, I'm not making a judgement. C exists in a paradigm where writing

    x = 3
    x = 4
makes sense. In other paradigms it would be logically inconsistent.

>>there is random access storage of information (with constant time access and update)

>Again, that's just how "the world" works.

That's absolutely not how "the world" works. Again, you've probably never even used a computer where it was true.

> dissing C is just shitting where you eat. The only reasons I can imagine for it are jealousy or ignorance.

I don't think I've made any statement anywhere in this discussion that's "dissing C".

Post reply on HN