News for hackers. Stuff that matters.
Re:How to Design Programs 2nd Edition [free] by michidk on Saturday April 08, 2023 @07:12AM (#35492245)
I read the abstraction chapter, but I really have a hard time translating those concepts to different languages like Rust. Seems like this book is very specific to this Racket-based teaching language?
Re:How to Design Programs 2nd Edition [free] by zabzonk on Saturday April 08, 2023 @07:24AM (#35492297)
concepts presented seem pretty basic to any programmming language - what were you having problems with?
Re:How to Design Programs 2nd Edition [free] by czx4f4bd on Saturday April 08, 2023 @07:51AM (#35492400)
It uses Racket as a teaching language, but the concepts should be generally applicable.

The preface explains the goals and ideas behind the book: https://htdp.org/2023-3-6/Book/part_preface.html

Re:How to Design Programs 2nd Edition [free] by Herval_freire on Saturday April 08, 2023 @08:14AM (#35492507)
Rust sacrifices modularity for performance. You're going to have to clone everything if you want to follow along with rust.

Additionally you have to use generics and trait bounds extensively for some equivalent function in rust.

Re:How to Design Programs 2nd Edition [free] by synergy20 on Saturday April 08, 2023 @10:30AM (#35493495)
isn't rust said to be good for high performance?

it's also move by default instead of copy, that saves memory copies which is a good thing?

I'm lost in 'clone everything', not a rust programmer per se.

Re:How to Design Programs 2nd Edition [free] by Herval_freire on Saturday April 08, 2023 @12:13PM (#35494721)
Yes. one of the things rust sacrifices for high performance is modularity. Rust is a better language for safety and high performance, however it is not the best language in terms of modularity.

Haskell takes the crown for modularity and safety but as a result it is less performant then rust.

Move by default is not modular. Why? Because it is a mutation. The state of your program changes after a move and your program must be structured around that.

That variable that was moved can no longer be reused in the same context so your program is less modular as a result as the definition of modularity is high reusability of modules.

Clone just means pass by copy. Make a copy and then pass the value. Pass by immutable reference works too. Just keep everything immutable for maximum modularity. But if you want to mutate things and keep things relatively modular then pass by copy (aka clone) is the best alternative.

All in all rust is typically harder to program for and harder to make elegant because of all the anti-modularity features used to increase performance and safety.

Re:How to Design Programs 2nd Edition [free] by lillywastaken on Saturday April 08, 2023 @01:51PM (#35495836)
Though Haskell's module system is somewhat a wart of the language, and I say this as someone who loves Haskell. "Hierarchical" modules in Haskell2010 are literally just modules with periods in the name, and it lacks the power of ML and Agda's parameterized modules. The other major wart with Haskell to me is the record types.
Re:How to Design Programs 2nd Edition [free] by chongli on Saturday April 08, 2023 @08:18AM (#35492520)
The racket-based teaching language is actually a series of languages that progress in complexity. The beginner version is very simplified, which makes it perfect for students working on assignments since they won’t be distracted by advanced language features.

The specific concepts in the book translate to other functional programming languages, and almost not at all to imperative programming.

The general thesis of the book, that you should follow a design recipe, is a universal one. It teaches you how to design your functions and write the documentation before you begin the implementation. This is also the part that students are the worst at, in my experience (as a TA for a first year course based on this book, twice).

Re:How to Design Programs 2nd Edition [free] by zabzonk on Saturday April 08, 2023 @08:32AM (#35492609)
> This is also the part that students are the worst at

isn't everyone?

as some one that worked for years as a trainer at a tech commercial training company, i eventually came up with two sort of realisations:

a) teaching HOW to program is really, really hard. i was never at all good at it, though i could teach programming languages and system architectures rather well.

b) when you start out, you cannot write too many functions.

i'm not sure that the book in question would entirely agree with this. any course using it for teaching would need lots of input from the physical human instructor.

Re:How to Design Programs 2nd Edition [free] by chongli on Saturday April 08, 2023 @09:29AM (#35492889)
isn't everyone?

…

a) teaching HOW to program is really, really hard. i was never at all good at it, though i could teach programming languages and system architectures rather well.

It really is a way of thinking. It takes deliberate practice to develop. Students are often uninterested in developing this kind of soft skill set because it doesn’t provide immediate returns when it comes to finishing assignments.

It’s a real shame. In the long run it pays huge dividends.

Re:How to Design Programs 2nd Edition [free] by zabzonk on Saturday April 08, 2023 @11:04AM (#35493883)
yes, of course it does. but can you teach it??? for me, when presented with a problem, the tech solution normally pops into my brain, like the lightbulb in cartoons, if it doesn't, it's (not always) often an early-warning that i have misunderstood the problem, or that it is too difficult for me. you can't teach this stuff.
Re:How to Design Programs 2nd Edition [free] by troupe on Saturday April 08, 2023 @10:00AM (#35493203)
The "How To Code" EdX classes taught by Kiczales follow the method in HtDP.

https://www.edx.org/bio/gregor-kiczales

Re:How to Design Programs 2nd Edition [free] by nixpulvis on Saturday April 08, 2023 @11:20AM (#35494091)
As a functional language (or family of languages in this case), Racket should translate very easily into other languages with the ability to create and call functions. Not having some form of polymorphism will make it hard to follow many of the examples and exercises though, so perhaps

I actually think the materials in HtDP complements learning Rust pretty well. What makes Rust interesting exists almosy