Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Relearning/Modern C

Name: Anonymous 2013-07-25 18:55

Hi /prog/,
I want to re-learn C the right way.

When I was in college I took a bunch of courses (data structures, ADTs, algorithms) but I don't think I gained a deep knowledge of C.

What are some good books or resources on modern C usage (K&R is pretty dated)?

I'd like to do some HPC later in my life and I need to start somewhere.

Name: Anonymous 2013-07-25 19:05

K&R is not dated at all, maybe you should think of the areas that you want to study and how C is used in those areas, not about the language itself

Name: Anonymous 2013-07-25 19:26

you don't need a good book to learn C, you just need to start programming and keep learning new parts of the language. this is how you learn any language. if you really didn't even learn a single language at university, try an online course. im no expert, but im sure /prog/ knows some good books you can get for free

Name: Anonymous 2013-07-25 19:33

K&R

Name: Anonymous 2013-07-25 19:36

K&R is still a very good source of knowledgr.
After that, you can check the Structure & Interpretation of Computer Programs (SICP)

Name: Anonymous 2013-07-25 19:40

>>2
Bioinformatics/statistics, which would be mostly R and Python. I would like to be able to implement what R does, before learning R.


>>3
I could do "Learning C The Hard Way" but if it's anything like the Python version, I won't learn anything about how my code works, just how to write it.

I think too many people "just code" without regard to best practice or design (not that I'm implying you do).

My boss seriously used a do {} while (false); with breaks as a ghetto goto.

Name: Anonymous 2013-07-25 19:42

>>6
Learning C The Hard Way is not as bad as the Python version. If you want to read it, I'd say go for it.

But K&R is still a valid source.

Name: Anonymous 2013-07-25 19:47

>>7
Is there anything in LCTHW I should take with a grain of salt? I will probably read K&R or another book alongside.

Name: Anonymous 2013-07-25 19:51

>>8
Yes. Everything.

He kind of abuses preprocessor macros, and uses gotos ocasionally.

Name: Anonymous 2013-07-25 19:54

>>6
For that field it's better to just learn the math, then use SAS or R or whatever's easiest to implement your analysis.

Name: Anonymous 2013-07-25 20:34

For starters, read the standard.

Name: Anonymous 2013-07-25 20:45

>>9
Good to know

Are "C Programming: A Modern Approach" or "Expert C Programming: Deep C Secrets" any good? I've seen them recommended before.

>>10
I should, but it's even harder to find materials to learn from outside of a class for this. I don't think I could learn the math in a vacuum.

Most intro statistics material I've found is just learning techniques/distributions but now when to use what.

Name: Anonymous 2013-07-25 20:53

>>12
That's where you need to read journal articles relevant to your particular study, specifically the methods section.

Name: Anonymous 2013-07-25 21:18

K&R is dated. Read SICP.

Name: Anonymous 2013-07-25 21:21

SICP is dated. Read why's poignant guide to Ruby.

Name: Anonymous 2013-07-25 22:33

Expert C Programming: Deep C Secrets
You can tuna filesystem, but you can't fsck a fish!

Name: Anonymous 2013-07-25 22:37

>>16
I never understood this joke.

Name: Anonymous 2013-07-25 23:06

>>17
Then you should be able to get away with murder.

Name: Anonymous 2013-07-26 1:34

>>16
I fscking lol'd!

Name: Anonymous 2013-07-26 5:16

>>16
Selected quote from the book:
To this day, many C programmers
believe that "strong typing" just means pounding extra hard on the keyboard.

Name: Anonymous 2013-07-26 5:43

>>19
Who is lol'd?

Name: Anonymous 2013-07-26 7:38

>>21
I've been penetrating this hacker sub-culture for a while now and maybe I can shed some light on this word.

LOL, or "laughing-out-loud", seems harmless. But in actuality it is used to identify other hackers in places where they are frowned upon. Many of today's youth has started to use LOL thinking it's the online version of "laughing", but they don't understand.

LOL is the the exact equivalent of a gang sign.

To differentiate between a user's harmless use of LOL and a symbol of "hackerdom", a lot of times there's the "'D" attached to the end. It becomes LOL'D. It comes from the last letter in the word "hacked".

Just like contractions use "'" to replace letters in common phrases (like "can't" uses the ' to replace the letters "no" in "cannot"), the whole phrase of LOL'D spelled out is "look out, line hacked".

It's a phrase dating back to when hackers used to mess with phone systems, they would say "look out, line hacked" so the other person wouldn't say anything incriminating -- they knew someone else was on the line with them. Now days, it's simply a common greeting.

Please, use this knowledge and don't throw LOL'D around because you don't know who you're attracting.

Name: Anonymous 2013-07-26 11:02

Name: Anonymous 2013-07-26 17:59

>>20
Read the part after that (evolution of the language K&R->ANSI) was pretty interesting too.

Name: Anonymous 2013-07-27 5:48

>>17
You can tune a filesystem, but you can't tuna fish!

Name: Anonymous 2013-07-28 10:42

SICP is useful if you're a 1st of 2nd year in college- or pragmatically on a similar level of where they're at. Once you get past discrete mathematics, there is really no benefit to SICP

Name: Anonymous 2013-07-28 11:10

>>26
Bullshit.

Name: Anonymous 2013-07-28 13:35

>>26
Have you red ur SICP?

Name: Anonymous 2013-07-28 15:23

>>28
Have you read your New Oxford American Dictionary?

Name: Anonymous 2013-07-28 15:38

>>29
I don't trust the British to write an American Dictionary. It's Webster or nothing.

Name: Anonymous 2013-07-28 15:48

>>30
But the New Oxford American Dictionary is optimised.

Name: Anonymous 2013-07-28 16:07

>>31
optimised
See? This is why the world hates you. You Brits have no respect for the letter `z'.

Name: Anonymous 2013-07-28 16:13

>>32
Well, guess what.
http://upload.wikimedia.org/wikipedia/commons/d/dc/Israelinbritainb00garn_0005.jpg
Transcript:
ISRAEL IN BRITAIN

A BRIEF STATEMENT OF THE EVIDENCES IN PROOF OF THE ISRAELITISH ORIGIN OF THE BRITISH RACE

http://en.wikipedia.org/wiki/British_Israelism

Shalom, mate! Shalom, mate!

Name: Anonymous 2013-07-28 16:28

>>33
See, again, you can't even spell Izrael properly!

Name: Anonymous 2013-07-28 17:06

>>32
I think it's even worse that you stupid American's can't pronounce `z' correctly. ZED, ZED, NOT ZEE, ZED IS THE STANDARD!!!

Name: Anonymous 2013-07-28 17:22

Maybe you should try java: http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.html

Or php, which is an even better choice. Especially with Zend Framework. It is a general purpose language, with namespaces and great support for closures. Everything an enterprise enabled coder needs.

Name: Anonymous 2013-07-28 17:29

>>36
Oh, you've been trolling so far! You had me going there for a good fucking while.

Name: Anonymous 2013-07-28 17:43

>>37

You cannot discern a php programmer from a troll.

For example:

I want to create a daemon/Linux service. Here is an example of how to run a process that has "throttle control"

// You must set these
//
// max_execution_time = 0
// max_input_time = 0

function doProcess() {
    echo "Start"."\n";
    usleep(10000);
    echo "Stop"."\n";
    return false;
}

function manageProcess() {
    // Setup data
    $runsPerMinute = 200;
    $maxMinuteAverage = 5;
    $waitIfNotWorking = 120; // seconds

    // Conversion
    $microsPerSecond = 1000000;

    // Statistical Info
    $currentMinute = 0;
    $minute = -1;
    $countPerMinute = array();
    $sumPerMinute = array();

    // Totals
    $totalProcessTime = 0;
    $totalCounts = 0;

    while (true) {
        $timestart = microtime();
        $performedWork = doProcess();
        $timeend = microtime();

        if (!$performedWork) {
            // Statistical Info
            $currentMinute = 0;
            $minute = -1;
            $countPerMinute = array();
            $sumPerMinute = array();

            sleep($waitIfNotWorking);
        } else {

            $ts = split(" ",$timestart);
            $te = split(" ",$timeend);

            $te[0] = ($te[0] * $microsPerSecond) - ($ts[0] * $microsPerSecond);
            $te[1] = ($te[1] - $ts[1]) * $microsPerSecond;

            $processTime = $te[0] + $te[1];

            if (date("i")<>$minute) { // We are NOT in the same minute
                // Reset the new minute
                $minute = date("i");
                $currentMinute = ($currentMinute+1) % $maxMinuteAverage;

                // Remove Statistical Information from the minute we are expiring.
                if (isset($countPerMinute[$currentMinute])) {
                    $totalProcessTime = $totalProcessTime - $sumPerMinute[$currentMinute];
                    $totalCounts = $totalCounts - $countPerMinute[$currentMinute];
                }

                $countPerMinute[$currentMinute] = 0;
                $sumPerMinute[$currentMinute] = 0;
            }

            $countPerMinute[$currentMinute] = $countPerMinute[$currentMinute] + 1;
            $sumPerMinute[$currentMinute] = $sumPerMinute[$currentMinute] + $processTime;

            $totalCounts = $totalCounts + 1;
            $totalProcessTime = $totalProcessTime + $processTime;

            $averageRuntime = round($totalProcessTime / $totalCounts);

            $waitTime = (($microsPerSecond*60) / $runsPerMinute) - $averageRuntime;

            usleep($waitTime);
        }
    }

}

manageProcess();


This shit will happily eat away all your memory. Is he serious or not?

Name: Anonymous 2013-07-28 17:52

>>38
Don't know.

Don't change these.
Name: Email:
Entire Thread Thread List