News for hackers. Stuff that matters.
Re:First THINK C Program (2020) by azinman2 on Sunday August 15, 2021 @01:42PM (#28190646)
How does programming in Think C or Turbo Pascal compare to the new m68k compilers? If I were to make a program from scratch, what’s my best environment if I care about performance? I gather the old C and Pascal compilers were probably not very optimized and that assembly would be needed quite a bit, but given how good modern compilers are, is that true now?
Re:First THINK C Program (2020) by jhoechtl on Sunday August 15, 2021 @02:35PM (#28191175)

    (n > 0) && printf("0  ", 0);
Never saw something like this. A conditional execution without an if?
Re:First THINK C Program (2020) by kmill on Sunday August 15, 2021 @03:15PM (#28191573)
In C, the && and || operators are short-circuiting. This works (in that it doesn't give a compiler error) because printf returns an int.

I remember following a really old Python tutorial that suggested the way to write inline if/else statements was

  C and A or B
which makes use of similar short-circuiting behavior. Nowadays this is written as

  A if C else B
The and/or version depends on A being truthy, otherwise it evaluates both A and B, giving the value of B.
Re:First THINK C Program (2020) by qunabu on Monday August 16, 2021 @02:55AM (#28195600)
this is a classic functional programming that prefers expression like above instead of `if` statements.
Re:First THINK C Program (2020) by duskwuff on Sunday August 15, 2021 @03:36PM (#28191768)
Oh, I like the writing style here. Shades of Aphyr's "Interviews" series:

https://aphyr.com/posts/341-hexing-the-technical-interview

Re:First THINK C Program (2020) by rak1507 on Sunday August 15, 2021 @04:30PM (#28192236)
Check out the other articles too. https://beyondloom.com/blog/denial.html was posted on HN recently, I wonder if that's how the poster found it.
Re:First THINK C Program (2020) by mrpippy on Sunday August 15, 2021 @02:08PM (#28190869)
More fun building Pararena 2 in THINK C 6 (with Basilisk):

https://bslabs.net/2016/11/13/building-pararena/

Re:First THINK C Program (2020) by OnlyMortal on Sunday August 15, 2021 @04:12PM (#28192082)
I was using MPW C back in those days. Great for shell scripting.

Think C was a fast compiler I used briefly as “Think C With Objects”. Objects were done with Handles so you had to lock an object before using it. The OS could move the backing memory of a Handle around as memory demands required.

Re:First THINK C Program (2020) by cable2600 on Sunday August 15, 2021 @12:56AM (#28186373)
Should have started with Hello world first. Introducing newbies to variables to do a Fibonacci sequence is very hard for them.

Nice use of the vMac emulator.

Re:First THINK C Program (2020) by kmill on Sunday August 15, 2021 @03:09PM (#28191515)
Don't you think it's a bit odd that the example program uses short-circuiting booleans as conditionals and uses the fabled downto operator?[1] The article's not teaching how to program, it's just showing you how to set up THINK C -- the intro suggests that the target audience is programmers ("I can see [...] that you, too, are a programmer.")

[1] https://stackoverflow.com/questions/1642028/what-is-the-oper...

Re:First THINK C Program (2020) by setpatchaddress on Sunday August 15, 2021 @01:23PM (#28190508)
If one’s going to argue about choice of first programs, a proper Hello World on classic macOS requires the use of the Mac Toolbox. Using the bundled Think C console isn’t really producing a Mac-native program.
Re:First THINK C Program (2020) by wwweston on Sunday August 15, 2021 @02:05PM (#28190843)
Where's a good place to find a guide to that?
Re:First THINK C Program (2020) by duskwuff on Sunday August 15, 2021 @02:58PM (#28191400)
The definitive reference is Apple's own Inside Macintosh. Many parts of that are still available on the Apple developer web site, e.g.

https://developer.apple.com/library/archive/documentation/ma...

https://developer.apple.com/library/archive/documentation/ma...

For a more directed and more C-oriented walkthrough, the Macintosh C Programming Primer was a pretty common go-to. It's been out of print for ages, of course, but there's a PDF available at:

https://vintageapple.org/macprogramming/pdf/Macintosh_C_Prog...

Re:First THINK C Program (2020) by lioeters on Sunday August 15, 2021 @02:29PM (#28191118)
You can search for "Toolbox" and "Tool Box" here:

Vintage Macintosh Programming Book Library - https://vintageapple.org/macprogramming/