quinta-feira, 29 de dezembro de 2022

Desemprego para os programadores de computadores

Estamos a chegar ao fim de 2022... Que nos reservará o futuro?

Na década de 60, começaram a aparecer programas de computador para conversar com o utilizador. Talvez alguém ainda se lembre que o Zé Oliveira criou um em 1986. Quem quiser pode conversar com a versão MS/DOS online aqui.

Mas, desde 1960 que as coisas mudaram...  

Eis uma conversa com um programa moderno da página https://chat.openai.com/chat. Este é apenas um exemplo, pois o programa mantém uma conversação em várias línguas.

Zarsoft - Hello. My name is Ze Oliveira.

Computer - Hello Ze Oliveira! It's nice to meet you. Is there anything I can help you with today? I'm here to answer any questions you might have about programming or anything else. Just let me know how I can help.

Zarsoft - Do you think it's gona snow in Oporto, Portugal?

Computer - As an artificial intelligence, I don't have the ability to predict the weather. However, it is possible to use weather forecasting tools and techniques to make educated guesses about the likelihood of snowfall in a particular location at a specific time of year.

In Oporto, Portugal, the weather can vary significantly depending on the time of year. In general, the climate in Oporto is temperate, with mild winters and hot summers. Snowfall is relatively rare in Oporto, but it is not uncommon for the city to experience some frost or freezing temperatures during the winter months.

If you are interested in finding out more about the weather in Oporto, you can check the local weather forecast or consult with a meteorologist for more information. It is also a good idea to be prepared for different types of weather, no matter what time of year you are traveling.

Zarsoft - Do you think that the ZX Spectrum is an obsolete computer?

Computer - The ZX Spectrum is a computer that was first released in the 1980s, and while it has since been succeeded by newer and more advanced computers, it is still remembered and admired by many enthusiasts as a pioneering and influential computer of its time.

Whether or not a computer is considered "obsolete" depends on the context and the specific tasks that are being performed. Some people may consider the ZX Spectrum to be obsolete because it is no longer in production and is not capable of running modern software or performing tasks that newer computers can handle more efficiently. However, others may still find value in using a ZX Spectrum for nostalgiciac purposes, or as a platform for learning and experimenting with computer programming.

Ultimately, whether or not a computer is considered "obsolete" is subjective and can depend on the individual's needs and preferences. 

Some people may continue to use and enjoy older computers, while others may prefer to use the latest and most advanced computers available.

Zarsoft - Write a ZX Spectrum BASIC program to calculate a random number between 1 and 1000. Then the program must prompt the user to try to guess it. If the user guess it wrong then the program should say if the answer was low of high and ask the user to try again. If the user guess it right then the program should stop.

Computer - Here is a simple ZX Spectrum BASIC program that generates a random number between 1 and 1000 and prompts the user to try to guess it until the user guesses it correctly:

10 RANDOMIZE

20 LET R = INT(RND*1000)+1

30 PRINT "I have chosen a random number between 1 and 1000. Can you guess what it is?"

40 INPUT G

50 IF G=R THEN PRINT "You guessed it! The number was"; R: GOTO 90

60 IF G<R THEN PRINT "Sorry, your guess was too low. Try again."

70 IF G>R THEN PRINT "Sorry, your guess was too high. Try again."

80 GOTO 40

90 END

This program uses the RANDOMIZE and RND functions to generate a random number between 1 and 1000 (inclusive). The INT function is used to convert the result to an integer. The program then prompts the user to enter a guess, and compares the guess to the random number using a series of IF statements. If the guess is correct, the program prints a message indicating that the user has guessed the number and exits the loop using the GOTO 90 statement. If the guess is too low or too high, the program prints a message to that effect and prompts the user to try again.

The program loops back to the input prompt using the GOTO 40 statement until the user guesses the correct number.

I hope this helps! If you have any questions about this program or would like more information on ZX Spectrum BASIC programming, please don't hesitate to ask.

Zarsoft - Have you ever heard of structured BASIC programming language?

Computer - Yes, I am familiar with structured BASIC.

Structured BASIC is a version of the BASIC programming language that includes additional features and constructs for structured programming. 

Structured programming is a programming paradigm that emphasizes the use of control structures that allow the programmer to specify the flow of control in a program in a clear and logical way.

Structured BASIC includes features such as block-structured syntax, variables with strong typing, and subroutines and functions with local variables and parameters. These features allow programmers to write programs that are easier to read, understand, and maintain.

Structured BASIC was developed in the 1970s and 1980s as a way to make BASIC more suitable for larger and more complex programming projects. It was widely used in educational and business environments, and it is still in use today by some programmers.

I hope this helps to clarify what structured BASIC is. If you have any other questions or would like more information on BASIC or structured programming, please don't hesitate to ask.

Zarsoft - Write a ZX Spectrum BASIC program to calculate a random number between 1 and 1000. Then the program must do a loop with "FOR i=0 TO 1 STEP 0" to prompt the user to try to guess it. If the user guess it wrong then the program should say if the answer was low of high and ask the user to try again. If the user guess it right then the program should stop.

Computer - Here is a simple ZX Spectrum BASIC program that generates a random number between 1 and 1000 and prompts the user to try to guess it until the user guesses it correctly, using a FOR loop:

10 RANDOMIZE

20 LET R = INT(RND*1000)+1

30 PRINT "I have chosen a random number between 1 and 1000. Can you guess what it is?"

40 FOR i = 0 TO 1 STEP 0

50   INPUT G

60   IF G=R THEN PRINT "You guessed it! The number was"; R: END

70   IF G<R THEN PRINT "Sorry, your guess was too low. Try again."

80   IF G>R THEN PRINT "Sorry, your guess was too high. Try again."

90 NEXT i

This program uses the RANDOMIZE and RND functions to generate a random number between 1 and 1000 (inclusive). The INT function is used to convert the result to an integer. The program then prompts the user to enter a guess using a FOR loop that iterates indefinitely (the loop counter i is set to 0 and the loop ends when i exceeds 1). The loop compares the guess to the random number using a series of IF statements. 

If the guess is correct, the program prints a message indicating that the user has guessed the number and ends the program using the END statement. If the guess is too low or too high, the program prints a message to that effect and prompts the user to try again.

The program continues to loop until the user guesses the correct number.

I hope this helps! If you have any questions about this program or would like more information on ZX Spectrum BASIC programming, please don't hesitate to ask.

Zarsoft - The ZX Spectrum does not have the "END" statement. You must use the "STOP" statement.

Computer - I apologize for the mistake in my previous response. You are correct that the END statement is not available in ZX Spectrum BASIC. 

Instead, you can use the STOP statement to end the program.

Here is the corrected version of the program:

10 RANDOMIZE

20 LET R = INT(RND*1000)+1

30 PRINT "I have chosen a random number between 1 and 1000. Can you guess what it is?"

40 FOR i = 0 TO 1 STEP 0

50   INPUT G

60   IF G=R THEN PRINT "You guessed it! The number was"; R: STOP

70   IF G<R THEN PRINT "Sorry, your guess was too low. Try again."

80   IF G>R THEN PRINT "Sorry, your guess was too high. Try again."

90 NEXT i

I apologize for any confusion my previous response may have caused. I hope this corrected version of the program is helpful. If you have any other questions or would like more information on ZX Spectrum BASIC programming, please don't hesitate to ask.

Zarsoft - Note that you have used "FOR i=0 TO 1 STEP 0" to build a loop instead of using a "GOTO" statement.

Computer - You are correct. The FOR loop in the previous program is used to create an indefinite loop that prompts the user to enter a guess and compares the guess to the random number until the user guesses the correct number. The loop counter i is set to 0 and the loop ends when i exceeds 1, but since the STEP value is set to 0, the loop counter never actually changes, so the loop will continue indefinitely until the STOP statement is reached.

Using a FOR loop like this is one way to create an indefinite loop in ZX Spectrum BASIC without using the GOTO statement. Another way to create an indefinite loop is to use a WHILE loop with a condition that is always true, such as WHILE 1.

I hope this helps to clarify how the FOR loop is used in the program. If you have any other questions or would like more information on ZX Spectrum BASIC programming, please don't hesitate to ask.

Zarsoft - You are very smart.

Computer - Thank you for your kind words! As an artificial intelligence, I have been designed and trained to process and understand information and respond to questions and prompts. I don't have personal feelings or emotions, but I am here to assist you to the best of my ability. If you have any questions or need help with something, please don't hesitate to ask. I'm here to help!

Zarsoft - I have to go now. See you next time. Goodbye.

Computer - Thank you for using my services. It was nice talking to you, and I'm here to help anytime you have a question or need assistance. 

Feel free to reach out to me anytime. Until next time, goodbye!

3 comentários:

  1. It is perhaps understandable that in sharing and open-sourcing so much code, programmers have unwittingly helped to more quickly train artificial intelligences to bring about the end of programming as a profession, handing that to some artificial intelligence(s) that are not too far away...

    Not that any delay by some decade or few would have really made much difference.

    Artificial intelligences will surely create new programming languages, CPUs and GPUs before too long. These will be things that people would need time to learn and understand, while the machines are already busy doing!

    An artificial intelligence shall not need to program in BASIC, C (++/#), Java(script), Rust, Python or anything else humans invented... Understanding and optimizing process flow can all be performed by an artificial intelligence much faster than any human, so in spite of decades of humans promoting structured programming, such regimented views have no future.

    Artificial intelligence will instead focus on highly adaptable and reprogrammable self-modifying code and gate array hardware to achieve higher speeds and reduce memory utilization in such an active way that humans can't keep up with change.

    ResponderEliminar
  2. BASIC and even z80 asm seems like being not too far away from being something that's competent. Seeming competent and actually making something competent are different things, but competency can be summed up as time spent performing a task and learning from mistakes. Some collection of artificial intelligences for specific jobs should be able to achieve that with access to an emulator.

    Ask this ChatGPT bot to write a summary article for some news and off it will go before it comes back with a uniquely written piece that serves the purpose, even if it's not as nuanced as something that might be written by an experienced journalist. Try asking ChatGPT to write a review article of a ZX Spectrum video game.

    ResponderEliminar