Sponsored Content
Full Discussion: Is it a joke or a command?
Top Forums UNIX for Beginners Questions & Answers Is it a joke or a command? Post 303034672 by wisecracker on Thursday 2nd of May 2019 05:33:54 AM
Old 05-02-2019
Hi fellas...

OO oriented programming lends itself to quick acting fork_bombing and memory eating.
Take this Python code deliberately held back:
Code:
# Works on any Python!
# OO programming eats memory like there's in no tomorrow!
text='Junk variable!'
for x in range(0,5,1):
    text=text+text
    print(text)
    print(id(text))

# A very basic fork bomb for Python, the print function holds it back:
# def _(): _()

def _(): print('_()'); print(id(_))
_()

Results OSX 10.14.3, default bash terminal calling Python 3.5.2.
Code:
Last login: Thu May  2 10:13:33 on ttys000
AMIGA:amiga~> cd Desktop/Code/Python
AMIGA:amiga~/Desktop/Code/Python> python3.5 OO_bomb.py
Junk variable! Junk variable! 
4328391264
Junk variable! Junk variable! Junk variable! Junk variable! 
4328477280
Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! 
4327568992
Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! 
4338181032
Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! Junk variable! 
4337054352
_()
4338198864
AMIGA:amiga~/Desktop/Code/Python> _

As one can see the fork bomb although not obfuscated is a single line of code and very dangerous.
Object Orientation OTOH is memory hungry and anyone with any knowledge can do that from Python interactive shell.
With only 2MB of memory on a stock AMIGA A1200 and Python this stood out only too well as soon my 2MB was gone.
These 2 Users Gave Thanks to wisecracker For This Post:
 

We Also Found This Discussion For You

1. What is on Your Mind?

Post Your Favorite Joke! Laugh a Little!

Let's have a few laughs! Post your favorite joke! (no racist / racism jokes, please post in good taste, thanks!) (65 Replies)
Discussion started by: Neo
65 Replies
while(n)						       Tcl Built-In Commands							  while(n)

__________________________________________________________________________________________________________________________________________________

NAME
while - Execute script repeatedly as long as a condition is met SYNOPSIS
while test body _________________________________________________________________ DESCRIPTION
The while command evaluates test as an expression (in the same way that expr evaluates its argument). The value of the expression must a proper boolean value; if it is a true value then body is executed by passing it to the Tcl interpreter. Once body has been executed then test is evaluated again, and the process repeats until eventually test evaluates to a false boolean value. Continue commands may be exe- cuted inside body to terminate the current iteration of the loop, and break commands may be executed inside body to cause immediate termi- nation of the while command. The while command always returns an empty string. Note: test should almost always be enclosed in braces. If not, variable substitutions will be made before the while command starts execut- ing, which means that variable changes made by the loop body will not be considered in the expression. This is likely to result in an infinite loop. If test is enclosed in braces, variable substitutions are delayed until the expression is evaluated (before each loop iter- ation), so changes in the variables will be visible. For an example, try the following script with and without the braces around $x<10: set x 0 while {$x<10} { puts "x is $x" incr x } SEE ALSO
break(n), continue(n), for(n), foreach(n) KEYWORDS
boolean value, loop, test, while Tcl while(n)
All times are GMT -4. The time now is 01:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy