Welcome, Guest. Please login or register.

Author Topic: CopyMem Quick & Small released!  (Read 14343 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline olsen

Re: CopyMem Quick & Small released!
« Reply #119 from previous page: January 13, 2015, 01:59:10 PM »
Quote from: Thorham;781597
Quote
Should you wake me up in the dead of the night, stressing that the fate of the world depended upon me instantly adding scripting language support to an application, I'd probably start yawning, make coffee and write a Lisp-like language interpreter.
Or you could get Lua, and add that. Seems a lot easier than writing a script language from scratch. Not to mention that Lua is a lot nicer than Lisp
Sometimes you don't get to choose, and there are overriding constraints which spell out in so many words why we can't always have nice things.

I've been in that position several times, and although I don't recommend the approach, it can make great sense to explore the boundaries set by the constraints and use that playing field to the best of your ability.

That can lead to wicked strange solutions which you'd rather not admit having cooked up in a moment of weakness, but then sometimes the overriding constraints are what guide your decision-making and not that nagging conscience of yours that keeps reminding you that the choices you are forced to make may not look so good in the long run. Being a programmer can suck.

Quote
Quote
Sometimes it's enough just to make a system scriptable which wasn't scriptable before.
Why not just add a nice language? Best choices for a script language seem to be Lua or a C interpreter.
You don't always get to choose. The last time I was really upset by the choices made in a scripting language design was when I had to write something in AppleScript to clean up my iTunes library. What a bizarre language. Why is Apple holding onto it, and its equally bizarre ecosystem? Because that scripting language, and all the ideas that went into its design, has been around for decades with nobody willing to admit that it doesn't hold up well.

Quote
Lua is easy, and easy to add if you're working in C. It's also pretty fast, works well on old systems like lower end 68k Amigas (68020/30), and very portable (SASC compiles it properly).

Adding a C interpreter is good, because many programmers know C. That's why FrexxEd's script system is so nice. If you know C, then you know FrexxEd's script language.
I think that Lua's a decent enough design, which is both powerful, well-documented and something newcomers can learn and apply. It's also embeddable with a small memory footprint. I once came close to using it in one of my applications, but then time constraints made me - wait for it - knock off one of those Lisp-like language interpreters instead (the fate of the world didn't exactly depend upon it, and if it did I didn't notice, but sometimes you just want to finish a project and not keep on tinkering).

As for using a 'C'-like language for the purpose of scripting, I can see the attraction for programmers who are already familiar with the language. For everybody else it's a long and ardous journey to even become competent in using the language, so I wouldn't want to force it upon anybody.
« Last Edit: January 13, 2015, 02:03:06 PM by olsen »
 

Offline Cosmos Amiga

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 954
    • Show only replies by Cosmos Amiga
    • http://leblogdecosmos.blogspot.com
Re: CopyMem Quick & Small released!
« Reply #120 on: January 13, 2015, 02:38:42 PM »
Quote from: olsen;781601
(SASC compiles it properly)

For the love of the Amiga, please DO NOT USE or write on forum this compilator at all...


Here an example of what I have found in the GRex Voodoo3 monitor :

Code: [Select]
JL_0_CC68
  move.l a5,-(sp)
  move.l d0,d1
  move.l a0,a5
  bmi.b JL_0_CC76
  moveq #8,d0
  cmp.l d0,d1
  ble.b JL_0_CC7E
JL_0_CC76
  move.w #-$0001,a0
  move.l a0,d0
  bra.b JL_0_CC92
JL_0_CC7E
  asl.l #2,d1
  lea $2AC(a4),a0
  lea $2AC(a4),a1
  move.l (a0,d1.l),a0
  move.l a5,(a1,d1.l)
  move.l a0,d0
JL_0_CC92
  move.l (sp)+,a5
  rts


It's AWFULL : DO NOT USE THIS COMPILATOR !!



:(

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: CopyMem Quick & Small released!
« Reply #121 on: January 13, 2015, 02:49:14 PM »
Quote from: Thomas Richter;781600
I used ed for the startup-sequence.
We've all done that at some point :lol: Ced is nice for stuff like that. Solid and fast (but a little on the basic side).

Quote from: Thomas Richter;781600
I don't even remember which editor I used in the old days when I did a lot of in assembly. Really a lot. I looked at seka, and had to p*ke about its user interface (or lack thereof) and decided against this primitive beast (a good decision), then used the Databecker "Profimat", which had a somewhat useful IDE, though a pretty limited assembler (not a good decision). Luckely, decided against the GFA assembler (I also used GFA Basic quite a bit, fast but buggy) and bought DevPac (2.0 back then), never regretted it, it was a decent choice. I believe I used the DevPac editor for quite a while, still a good thing. Then with Lattice C, I believe it was LSE, which had a couple of bugs, but still worked quite ok. Then came GoldEd, SAS/C and DevPac 3.0, again good investments. I guess I was never a particular fan of CED, but I already had good editors for what I needed. GED I used for almost everything, C, Assembler, PasTeX. Except for the Startup-Sequence. That was still in the hands of "Ed" because GED was a bit too bulky.
Back in the day I used to do everything in AsmOne. Now I do everything in FrexxEd, with Barfly for assembly language and SASC for C.

Quote from: olsen;781601
Sometimes you don't get to choose, and there are overriding constraints which spell out in so many words why we can't always have nice things.
Yes, but not when you're developing your own software from scratch.

Quote from: olsen;781601
Being a programmer can suck.
Yes, but not when you're doing it on a hobby basis. Then you get to do whatever you want in whatever way you want. You simply need the discipline to actually finish the project, or get it into a state where it can be released and used properly (after that you can keep working on it to make it better, but at least you already have something decent).

Quote from: olsen;781601
I think that Lua's a decent enough design, which is both powerful, well-documented and something newcomers can learn and apply. It's also embeddable with a small memory footprint. I once came close to using it in one of my applications, but then time constraints made me - wait for it - knock off one of those Lisp-like language interpreters instead (the fate of the world didn't exactly depend upon it, and if it did I didn't notice, but sometimes you just want to finish a project and not keep on tinkering).
What kind of time constraints cause you to have to make concessions like that?

Quote from: olsen;781601
As for using a 'C'-like language for the purpose of scripting, I can see the attraction for programmers who are already familiar with the language. For everybody else it's a long and ardous journey to even become competent in using the language, so I wouldn't want to force it upon anybody.
True, but it's still great for programmers editors because so many programmers know C. For something that's not related to programming I'd pick something else, too.
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: CopyMem Quick & Small released!
« Reply #122 on: January 13, 2015, 02:52:58 PM »
Quote from: Cosmos;781604
For the love of the Amiga, please DO NOT USE or write on forum this compilator at all...

Here an example of what I have found in the GRex Voodoo3 monitor :

It's AWFULL : DO NOT USE THIS COMPILATOR !!

:(
I'll keep using SASC because it's fine. Perhaps you should do some proper tests first instead of looking at one piece of code. Also, what's the alternative?

Anyway, 68k compilers in general won't produce top notch code. If you really want good code, then use assembly language.
 

Offline olsen

Re: CopyMem Quick & Small released!
« Reply #123 on: January 13, 2015, 03:29:39 PM »
Quote from: Thorham;781606
Quote
I think that Lua's a decent enough design, which is both powerful, well-documented and something newcomers can learn and apply. It's also embeddable with a small memory footprint. I once came close to using it in one of my applications, but then time constraints made me - wait for it - knock off one of those Lisp-like language interpreters instead (the fate of the world didn't exactly depend upon it, and if it did I didn't notice, but sometimes you just want to finish a project and not keep on tinkering)

What kind of time constraints cause you to have to make concessions like that?

I create, modify and debug programs both as part of my day job and as a hobby. The programming I do for fun happens in my somewhat limited spare time. In that situation you can weigh the benefits and drawbacks of one solution to a specific problem against a different solution by looking at how long it would take to implement it, and how well it would solve the problem at hand.

In the case of wiring up a Lua interpreter vs. plugging in some slightly grubby but well-tested Lisp-like language interpreter it was tempting to use the leverage which Lua would have provided, because it was a "real" language with variables, loops and all those shiny things that just might come in handy (or may never get used).

However, not all applications really need that power, and they still get the job done which they were intended for. So plugging in the Lisp-like language interpreter solved the problem at hand, with a minimum of implementation and testing effort. Lua would have provided a much more powerful and well-rounded solution, but I would have had to spend another day or two to get it working properly, and just maybe I wouldn't have used the flexibility and options which Lua would have provided anyway.

So, sometimes a "good enough" solution can beat a "good" or even "perfect" solution.
 

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: CopyMem Quick & Small released!
« Reply #124 on: January 13, 2015, 03:48:55 PM »
Quote from: olsen;781609
However, not all applications really need that power, and they still get the job done which they were intended for. So plugging in the Lisp-like language interpreter solved the problem at hand, with a minimum of implementation and testing effort. Lua would have provided a much more powerful and well-rounded solution, but I would have had to spend another day or two to get it working properly, and just maybe I wouldn't have used the flexibility and options which Lua would have provided anyway.
It depends on the software, sure, but for some software you shouldn't make such concessions.

For some software, 'limitless power' is part of the design goal. FrexxEd is a good example of that, and it's script language is the main reason why it's so powerful.
 

guest11527

  • Guest
Re: CopyMem Quick & Small released!
« Reply #125 on: January 13, 2015, 04:15:37 PM »
Quote from: Thorham;781610
For some software, 'limitless power' is part of the design goal.

Not really. It is "getting the job done with the resources available". In real life, the cost factor of software is *your* time, not *computer time*. Thus, if I can get something done in a high-level scripting language that satisfies the needs of my customers, and I take two days for that, then that's a better solution than working on the same project for a month in C even if the resulting C code would run probably at three times the speed. There are situations where this slow-down is not acceptable, of course, that depends on the problem. But the cases where you can justify for your clients a six-month development time for an Assembly program that runs 50% faster than a C code that could have been done in a month are pretty rare. Yes, I've seen such cases, but that's really the exception.
 

Offline Cosmos Amiga

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 954
    • Show only replies by Cosmos Amiga
    • http://leblogdecosmos.blogspot.com
Re: CopyMem Quick & Small released!
« Reply #126 on: January 13, 2015, 04:33:15 PM »
Quote from: Thomas Richter;781612
Not really. It is "getting the job done with the resources available". In real life, the cost factor of software is *your* time, not *computer time*. Thus, if I can get something done in a high-level scripting language that satisfies the needs of my customers, and I take two days for that, then that's a better solution than working on the same project for a month in C even if the resulting C code would run probably at three times the speed. There are situations where this slow-down is not acceptable, of course, that depends on the problem. But the cases where you can justify for your clients a six-month development time for an Assembly program that runs 50% faster than a C code that could have been done in a month are pretty rare. Yes, I've seen such cases, but that's really the exception.

Don't care about the code time for me : I just want PERFECT code...

Sometimes I can think many days about one small routine to find finally his Truth... Just like SpeedGeek with CopyMem & CopyMemQuick !



:)

Offline Thorham

  • Hero Member
  • *****
  • Join Date: Oct 2009
  • Posts: 1150
    • Show only replies by Thorham
Re: CopyMem Quick & Small released!
« Reply #127 on: January 13, 2015, 04:36:24 PM »
Quote from: Thomas Richter;781612
Not really.
No, really. I'm not talking about all software, I'm talking about some software. In these specific cases the goal of the author/authors was to create software with 'limitless power'.

FrexxEd is an example of such software. From the manual:
Code: [Select]
   What is FrexxEd?
    ================

 FrexxEd is an advanced, highly customizable, extensible, real-time, zero
limitation, fully programmable, function driven full screen display editor
(not a word processor) for editing text files (even though it's possible to
edit any kind of file).

 We say that FrexxEd is a "display" editor because normally the text being
edited is visible on the screen and is updated automatically as you type your
commands.

 We call FrexxEd advanced because it provides facilities that go beyond simple
insertion and deletion.

 "Customizable" means that you can change the definitions of FrexxEd commands
in many ways. For example, if you don't want FrexxEd to query if you kill a
modified buffer, you can simply tell it so. Another sort of customization is
rearrangement of the command set. For example, if you prefer the four basic
cursor motion commands (up, down, left and right) on keys in a diamond pattern
on the keyboard, you can have it.

 "Extensible" and "fully programmable" means that you can go beyond simple
customization and write entirely new commands (programs in the FPL language).
FrexxEd is an "on-line extensible" system, which means that it is divided into
many functions that call each other, any of which can be redefined in the
middle of an editing session. Any part of FrexxEd can be replaced without
making a separate copy of all of FrexxEd. Many of the editing commands of
FrexxEd are written in FPL already; the exceptions could have been written in
FPL but are written in C for improved efficiency. Although only a programmer
can write an extension, anybody can use it when it's done.

 We call it a "real-time" editor because the display is updated very
frequently, usually after each character or pair of characters you type. This
minimizes the amount of information you must keep in mind as you edit. (The
term 'real-time' is, according to some, not used in its right sense here, but
I think you all get my point!)

 "Zero limitation" means that there are hardly no limits in amount or size in
FrexxEd. Your amount of primary memory is the biggest limitation.

 Every keystroke in FrexxEd invokes a function. Most keystrokes invoke the
`Output()' command which inserts the string/character stored in your AmigaDOS
keymap for that key, but there is no real limit to what can be done with
merely a simple keystroke. If FrexxEd cannot already do it, it can be
programmed by the user to do it.

 FrexxEd is not an every man text editor. It's for people with a large
customizable need, brains and more than a 512KB or 1MB floppy system.

 FrexxEd is ShareWare, coded with the intension to give the world a superb
editor to everyone for a low price.
 

guest11527

  • Guest
Re: CopyMem Quick & Small released!
« Reply #128 on: January 13, 2015, 04:54:09 PM »
Quote from: Cosmos;781615
Don't care about the code time for me : I just want PERFECT code...
Excellent, that's better business for me. What are you willing to pay for it, as hourly rate?
 

Offline psxphill

Re: CopyMem Quick & Small released!
« Reply #129 on: January 13, 2015, 05:14:40 PM »
Quote from: Cosmos;781615
Don't care about the code time for me : I just want PERFECT code...

Sometimes I can think many days about one small routine to find finally his Truth... Just like SpeedGeek with CopyMem & CopyMemQuick !

Sure we've all been there. If you can write something the fastest possible then it feels good. If you ever get the ambition to work on something bigger then you will run out of time pretty quick.

 I try to balance optimising algorithms and code quality and have the compiler worry about what registers to use etc.
 

Offline olsen

Re: CopyMem Quick & Small released!
« Reply #130 on: January 13, 2015, 05:36:07 PM »
Quote from: Thorham;781610
Quote
However, not all applications really need that power, and they still get the job done which they were intended for. So plugging in the Lisp-like language interpreter solved the problem at hand, with a minimum of implementation and testing effort. Lua would have provided a much more powerful and well-rounded solution, but I would have had to spend another day or two to get it working properly, and just maybe I wouldn't have used the flexibility and options which Lua would have provided anyway.
It depends on the software, sure, but for some software you shouldn't make such concessions.

For some software, 'limitless power' is part of the design goal. FrexxEd is a good example of that, and it's script language is the main reason why it's so powerful.
My outlook on software quality and how to get it has changed over the years. When I started noodling around with BASIC on whatever home computer I could get my hands on my curiousity was the driving force in getting stuff done. A couple of years down the line I got it into my head that working on a program actually is a task that can always be finished.

At times that even was true when somebody was willing to pay me money for the work I did, or when somebody was very keen on putting my work to good use. That's when you had to make sure that everything you promised or hoped for was accounted for and in the box, before you closed it, tied a bow around it and handed it over.

I've been programming for some odd 30-31 years now, both as a hobby and as a profession, and I couldn't help noticing that there were recurring patterns in the work I did. One important pattern is in that your work is rarely finished, and that you will end up iterating on it. You'll invariably find bugs, understand your own work and working method better, understand what the requirements of the project were better than you did before, and with that insight will come the need to give the job another go, so as to make things better.

This is one of the key insights I gained: your choices, when it comes to designing and implementing software, may not be the best at the time you make them, but that is not the end of the story. You will return to your work, and this time it may improve. Even if it doesn't, then maybe the next iteration will be better.

With this insight you gain a different perspective on how you spend your time on the project. You begin accept that you will be unable to make the best choices, and that the next best thing you can do is focus on specific parts of the task which benefit most from your attention. This is where you'll discover that you have been making trade-offs all the time. Some code may be best in a state in which it's readable and not necessarily optimized for time or space. Some code may be best in a state in which it's optimized. Some code just doesn't benefit from any polishing at all. Turns out that some of the trade-offs you make don't look so good in hindsight, and off you'll go for another round of making better choices.

And that's about it: just because I pick one quirky scripting language that has trouble walking and chewing gum at the same time over an arguably superior alternative it doesn't have to stay that way forever.

I distrust the notion of perfect code or the perfect solution for a problem, as implemented by a program. Perfect code has no bugs and always solves the problem at hand. I've seen that, but the scope such perfect code covers is usually tiny, and if it isn't, it takes a crazy amount of work to produce it. I'm not in the business of producing that kind of work ;) Trying to get to the perfect solution, that I can agree with as part of a process. But you can only get very, very close (asymptotically close, for the mathematically inclined among us) to it and never quite reach that point. Close enough is good enough for me, as otherwise you'll spend your time chipping away at only one small part of the interesting stuff you might otherwise get a chance to explore instead.
« Last Edit: January 13, 2015, 05:43:16 PM by olsen »
 

guest11527

  • Guest
Re: CopyMem Quick & Small released!
« Reply #131 on: January 13, 2015, 07:50:32 PM »
To add a bit to what Olsen said (because I believe he missed an important point). In reality, you want to optimize code quality Q (measured in whatever units you want to measure it), but you only have limited resources R for that. It can be as simple as only having a limited time on this planet, or let it be as trivial as a customer demanding the task ready by a deadline. Or let it be money you are willing to pay.

Olsen said correctly that the definition of Q is not quite as trivial as it may seem. Q is dependent on many things, and may even change over time as you rate quality differently as you learn more.

What I want to add is that the problem is that it is not defined by optimizing Q. It is to optimize Q under the constraint R, which is a different problem.  

Mathematically, you solve such problems by adding the constraint with a Lagrangian multiplier \lambda, and then solve that as an unconstraint problem. So, in reality, you want to optimize

J = Q + \lambda R

where \lambda is the "cost for the quality". If you only say that Q should be ideal, then this is identical to saying that "\lambda = 0", or "you don't value your resources R". That is, seen above, a unrealistic choice.

I personally want to make the best out of my life, and that's finding the maximum of J, and not of Q. That's simply because my R is bounded.

So much for today's math lesson. Yes, the older you get, the more you rate R.
 

Offline Oldsmobile_Mike

Re: CopyMem Quick & Small released!
« Reply #132 on: January 13, 2015, 08:32:33 PM »
^^^ That is brilliant. But I still love @Cosmos and @SpeedGeek's dedication to the micro-optimizations of this code.  It takes a special kind of OCD that I can appreciate in my job, as well. ;)

Kudos, all of you, especially for not letting this turn into a flame-fest! :pint: :pint:
Amiga 500: 2MB Chip|16MB Fast|30MHz 68030+68882|3.9|Indivision ECS|GVP A500HD+|Mechware card reader + 8GB CF|Cocolino|SCSI DVD-RAM
Amiga 2000: 2MB Chip|136MB Fast|50MHz 68060|3.9|Indivision ECS + GVP Spectrum|Mechware card reader + 8GB CF|AD516|X-Surf 100|RapidRoad|Cocolino|SCSI CD-RW
 Amiga videos and other misc. stuff at https://www.youtube.com/CompTechMike/videos
 

Offline SpeedGeekTopic starter

Re: CopyMem Quick & Small released!
« Reply #133 on: January 22, 2015, 03:54:12 PM »
** 3RD NEWS UPDATE **

No version change
- New 1024-8192 byte Block Size versions added to archive

(The new Block Size versions allow you to "Tune" the
MoveL vs. Move16 performance of your system).
 

Offline Cosmos Amiga

  • Hero Member
  • *****
  • Join Date: Jan 2007
  • Posts: 954
    • Show only replies by Cosmos Amiga
    • http://leblogdecosmos.blogspot.com
Re: CopyMem Quick & Small released!
« Reply #134 on: January 22, 2015, 04:37:54 PM »
"Little by little the bird makes its nest"



:)