[ home / rules / faq / search ] [ overboard / sfw / alt ] [ leftypol / edu / labor / siberia / lgbt / latam / hobby / tech / games / anime / music / draw / AKM / ufo ] [ meta ] [ wiki / shop / tv / tiktok / twitter / patreon ] [ GET / ref / marx / booru ]

/edu/ - Education

'The weapon of criticism cannot, of course, replace criticism of the weapon, material force must be overthrown by material force; but theory also becomes a material force as soon as it has gripped the masses.' - Karl Marx
Name
Options
Subject
Comment
Flag
File
Embed
Password(For file deletion.)

Check out our new store at shop.leftypol.org!


File: 1752669802595.png (1.76 MB, 2500x1443, ClipboardImage.png)

 

Let's make a thread about programming,share your experiences,adviсes to beginners and so on.
I don't have any great experience on this topic,because i'm beginner like only language i learned is Python.

File: 1757352296674.png (1.79 MB, 1552x873, ClipboardImage.png)

If learning programming be it for work or for fun or just self improvement, don't do those stupid template starter projects like the eternal to-do list. Program software that you want to use.

Real Programmers write in FORTRAN.

Maybe they do now,
in this decadent era of
Lite beer, hand calculators, and "user-friendly" software
but back in the Good Old Days,
when the term "software" sounded funny
and Real Computers were made out of drums and vacuum tubes,
Real Programmers wrote in machine code.
Not FORtranshumanistot RATFOR. Not, even, assembly language.
Machine Code.
Raw, unadorned, inscrutable hexadecimal numbers.
Directly.

Lest a whole new generation of programmers
grow up in ignorance of this glorious past,
I feel duty-bound to describe,
as best I can through the generation gap,
how a Real Programmer wrote code.
I'll call him Mel,
because that was his name.

I first met Mel when I went to work for Royal McBee Computer Corp.,
a now-defunct subsidiary of the typewriter company.
The firm manufactured the LGP-30,
a small, cheap (by the standards of the day)
drum-memory computer,
and had just started to manufacture
the RPC-4000, a much-improved,
bigger, better, faster — drum-memory computer.
Cores cost too much,
and weren't here to stay, anyway.
(That's why you haven't heard of the company,
or the computer.)

I had been hired to write a FORTRAN compiler
for this new marvel and Mel was my guide to its wonders.
Mel didn't approve of compilers.

"If a program can't rewrite its own code",
he asked, "what good is it?"

Mel had written,
in hexadecimal,
the most popular computer program the company owned.
It ran on the LGP-30
and played blackjack with potential customers
at computer shows.
Its effect was always dramatic.
The LGP-30 booth was packed at every show,
and the IBM salesmen stood around
talking to each other.
Whether or not this actually sold computers
was a question we never discussed.

Mel's job was to re-write
the blackjack program for the RPC-4000.
(Port? What does that mean?)
The new computer had a one-plus-one
addressing scheme,
in which each machine instruction,
in addition to the operation code
and the address of the needed operand,
had a second address that indicated where, on the revolving drum,
the next instruction was located.

In modern parlance,
every single instruction was followed by a GO TO!
Put *that* in Pascal's pipe and smoke it.

Mel loved the RPC-4000
because he could optimize his code:
that is, locate instructions on the drum
so that just as one finished its job,
the next would be just arriving at the "read head"
and available for immediate execution.
There was a program to do that job,
an "optimizing assembler",
but Mel refused to use it.

"You never know where it's going to put things",
he explained, "so you'd have to use separate constants".

It was a long time before I understood that remark.
Since Mel knew the numerical value
of every operation code,
and assigned his own drum addresses,
every instruction he wrote could also be considered
a numerical constant.
He could pick up an earlier "add" instruction, say,
and multiply by it,
if it had the right numeric value.
His code was not easy for someone else to modify.

I compared Mel's hand-optimized programs
with the same code massaged by the optimizing assembler program,
and Mel's always ran faster.
That was because the "top-down" method of program design
hadn't been invented yet,
and Mel wouldn't have used it anyway.
He wrote the innermost parts of his program loops first,
so they would get first choice
of the optimum address locations on the drum.
The optimizing assembler wasn't smart enough to do it that way.

Mel never wrote time-delay loops, either,
even when the balky Flexowriter
required a delay between output characters to work right.
He just located instructions on the drum
so each successive one was just *past* the read head
when it was needed;
the drum had to execute another complete revolution
to find the next instruction.
He coined an unforgettable term for this procedure.
Although "optimum" is an absolute term,
like "unique", it became common verbal practice
to make it relative:
"not quite optimum" or "less optimum"
or "not very optimum".
Mel called the maximum time-delay locations
the "most pessimum".

After he finished the blackjack program
and got it to run
("Even the initializer is optimized",
he said proudly),
he got a Change Request from the sales department.
The program used an elegant (optimized)
random number generator
to shuffle the "cards" and deal from the "deck",
and some of the salesmen felt it was too fair,
since sometimes the customers lost.
They wanted Mel to modify the program
so, at the setting of a sense switch on the console,
they could change the odds and let the customer win.

Mel balked.
He felt this was patently dishonest,
which it was,
and that it impinged on his personal integrity as a programmer,
which it did,
so he refused to do it.
The Head Salesman talked to Mel,
as did the Big Boss and, at the boss's urging,
a few Fellow Programmers.
Mel finally gave in and wrote the code,
but he got the test backwards,
and, when the sense switch was turned on,
the program would cheat, winning every time.
Mel was delighted with this,
claiming his subconscious was uncontrollably ethical,
and adamantly refused to fix it.

After Mel had left the company for greener pa$ture$,
the Big Boss asked me to look at the code
and see if I could find the test and reverse it.
Somewhat reluctantly, I agreed to look.
Tracking Mel's code was a real adventure.

I have often felt that programming is an art form,
whose real value can only be appreciated
by another versed in the same arcane art;
there are lovely gems and brilliant coups
hidden from human view and admiration, sometimes forever,
by the very nature of the process.
You can learn a lot about an individual
just by reading through his code,
even in hexadecimal.
Mel was, I think, an unsung genius.

Perhaps my greatest shock came
when I found an innocent loop that had no test in it.
No test. *None*.
Common sense said it had to be a closed loop,
where the program would circle, forever, endlessly.
Program control passed right through it, however,
and safely out the other side.
It took me two weeks to figure it out.

The RPC-4000 computer had a really modern facility
called an index register.
It allowed the programmer to write a program loop
that used an indexed instruction inside;
each time through,
the number in the index register
was added to the address of that instruction,
so it would refer
to the next datum in a series.
He had only to increment the index register
each time through.
Mel never used it.

Instead, he would pull the instruction into a machine register,
add one to its address,
and store it back.
He would then execute the modified instruction
right from the register.
The loop was written so this additional execution time
was taken into account —
just as this instruction finished,
the next one was right under the drum's read head,
ready to go.
But the loop had no test in it.

The vital clue came when I noticed
the index register bit,
the bit that lay between the address
and the operation code in the instruction word,
was turned on —
yet Mel never used the index register,
leaving it zero all the time.
When the light went on it nearly blinded me.

He had located the data he was working on
near the top of memory —
the largest locations the instructions could address —
so, after the last datum was handled,
incrementing the instruction address
would make it overflow.
The carry would add one to the
operation code, changing it to the next one in the instruction set:
a jump instruction.
Sure enough, the next program instruction was
in address location zero,
and the program went happily on its way.

I haven't kept in touch with Mel,
so I don't know if he ever gave in to the flood of
change that has washed over programming techniques
since those long-gone days.
I like to think he didn't.
In any event,
I was impressed enough that I quit looking for the
offending test,
telling the Big Boss I couldn't find it.
He didn't seem surprised.

When I left the company,
the blackjack program would still cheat
if you turned on the right sense switch,
and I think that's how it should be.
I didn't feel comfortable
hacking up the code of a Real Programmer.

Source https://users.cs.utah.edu/~elb/folklore/mel.html


Learn C/C++ (C# is very similar but there are some differences that are noticeable for those who know what computers do at the hardware/assembly level, all of which are mostly there to make writing business programs easier, while in C/C++ the programmer has to manually do things.) Few languages do anything particularly better than C unless you're getting into base-level OS stuff or security stuff (since C has some security vulnerabilities).

After that it's helpful to have some experience in an assembly language and then learn how C translates common instructions to assembly, to get an idea of how to write the most efficient and elegant programs. If you can do that, learning any other language or system is a lot easier.

Real heart of being a good programmer is systems analysis rather than "coding". Any idiot can write code, but what you're going to do as a programmer is solve problems, some of which happen in the real world and have to be modeled the smart way. It's an art and so many people have difficulty with this.

A lot of people want to learn for game programming, but I can tell you that games are simultaneously some of the most frustrating projects and also the least rewarding, and a lot of game programs are kept simple (and can be pretty badly programmed when you look at them). Games are frustrating as a starting project because you're worried about graphics, music, and gameplay. I find a better way for a novice-intermediate programmer to get used to programming is to program simple applications.

The ideal for a programmer is to build a program that does one thing and does it really well, rather than a big application with lots of features. I'd like instead to type in command line "timer" and get the thing I wanted. You can reuse code and even build libraries if several different programs are going to call the same functions.

Another thing that's helpful for learners: use g++ and, this is really useful, learn how to use Makefile at some point. There are versions of this for Windows and Linux both, and on Linux you're going to get very used to Makefiles since a lot of stuff you would install uses them. The advanced IDEs are helpful (and most helpful for experienced programmers working on a team project), but the best way to learn is to be as close to the computer's simplest operations as possible.

These things can be pretty difficult to pick up. For a code editor, Visual Studio Code is pretty good, and it is compatible with Make/CMake. It is helpful to have something that will pick up typos as you program, so you don't have that pratfall to worry about at compile time. Visual Studio full can let you get started with Windows stuff. I'm guessing you have some familiarity with this already.

Finally, it is helpful to learn how to use Git on a command line interface. That way you can upload programs and control code (or contribute to other projects). Git can be annoying to learn but if you're working on anything with a lot of files and multiple authors you will need to learn it.

Generally on Linux you don't download executable binaries when you want a new program. Instead you download source code and compile (or package manager which does this and leaves behind the executable you wanted). It's fairly helpful to get in the habit of assuming your users will want to compile the program just as you do, until you're shipping stuff for the casual user and want to make it as easy as possible for them. On Windows, you would want to create an installer instead of just an executable once your program is established. Even a simple program can benefit from an installer (and of course you would have an uninstaller that removes everything neatly). Only the simplest programs wouldn't need an installer (and these programs would be simple enough to expect the user to compile them manually with little effort).

I really recommend starting with command line programs to do simple things you'd like, before getting into simple applications with a program loop. You'd be amazed how many niches are poorly served by ready made programs, that you can fulfill with remarkably little effort once you have some basic widgets created. (And as you get better, build your own widgets for use in future programs… you only need to make a "button" widget once, and while there are libraries with these things already made, you can through reusable code make new widgets even faster if,. you only need to make an object that is clickable, and then make your widgets a derived class of that if you're doing C++. for example, all of your widgets have a bounding box and you want to detect when someone has clicked them. You should only need to make the "clicked box" code once and then reuse it for all other widgets.


Unique IPs: 5

[Return][Go to top] [Catalog] | [Home][Post a Reply]
Delete Post [ ]
[ home / rules / faq / search ] [ overboard / sfw / alt ] [ leftypol / edu / labor / siberia / lgbt / latam / hobby / tech / games / anime / music / draw / AKM / ufo ] [ meta ] [ wiki / shop / tv / tiktok / twitter / patreon ] [ GET / ref / marx / booru ]