Recent

Author Topic: "set of": order of elements  (Read 2807 times)

440bx

  • Hero Member
  • *****
  • Posts: 5080
Re: "set of": order of elements
« Reply #30 on: February 07, 2025, 10:11:31 am »
Asm is really bad first language candidate.
Personally, I think it's likely the best choice if the goal is to learn how a computer really works.

What can make it very undesirable to some is the large amount of information that must be learned which contributes to a fairly steep learning curve but, a programmer who is comfortable with assembler can learn a language like non-OOP Pascal or C fairly quickly.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8334
Re: "set of": order of elements
« Reply #31 on: February 07, 2025, 11:44:52 am »
Asm is really bad first language candidate.
Personally, I think it's likely the best choice if the goal is to learn how a computer really works.

What can make it very undesirable to some is the large amount of information that must be learned which contributes to a fairly steep learning curve but, a programmer who is comfortable with assembler can learn a language like non-OOP Pascal or C fairly quickly.

Practitioners should certainly be exposed to assembly language and to a "typical" machine architecture with registers etc. fairly early on. However I'm unconvinced that that should be right at the start of their training, since unless the opcodes are heavily augmented by "begin", "end" macros etc., i.e. the sort of technology with which Wirth was familiar when designing PL/360 and then Pascal, it risks undermining the importance of the structured programming philosophy that underlies most current languages.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 866
Re: "set of": order of elements
« Reply #32 on: February 07, 2025, 11:49:44 am »
Personally, I think it's likely the best choice if the goal is to learn how a computer really works.

What can make it very undesirable to some is the large amount of information that must be learned which contributes to a fairly steep learning curve but, a programmer who is comfortable with assembler can learn a language like non-OOP Pascal or C fairly quickly.
For adults? May be. But it would be way too hard for children. My first language was Basic. What made me learn Asm - was that I wanted to make games and Basic was too slow and limited for it. My guess was - if other developers could do it, then I also could. That leaded to well known "Asm syndrome", when you think that only Asm code can be fastest. But I changed my mind. Even back in old times, when compilers lacked optimization features, Asm was suitable for critical tasks only, while it was better to use high level language for "glue" code. That's why I learned Pascal then.
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

440bx

  • Hero Member
  • *****
  • Posts: 5080
Re: "set of": order of elements
« Reply #33 on: February 07, 2025, 12:09:33 pm »
I won't deny that learning Assembly as a first language is definitely not easy.

Another reason I think it may be a good first language is because, writing a program in assembler, pretty much forces the programmer do to at least some design upfront and often reconsider how the code is structured while the code is being written because assembly code can get unmanageable very quickly.

IOW, unlike in high level languages where programmers can get away with a poor design (or what is often no design or design on the fly) and keep throwing code at the computer until the program seems to work, that way of "designing" a program will rarely be successful when using assembly.  Basically, coding in assembler teaches a programmer the value of upfront design and the downsides of "code and think later" which is something high level languages somewhat encourage by their being high level.

The other thing I like about learning assembly first is that the programmer learns what the _true_ limits are (those imposed by hardware and architecture) instead of whatever mostly artificial limits are imposed by a high level language.

All that said, I definitely understand why it may be considered a "less than ideal" choice by many but, I don't consider it a bad choice as a first language to learn (I do consider it a tough one though.)

(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 16655
  • Kallstadt seems a good place to evict Trump to.
Re: "set of": order of elements
« Reply #34 on: February 07, 2025, 01:26:37 pm »
Asm is really bad first language candidate.
Personally, I think it's likely the best choice if the goal is to learn how a computer really works.
Here for once I totally agree.
(As long you agree there is no order in a set, that is.)
« Last Edit: February 07, 2025, 01:28:20 pm by Thaddy »
But I am sure they don't want the Trumps back...

440bx

  • Hero Member
  • *****
  • Posts: 5080
Re: "set of": order of elements
« Reply #35 on: February 07, 2025, 03:23:58 pm »
Here for once I totally agree.
(As long you agree there is no order in a set, that is.)
I'll quote myself:
As far as element ordering in sets, a set is by mathematical definition, unordered.
Mathematically sets are collections of _unordered_ items.

That said, compilers that implement sets, such as FPC may and usually do impose an order on the set elements to allow the compiler to represent each element in the set with a single bit.  To see that in action, run the code I included in a previous post.  However, that order imposed by the compiler, is _not_ equivalent to ordering the elements in the set, IOW, the sets [cBlack, cOrange] and [cOrange, cBlack] are equal, the different order does not affect equality.

If the element sequence is important, e.g, [cBlack, cOrange] <> [cOrange, cBlack], then a set is not a solution.  An array can be a solution for such sequences.
 


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018