Live data from Hacker News

Tenacious C: Cool C IDE

tenaciousc.com

31–40 of 43 posts

Re: Tenacious C: Cool C IDE

#31
post #20

Good top post on the blog page, made me lol: 'I like C, but I have to admit that, sometimes, “The Old Man of Programming” can be a bit of a killjoy. This is one of the most exciting eras in computer history, but lately, C’s acting like he doesn’t even want to have a good time. While the cool kids like Ruby and Haskell are living it up, C’s over in the corner obsessing over bits and bytes and memory alignment and poin…

The blog post is excellent. It led me to this: http://www.lysator.liu.se/c/duffs-device.html I've programmed in C a fair amount, but I am incapable of understanding the construct contained therein. Specifically, the interaction of the switch and the loop and all those fall-through cases. I would absolutely love it if some C-guru hn-er could describe it in layman's terms?

A good explanation was posted here a few days ago: http://news.ycombinator.com/item?id=1896643

(After looking it up, I discovered it was from the same site.)

Re: Tenacious C: Cool C IDE

#32
post #31
post #20

Earlier quoted context omitted.

The blog post is excellent. It led me to this: http://www.lysator.liu.se/c/duffs-device.html I've programmed in C a fair amount, but I am incapable of understanding the construct contained therein. Specifically, the interaction of the switch and the loop and all those fall-through cases. I would absolutely love it if some C-guru hn-er could describe it in layman's terms?

A good explanation was posted here a few days ago: http://news.ycombinator.com/item?id=1896643 (After looking it up, I discovered it was from the same site.)

Wow, serendipitous, thanks.

Re: Tenacious C: Cool C IDE

#33
post #20

Earlier quoted context omitted.

The blog post is excellent. It led me to this: http://www.lysator.liu.se/c/duffs-device.html I've programmed in C a fair amount, but I am incapable of understanding the construct contained therein. Specifically, the interaction of the switch and the loop and all those fall-through cases. I would absolutely love it if some C-guru hn-er could describe it in layman's terms?

The other two comments are right, but the context you might be missing is why you would unroll a loop. Due to cache behavior (and other low-level details), doing something eight times and then checking if it needs to be done another eight times has less overhead than checking after each loop iteration. Why eight? It was probably a sweet spot in time vs. code size, at some point. (Processor caches are larger now.) Duf…

Thanks. Lua is on "my list" actually, Fortunately I am only forced to work in C for one particular project (sorry if that sounds negative, C-heads, I'm just a messy enough person to require garbage collection to stop me from messing up too bad).

Re: Tenacious C: Cool C IDE

#34
post #33

Earlier quoted context omitted.

The other two comments are right, but the context you might be missing is why you would unroll a loop. Due to cache behavior (and other low-level details), doing something eight times and then checking if it needs to be done another eight times has less overhead than checking after each loop iteration. Why eight? It was probably a sweet spot in time vs. code size, at some point. (Processor caches are larger now.) Duf…

Thanks. Lua is on "my list" actually, Fortunately I am only forced to work in C for one particular project (sorry if that sounds negative, C-heads, I'm just a messy enough person to require garbage collection to stop me from messing up too bad).

Lua is, IMHO, "Javascript done right". It's nice to have the option of writing C code but letting Lua do garbage-collection on common userdata.

Lua replaced Python for me - it's a great language on its own. TCO and pattern matching (http://github.com/silentbicycle/tamale) go a long way.

Re: Tenacious C: Cool C IDE

#35
post #19

What a joke. Things like this – and the rhetoric on his site – make systems programming look like more of a dark art than it actually is. If you're a programmer, should know how your computer works; if pointers are too "hard" for you, you're in the wrong business. You're settling for mediocrity and belittling your own intelligence by assuming you're not capable of tackling this stuff the same way everyone else has.

How many programmers today do not know what what a pointer is, or even if they do, how to use/understand them? I'm sure the number is growing, considering the prevalence of languages where pointers aren't even a consideration. Now if you don't like the features of this IDE, that's fair. You're free to stick to whatever you're currently using. Given that Tenacious C will be a paid app when it is done, I doubt I'll rea…

Gah, I can't remember the details now, but I'm sure one of the interviewees in Coders At Work talks about this point. Something about how the notion of pointers/references is fundamentally wrong because it doesn't reflect our understanding of objects in RL.

I realise I'm being tangential now, but thought I'd mention it anyway.

Re: Tenacious C: Cool C IDE

#36
post #30

Earlier quoted context omitted.

It's really less complex than it appears, especially once you grok that switch/case is just a computed goto; cases are just labels. So, the idea behind Duff's Device is just to unroll a loop, dealing in an elegant (some would say abhorrent - they're wrong) way with the "leftover" portion. So, the canonical Duff's is copying shorts, with the copy loop unrolled to eight copy statements inside the loop. If you want to c…

Okay, this definitely helps but I'm still struggling (sorry), I'm probably focusing too much on minutiae but: * At the static level, what does it mean to start the loop at `case 0` then fall through to the termination of the loop? Part of me is surpisued that it even compiles (again, sorry); it's like the mechancis of the loop itself become dependent on the runtime input, at which point my brain begins to frazzle gen…

- case 0 is first, because this indicates that the modulo operation in the switch statement (count % 8) has no remainder, i.e., all 8 copy instructions should be executed. So, this is first because of the properties of the modulo operation.

- the to pointer is not incremented because it corresponds to a single memory mapped output register (http://en.wikipedia.org/wiki/Duff%27s_device#Original_versio...). It does not have anything to do with the use if Duff's device.

hth

Re: Tenacious C: Cool C IDE

#37
post #16

Earlier quoted context omitted.

It's just that you write it once and it can run anywhere without "installing" many dependencies other than a browser. No fugly GUIs, no inconsistencies, etc. By web-based I didn't mean it to be on the Internet.

So basically, "web-based" is the new portable GUI library.

Absolutely — you just open a high port on localhost and open the URL in a browser. I've used this technique before on consulting projects with great success.

Re: Tenacious C: Cool C IDE

#38
post #20

Earlier quoted context omitted.

The blog post is excellent. It led me to this: http://www.lysator.liu.se/c/duffs-device.html I've programmed in C a fair amount, but I am incapable of understanding the construct contained therein. Specifically, the interaction of the switch and the loop and all those fall-through cases. I would absolutely love it if some C-guru hn-er could describe it in layman's terms?

The other two comments are right, but the context you might be missing is why you would unroll a loop. Due to cache behavior (and other low-level details), doing something eight times and then checking if it needs to be done another eight times has less overhead than checking after each loop iteration. Why eight? It was probably a sweet spot in time vs. code size, at some point. (Processor caches are larger now.) Duf…

> make sure it's a hotspot first

A wise friend of mine once said it's much easier to optimize a correct program than debugging a heavily optimized one.

Re: Tenacious C: Cool C IDE

#39
post #37

Earlier quoted context omitted.

So basically, "web-based" is the new portable GUI library.

Absolutely — you just open a high port on localhost and open the URL in a browser. I've used this technique before on consulting projects with great success.

That's not really web-based then, more HTML-based.

Re: Tenacious C: Cool C IDE

#40

Neat, but I question the Windows only choice here. A lot of C programmers are developing on a *nix platform. But I see this as being more useful for students learning C and memory management. It's a neat project and might recommend it to students but I'll stick to vim, myself.

They seem to be targeting the embedded market, which is mostly Windows based.
Post reply on HN