Discuss Scratch

oblanman
Scratcher
26 posts

Python or Java? (Or any other language)

I have been learning Python for a while now and I was just wondering what language (besides the basic Scratch language) I should learn instead?
And for anyone who wants to see a fancy Python program:

import turtle
from turtle import *
for i in range(100):
turtle.forward(20)
turtle.right(10)

Last edited by oblanman (Oct. 3, 2019 20:38:07)

imfh
Scratcher
1000+ posts

Python or Java? (Or any other language)

JavaScript is a good one to learn. You could also try VB.NET for a more powerful yet still fairly easy to learn language.

Did you know if you put your code in [code=python] [/code] brackets you can get syntax highlighting?
import turtle
from turtle import *
for i in range(100):
  turtle.forward(20)
  turtle.right(10)
adsuri
Scratcher
1000+ posts

Python or Java? (Or any other language)

let j = 4;
console.log(j);
const i = function (a) {
    console.log(a);
};
i("hi");
Used with code=javascript

Last edited by adsuri (Oct. 4, 2019 23:19:14)

sausagescratch
Scratcher
78 posts

Python or Java? (Or any other language)

Hi there,

Do you people know what software I could download on my Raspberry Pi running Raspbian to make an app?
DipLeChip
Scratcher
1000+ posts

Python or Java? (Or any other language)

Python is the best language after scratch, and has the most uses out of all the main ones.
LastContinue
Scratcher
500+ posts

Python or Java? (Or any other language)

OCaml is the best language.
PrincessPandaLover
Scratcher
1000+ posts

Python or Java? (Or any other language)

Python is better, because Java is outdated.
LastContinue
Scratcher
500+ posts

Python or Java? (Or any other language)

PrincessPandaLover wrote:

Python is better, because Java is outdated.
Java is better because it runs on more devices, runs a huge amount faster, is updated to this day (same as Python), powered by the JVM, possibly the most universal and battle hardened Bytecode VM out there, files are smaller (because Bytecode), is statically typed (which is a benefit over Python in some cases) etc

Python is good for data science and being an interpreted language
Java is a jack of all trades and is a compiled language
technoguyx
Scratcher
500+ posts

Python or Java? (Or any other language)

LastContinue wrote:

Python is good for data science and being an interpreted language
Java is a jack of all trades and is a compiled language
IIRC both Python and Java are “compiled” in the sense that your code is turned into compact bytecode, which is then run by a virtual machine (VM). In fact, Java is perhaps the first language that popularized the use of a VM in such a way. You might think that interpreted languages are called so because a program reads the source code, line by line every time, and acts accordingly – this is not the case, and with good reason, since that would be ridiculously inefficient. So Java and Python are “compiled” to bytecode; they are not “compiled” like e.g. C++ is: C and C++ are low-level languages, and in this case source code is compiled pretty much directly to machine code.

Back on topic, I think both are really good languages and as for the question of which one to learn, it depends. Mostly on what you want to do with it. If you want to make web apps, learn Javascript. For software development, Java might be good to start – and I've used some actually real good software made with Java. For quick scripts and the such, Python is good – it's even learnt by some as their first programming language and many intro programming courses in universities/colleges teach Python.

Last edited by technoguyx (Oct. 19, 2019 01:46:44)

Nambaseking01
Scratcher
1000+ posts

Python or Java? (Or any other language)

HTML is a pretty cool language. It's pretty simple — I even have a Wiki on FANDOM about web developing!

Here is a code I made with it (you can scroll more down):

<!DOCTYPE html>
<html>
<head>
<title>Nammy's Page</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Check out my website! You can also learn a lot of things yourself here!">
<meta name="keywords" content="nammy,nambaseking01,Scratch,HTML,JS,JavaScript,writing,programming,Lua,videos,talking,stories,education,happiness,india,belgium">
<meta name="author" content="Nambaseking01">
</head>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
<link rel="icon" type="image/x-icon" href="https://cdn2.scratch.mit.edu/get_image/user/32829133_60x60.png">
<style>
body {
	background-color: lightgrey;
	font-family: helvetica;
}
.welcomeDiv {
	background-color: #4E97FE;
	color: black;
	margin: -5px;
	padding: 25px;
	text-align: center;
}
.internetDiv {
	background-color: grey;
	border-style: solid;
	text-align: center;
	color: black;
	margin: 20px;
	width: 200px;
	height: 120px;
	float: left;
}
.nextToInternet {
	background-color: lightgrey;
	width: 1000px;
	height: 100px;
	margin: 20px;
	float: left;
}
.parentDiv {
}
.websiteDiv {
	background-color: lightgrey;
	width: 1350px;
	height: 200px;
	margin: 15px;
	float: left;
	clear: left;
}
.line {
	height: 1px;
	background: #717171;
	border-bottom: 1px solid #313030;
}
.forKidsButton {
	background-color: rgb(174, 174, 174);
	border-style: solid;
	text-align: center;
	color: black;
	width: 220px;
	height: 120px;
	float: left;
	align: center;
}
.forAdultsButton {
	background-color: rgb(174, 174, 174);
	border-style: solid;
	text-align: center;
	color: black;
	width: 220px;
	height: 120px;
	float: left;
	align: center;
}
.forKidsButton:hover {
	opacity: .5;
}
.forAdultsButton:hover {
	opacity: .5;
}
</style>
</head>
<body>
<div class="welcomeDiv">
<header>
<i class="fas fa-cloud" style="font-size: 75px; float: left;"></i> 
<i class="fas fa-cloud" style="font-size: 75px; float: right;"></i>
<h1>Welcome to Nammy's website!</h1>
</header>
<p>Hello there! My online nickname is Nammy and this is my website! I have been learning HTML and JavaScript for a long time, and now I have decided to finally create my website!</p>
</div>
<div class="parentDiv">
<div class="internetDiv">
<p>Hello! If you like this website, please give me an internet by clicking <a href="http://internetometer.com/give/47350" target="_blank">here</a>! Thank you for reading this!</p>
</div>
<div class="nextToInternet">
<p>Hey! As written above, my online nickname is Nammy. My passions are writing and programming and my hobby is playing the piano. I am trying to write a novel series by the name of <i>Bill Anderson</i> right now, and I programmed this website myself. Oh, and I also program on the <a href="https://scratch.mit.edu" target="_blank">Scratch programming language</a> and on <a href="https://web.roblox.com/create" target="_blank">ROBLOX Lua</a>. I am currently learning HTML, JS, and CSS since they will help me with the website. My latest game on Scratch is named <i>Random Noun Generator</i> and it's actually pretty good. Here is the link: <a href="https://scratch.mit.edu/projects/320069004/" target="_blank">https/scratch.mit.edu/projects/320069004/</a>. Hopefully you like the project - I spent a lot of time on it and I don't want someone to think that it is bad. I am also pretty active on <a href="https://github.com">Github</a>, which I only joined recently</p>
</div>
</div>
<div class="websiteDiv">
<p>Actually, you are allowed to think my Scratch project is bad. People can have their own opinion. I am not one of those people who don't let other people have their opinions. Speaking of which, my age is 9 and I am an Indian that immigrated to Belgium. In the fourth grade I was the topper in spelling and the third topper in maths! I also have a YouTube channel. Here is the link: <a href="https://www.youtube.com/channel/UCmwgBDlUMl4yB5hdG4qn_5g" target="_blank">https/www.youtube.com/channel/UCmwgBDlUMl4yB5hdG4qn_5g</a>. Hopefully you like my videos. I know I haven't uploaded a single video in 4 months, but I am planning to release a vlog soon enough. Me and my dad are thinking of making multiple vlogs in a couple of weeks and release them one per one. Besides, I can talk very well. I think that's also one of my hobbies.</p>
<p>So what can you do in this site? Well, you can actually just enjoy! Just click on one of the buttons given below to do some fun things! :smile:</p>
<div class="parentDiv">
<a href="https://nambaseking01.github.io/KidActivities" target="_blank">
<div class="forKidsButton"><h2>Activities for Kids</h2></div>
</a>
<div class="forAdultsButton" onclick="alert('Adult activities are coming soon!');"><h2>Activities for Adults</h2></div></div><br><br><br><br><br><br><br>
<div class="line"></div>
<small>
<p>Got code for the icon of this website from <a href="https://smileycreations15.com/" target="_blank">https/smileycreations15.com/</a></p>
<p>Got code for the lines in this website from <a href="https://cre8tivenerd.com/2011/01/create-a-line-separator-using-only-css/" target="_blank">https/cre8tivenerd.com/2011/01/create-a-line-separator-using-only-css/</a></p>
<p>Got code for the effects that come when you hover over buttons from <a href="http://jsfiddle.net/6wU8X/4/" target="_blank">http/jsfiddle.net/6wU8X/4/</a></p>
</small>
</body>
</html>

Last edited by Nambaseking01 (Oct. 20, 2019 14:29:10)

LastContinue
Scratcher
500+ posts

Python or Java? (Or any other language)

Nambaseking01 wrote:

HTML is a pretty cool language. It's pretty simple — I even have a Wiki on FANDOM about web developing!

Here is a code I made with it (you can scroll more down):

-snip-
HTML is not a programming language and thus is incomparable to both Java and Python.

technoguyx wrote:

LastContinue wrote:

Python is good for data science and being an interpreted language
Java is a jack of all trades and is a compiled language
IIRC both Python and Java are “compiled” in the sense that your code is turned into compact bytecode, which is then run by a virtual machine (VM). In fact, Java is perhaps the first language that popularized the use of a VM in such a way. You might think that interpreted languages are called so because a program reads the source code, line by line every time, and acts accordingly – this is not the case, and with good reason, since that would be ridiculously inefficient. So Java and Python are “compiled” to bytecode; they are not “compiled” like e.g. C++ is: C and C++ are low-level languages, and in this case source code is compiled pretty much directly to machine code.

Key thing is Python source has to be compiled to Python's Bytecode each time you run the file (apart from pyc?), Java's jar files are already compiled down to bytecode.

From what I've heard, all stages of Python are inefficient, from Lexing to Parsing to Compiling to Interpreting the final bytecode.
PrincessPandaLover
Scratcher
1000+ posts

Python or Java? (Or any other language)

Additionally, the syntax of Java can be confusing. I'm using it in my Game Design class, and I mess up sometimes.

Python's syntax is easier. It's a lot like Scratch's.

LastContinue wrote:

PrincessPandaLover wrote:

Python is better, because Java is outdated.
Java is better because it runs on more devices, runs a huge amount faster, is updated to this day (same as Python), powered by the JVM, possibly the most universal and battle hardened Bytecode VM out there, files are smaller (because Bytecode), is statically typed (which is a benefit over Python in some cases) etc

Python is good for data science and being an interpreted language
Java is a jack of all trades and is a compiled language
I learned Java being outdated from my father, a programming expert.
CatsUnited
Scratcher
1000+ posts

Python or Java? (Or any other language)

PrincessPandaLover wrote:

LastContinue wrote:

PrincessPandaLover wrote:

Python is better, because Java is outdated.
Java is better because it runs on more devices, runs a huge amount faster, is updated to this day (same as Python), powered by the JVM, possibly the most universal and battle hardened Bytecode VM out there, files are smaller (because Bytecode), is statically typed (which is a benefit over Python in some cases) etc

Python is good for data science and being an interpreted language
Java is a jack of all trades and is a compiled language
I learned Java being outdated from my father, a programming expert.
Maybe he doesn't deal with a programming field that requires Java?
Java is still used a lot, it just isn't perceived the same way as cool programming languages like JS or Python
LastContinue
Scratcher
500+ posts

Python or Java? (Or any other language)

PrincessPandaLover wrote:

Additionally, the syntax of Java can be confusing. I'm using it in my Game Design class, and I mess up sometimes.

Python's syntax is easier. It's a lot like Scratch's.

LastContinue wrote:

PrincessPandaLover wrote:

Python is better, because Java is outdated.
Java is better because it runs on more devices, runs a huge amount faster, is updated to this day (same as Python), powered by the JVM, possibly the most universal and battle hardened Bytecode VM out there, files are smaller (because Bytecode), is statically typed (which is a benefit over Python in some cases) etc

Python is good for data science and being an interpreted language
Java is a jack of all trades and is a compiled language
I learned Java being outdated from my father, a programming expert.
Calling Java outdated is like calling C++ outdated.
There are many better languages for many things, but the world would not function if you didn't have people who knew how to use this languages well.
In fact, so long as a language can target modern systems and use native libraries (C++ and Java tick both these boxes) it can never become outdated, because it will always be usable.
Now a truly outdated language is B, which cannot even compile on modern systems.
mrbumppo
Scratcher
500+ posts

Python or Java? (Or any other language)

sausagescratch wrote:

Hi there,

Do you people know what software I could download on my Raspberry Pi running Raspbian to make an app?
1. You have a Pi? I do too! (i host a web server on it though)
2. You should already have what you need to make a Python App.
3. You might already have everything you need to make a Java app.
PrincessPandaLover
Scratcher
1000+ posts

Python or Java? (Or any other language)

LastContinue wrote:

PrincessPandaLover wrote:

Additionally, the syntax of Java can be confusing. I'm using it in my Game Design class, and I mess up sometimes.

Python's syntax is easier. It's a lot like Scratch's.

LastContinue wrote:

PrincessPandaLover wrote:

Python is better, because Java is outdated.
Java is better because it runs on more devices, runs a huge amount faster, is updated to this day (same as Python), powered by the JVM, possibly the most universal and battle hardened Bytecode VM out there, files are smaller (because Bytecode), is statically typed (which is a benefit over Python in some cases) etc

Python is good for data science and being an interpreted language
Java is a jack of all trades and is a compiled language
I learned Java being outdated from my father, a programming expert.
Calling Java outdated is like calling C++ outdated.
There are many better languages for many things, but the world would not function if you didn't have people who knew how to use this languages well.
In fact, so long as a language can target modern systems and use native libraries (C++ and Java tick both these boxes) it can never become outdated, because it will always be usable.
Now a truly outdated language is B, which cannot even compile on modern systems.
There is no argument.

Python is just more used.
LastContinue
Scratcher
500+ posts

Python or Java? (Or any other language)

PrincessPandaLover wrote:

Python is just more used.
Python is a terrible dynamically typed language that shouldn't exist.

Java is statically typed and uses sensible (albeit annoying) syntax for things.

If you want a less verbose language that's pleasant to use, statically typed and fast, use OCaml.
Python add function example:
def add(a, b):
    return a + b

OCaml add function example:
let add a b =
    a + b
    ;;
The difference being that in Python you can pass anything to a and b, and it will throw a runtime error when executing the “+” operator, but in OCaml, that code defines a and b as only ever being integers avoiding all runtime errors, and instead throwing an error for a type mismatch.

Last edited by LastContinue (Oct. 25, 2019 10:18:26)

LastContinue
Scratcher
500+ posts

Python or Java? (Or any other language)

In fact OCaml is probably the greatest language that exists!
It's super easy to write and extremely powerful. Here's a fibonacci example:
let rec fib count =
    fibn 1 1 count
and fibn a b count =
    if count <> 0 then fibn b (a+b) (count-1)
    else a+b
    ;;
This defines two functions fib and fibn. Fib just takes count as an argument and does a normal fibonacci sequence [count] amount of times. Fibn allows you to define the start points.
technoguyx
Scratcher
500+ posts

Python or Java? (Or any other language)

Dynamically and statically typed languages both have their purposes; calling one better than the other is like comparing apples and oranges.

LastContinue wrote:

Python source has to be compiled to Python's Bytecode each time you run the file (apart from pyc?)
Yes, that's what happens when you “run” the .py file. While developing you must recompile your code after any changes you've done on the code just like with any other language, high-level or not. However, developers may then distribute the .pyc files or even use something like Cython for extra performance.

Last edited by technoguyx (Nov. 1, 2019 21:16:09)

Electroboss
Scratcher
20 posts

Python or Java? (Or any other language)

If you like python and javascirpt, I recommend lua.
I mainly use it for bizHawk, so this is what I have:
local table={}
local x403=0
local x404=0
local x405=0
while true do
 table=joypad.get(1)
 local keys= input.get()
 if keys.W and x403 == 0x00 then
  x404 = 1-x404
  x403=1
 elseif not keys.W then
  x403=0
 end
 x405=x404
 if not table.B then
  x405=0
 end
 if x405 == 0x01 and not (memory.readbyte(0x00D8) == 0x00) then
  if memory.readbyte(0x00BD) >= 0x79 then
   memory.writebyte(0x00BD,0xFF - memory.readbyte(0x00BD))
   memory.writebyte(0x00BD,0xFF - (memory.readbyte(0x00BD)*1.05))
  elseif memory.readbyte(0x00BD) <= 0x80 then
   memory.writebyte(0x00BD,memory.readbyte(0x00BD)*1.05)
  end
 end
 
 if memory.readbyte(0x00D8) == 0x00 then
  if memory.readbyte(0x00BD) >= 0x79 and memory.readbyte(0x00BD) <= 200 then
   memory.writebyte(0x00BD,200)
  elseif memory.readbyte(0x00BD) <= 0x80 and memory.readbyte(0x00BD) >= 56 then
   memory.writebyte(0x00BD,56)
  end
 end
 
 memory.writebyte(0x03DD,0x7F) -- p-meter always full
 memory.writebyte(0x056E,0xFF) -- unlimited flight
 if not (memory.readbyte(0x00ED) == 0x05) then
  memory.writebyte(0x0578,0x06) -- raccoon mode at all times
 end
 if memory.readbyte(0x04F1) == 0x40 then
  memory.writebyte(0x04F1,0x00)
 end
 if memory.readbyte(0x04F2) == 0xB0 then
  memory.writebyte(0x04F2,0x00)
 end
 gui.text(0,36, tostring(x404) .. tostring(x405) .. tostring(memory.readbyte(0x00D8)) .. tostring(memory.readbyte(0x00D8) * x405))
 memory.writebyte(0x05F1,0x05) -- stop time
 memory.writebyte(0x0736,0x05) -- inf lives
 emu.frameadvance()
end
It's a bit long, if you think about it !

Powered by DjangoBB