4 ms·
I remember when I first learned C. I was 13 and having written assembly for years I finally got a machine that was actually equipped for running a full-blown C
by yason 13y ago
I remember when I first learned C.
I was 13 and having written assembly for years I finally got a machine that was actually equipped for running a full-blown C compiler. Compiling was slow and the produced code was slow but all I could think of was how easily I could generate [assembly] code with just a few lines of C. Loops, pointers, function calls, conditionals... just like that. Wow. So productive.
C felt like writing assembly but with much better vocabulary. C was to assembly language what English was to the caricatured "ughs" of the stone age.
I often compared the output of the compiler to what I would've written myself: the output was bloaty, the compiler was obviously not very smart, but it did do what I wanted and the computers had just got fast enough to be able to actually run useful programs written in C without slowing down the user experience. So you couldn't necessarily distinguish a program written in C from a program written in assembly, and you could "cheat" by choosing C instead. That was so exciting!
The thing is, however, that since these trivial insights of my youth it turns out that C actually never ran out of juice.
I still write C and I'm enjoying it more than ever.
In C, I've learned to raise the layers of abstraction when necessary and writing C in a good codebase is surprisingly close to writing something like Python except several dozen times faster and you can build your memory layout and little details the best suitable way you want, in various meaningful contexts.
I love doing all the muck that comes with C. String handling, memory management, figuring out the best set of functions on top of which to compose your program, doing the mundane tasks the best way in each case, and never hitting a leaky abstraction like in higher level languages.
The thing is, the time I "waste" doing all that pays me back tenfold as I tend to think about the best way to lay out my program while writing the low-level stuff. Because such effort is required there's a slight cost in writing code which makes you think what you want to write in the first place.
In Python you shove in stuff into a few lists and dicts, it just works and you will figure out later what was it that you really wanted and clean it up. But often you're wrong because it was so easy in the beginning. In C, I have to think about my data structures first because I don't want to write all that handling again for a different set of approach. And that makes all the difference in code quality.
However, I don't think you could impose a similar dynamic on a high-level language. There's something in low-level C that makes your brain tick a slightly different way and how you build your creations in C rather than in other languages reflects that. The OP said it very well: C reflects the reality of what your computer does. And I somehow love it just the way it is.
I've worked most of my career in higher level languages but I've never set C aside. It has always been there, even with Python, C++, or some other language. Now I'm writing C again on a regular basis and with my accumulated experience summed into the work it's truly rewarding.
- mironathetin 13y agoThis proves the point: any language is good as long as you really know what you are doing in that language.
- GotAnyMegadeth 13y ago>>+++++++++++++++++[-<+++++++>]<>>+++++++++++++++++++[-<++++++>]<>>++++++++++++[-<++++++++>]<+>>+++++++++++[-<+++++++++++>]<>>+++++++++++++[-<+++++++++>]<>>+++++++++++++[-<++++++++>]<>>+++++++++++++++++[-<++++++>]<+>>+++++++++++++++[-<+++++++>]<>>+++++++++++++++++++++++++++++[-<++++>]<>>++++++++++[-<++++++++++>]<+>>+++++++++++[-<++++++++++>]<>>++++++++[-<++++>]<>>++++++++++++[-<+++++++++>]<+>>+++++[-<++>]<>>++++++++++++[-<+++++++++>]<>>++++++++++++++[-<++++++++>]<>>+++++++++++[-<+++++++++>]<>>+++++++++[-<++++++++>]<+>>+++++++++++++++++++++++++++++++++++++[-<+++>]<<.<<<<<<.>>>>>.>>.<<<<<<.>>>.<.<<<<<.<.>.>>>>>.<<<<<<<<<<<.>>>>>>>>.<<<<<<<<<.>>>>.<<<<<.>>>>>>>>..>>.<<<<<<<<<<<.>>>>>>>.>.<<<.>>>>>>.<<<<<<<<.>>>>>>>>>>>>>>>.<<<<<<<<<<<<<<.<<<.>>>>>>>>>>.>>>>>.>>.<<<<<<..<<<.>.<<.>>>>>.
- claudius 13y agoPlease do people a favour and either format this as code or add more linebreaks, at the moment it makes stuff rather uncomfortable to read (until one clicks ‘Fit to Width’).
- nfoz 13y agoThat sounds like a flaw in HN moreso than the post.
- GotAnyMegadeth 13y agoYeah sorry, I wrote it like that to make it more confusing... But it's actually not too confusing. A brief explanation: The first 75%ish, the bit with all the +s, is filling up the elements of the BF array with the ASCII value of all of the letters contained in the sentence. And the second 25%ish is just scrolling to the right location and printing out the letters, hence lots of <>s and .s. During the fill up stage each ASCII value is made using two of it's factors, in an attempt to reduce the number of characters. So each ASCII letter looks like this N+[-<M+>] where N and M are the two factors chosen. For example 32, an ASCII space, is ++++++++[-<++++>], N=8, M=4. I'm sure this isn't the most character efficient for short sentences, but it might not be too bad for paragraphs. PS, in analysing that I have noticed there is a pointless extra > at the start.