Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Sup dis

Name: Anonymous 2011-08-30 17:40

what defines a Virtual Machine

must make one in python, haven't given the specifics of what it's suppose to do, we just know that it will have to act as a compiler

Name: Anonymous 2011-08-30 17:47

A virtual machine is simply an interpreter for a code that looks like a plausible processor's machine code.

Name: Anonymous 2011-08-30 19:12

>>1
Wrong. A compiler and a virtual machine are two different things. The compiler accepts readable code (this excludes J, Lisp and Haskell) as its input and produces well-packed not-humanely-unreadable code that is intended to be executed by a machine (the latter is the compiler's target). A virtual machine is a software implementation of a certain machine (which may or may not be feasible as a hardware design).

Example:

Input code to the compiler:
x = y + 42;

Output bytecode from the compiler (this example is particularly readable; don't expect anything like this in reality):
push_local 3
push_int 42
add
pop_local 2

Name: Anonymous 2011-08-30 20:12

Goodness.

A compiler is a program that translates input from one language to another language.

Name: Anonymous 2011-08-30 21:16

>>4
Thank you, pedant, why don't you confuse him even more.

Name: Anonymous 2011-08-31 0:37

>>1
Read SICP

Name: Anonymous 2011-08-31 0:51

>>3
Wrong. Human readability has nothing to do with compilers.
>>4 is right, a compiler translates one language to another, period.
Hence, a VM is a compiler in the sense that it translates a language (bytecode for instance) to side-effects.

Name: Anonymous 2011-08-31 1:37

Hence, a VM is a compiler in the sense that it translates a language (bytecode for instance) to side-effects.
I can accept this.

A virtual machine (VM) is a "completely isolated guest operating system installation within your normal host operating system".[1] Modern virtual machines are implemented with either software emulation or hardware virtualization.

Name: not >>4 2011-08-31 3:05

>>5
A compiler is a function from source code to source code. Better now?

Name: Anonymous 2011-08-31 3:42

>>7
1- A compiler translates one language to a language
2- A VM translates one language to side-effects
And you conclude:
3- Therefore a VM is a compiler

This would make sense if ``side-effects'' is a language

>>8
I can accept this
I can't.

Name: Anonymous 2011-08-31 3:58

fuck I hate these faggots.

Name: Anonymous 2011-08-31 10:28

I'm working on a VM write now. Just do some reading on machine architecture and implement the various pieces of hardware in code. Start with the ALU, that one's pretty easy.

Name: Anonymous 2011-08-31 12:01

>>1
python
Python is not as good as it is made out to be, in other words it suffers from a degree of hype. I'll try to argue this point. Potential detractors of the language usually lack the experience to criticize it authoratively. This is more true for Python as it is not (yet) common that people are coerced (by work, school) into learning and working with the language. So the detractors are few and drowned out by the vocal supporters.

The proponents of Python cite 'indentation' as the worst problem, this is a strawman argument 'this is the worst problem and its not really a problem'. This argument has been voted up presumably by people who like the language, because it is certainly not a good reason not to use Python.

I am far from an expert at Python, but I have done a couple of semi-serious projects in the language and will try to recall specifically what I didn't like.

- Everything you write will be open source. No FASLs, DLLs or EXEs. Developer may want to have control over the level of access to prevent exposure of internal implementation, as it may contain proprietary code or because strict interface/implementation decomposition is required. Python third-party library licensing is overly complex. Licenses like MIT allow you to create derived works as long as you maintain attrubution; GNU GPL, or other 'viral' licenses don't allow derived works without inheriting the same license. To inherit the benefits of an open source culture you also inherit the complexities of the licensing hell.
- Installation mentality, Python has inherited the idea that libraries should be installed, so it infact is designed to work inside unix package management, which basically contains a fair amount of baggage (library version issues) and reduced portability. Of course it must be possible to package libraries with your application, but its not conventional and can be hard to deploy as a desktop app due to cross platform issues, language version, etc. Open Source projects generally don't care about Windows, most open source developers use Linux because "Windows sucks".
- Probably the biggest practical problem with Python is that there's no well-defined API that doesn't change. This make life easier for Guido and tough on everybody else. That's the real cause of Python's "version hell".
- Global Interpreter Lock (GIL) is a significant barrier to concurrency. Due to signaling with a CPU-bound thread, it can cause a slowdown even on single processor. Reason for employing GIL in Python is to easy the integration of C/C++ libraries. Additionally, CPython interpreter code is not thread-safe, so the only way other threads can do useful work is if they are in some C/C++ routine, which must be thread-safe.
- Python (like most other scripting languages) does not require variables to be declared, as (let (x 123) ...) in Lisp or int x = 123 in C/C++. This means that Python can't even detect a trivial typo - it will produce a program, which will continue working for hours until it reaches the typo - THEN go boom and you lost all unsaved data. Local and global scopes are unintuitive. Having variables leak after a for-loop can definitely be confusing. Worse, binding of loop indices can be very confusing; e.g. "for a in list: result.append(lambda: fcn(a))" probably won't do what you think it would. Why nonlocal/global/auto-local scope nonsense?
- Python indulges messy horizontal code (> 80 chars per line), where in Lisp one would use "let" to break computaion into manageable pieces. Get used to things like self.convertId([(name, uidutil.getId(obj)) for name, obj in container.items() if IContainer.isInstance(obj)])
- Crippled support for functional programming. Python's lambda is limited to a single expression and doesn't allow conditionals. Python makes a distinction between expressions and statements, and does not automatically return the last expressions, thus crippling lambdas even more. Assignments are not expressions. Most useful high-order functions were deprecated in Python 3.0 and have to be imported from functools. No continuations or even tail call optimization: "I don't like reading code that was written by someone trying to use tail recursion." --Guido
- Python has a faulty package system. Type time.sleep=4 instead of time.sleep(4) and you just destroyed the system-wide sleep function with a trivial typo. Now consider accidentally assigning some method to time.sleep, and you won't even get a runtime error - just very hard to trace behavior. And sleep is only one example, it's just as easy to override ANYTHING.
- Python's syntax, based on SETL language and mathematical Set Theory, is non-uniform, hard to understand and parse, compared to simpler languages, like Lisp, Smalltalk, Nial and Factor. Instead of usual "fold" and "map" functions, Python uses "set comprehension" syntax, which has an overhelmingly large collection of underlying linguistic and notational conventions, each with it's own variable binding semantics. Using CLI and automatically generating Python code is hard due to the so called "off-side" indentation rule (aka Forced Indentation of Code), also taken from a math-intensive Haskell language. This, in effect, makes Python look like an overengineered toy for math geeks. Good luck discerning [f(z) for y in x for z in gen(y) if pred(z)] from [f(z) if pred(z) for z in gen(y) for y in x]
- Python hides logical connectives in a pile of other symbols: try seeing "and" in  "if y > 0 or new_width > width and new_height > height or x < 0".
- Quite quirky: triple-quoted strings seem like a syntax-decision from a David Lynch movie, and double-underscores, like __init__, seem appropriate in C, but not in a language that provides list comprehensions. There has to be a better way to mark certain features as internal or special than just calling it __feature__. self everywhere can make you feel like OO was bolted on, even though it wasn't.
- Python is unintuitive and has too many confusing non-orthogonal features: references can't be used as hash keys; expressions in default arguments are calculated when the function is defined, not when it’s called. Why have both dictionaries and objects? Why have both types and duck-typing? Why is there ":" in the syntax if it almost always has a newline after it? The Python language reference devotes a whole sub-chapter to "Emulating container types", "Emulating callable Objects", "Emulating numeric types", "Emulating sequences" etc. -- only because arrays, sequences etc. are "special" in Python.
- Python's GC uses naive reference counting, which is slow and doesn't handle circular references, meaning you have to expect subtle memory leaks and can't easily use arbitrary graphs as your data. In effect Python complicates even simple tasks, like keeping directory tree with symlinks.
- Problems with arithmetic: no Numerical Tower (nor even rational/complex numbers), meaning 1/2 would produce 0, instead of 0.5, leading to subtle and dangerous errors.
- Poor UTF support and unicode string handling is somewhat awkward.
- No outstanding feature, that makes the language, like the brevity of APL or macros of Lisp. Python doesn’t really give us anything that wasn’t there long ago in Lisp and Smalltalk.

Name: Anonymous 2011-08-31 13:13

>>13
>unintuitive
this is the only part of the criticism that is not right. Most programmers find Python's bullshit perfectly intuitive, because most programmers are mentally broken. "intuitive" and "usable" and "readable" are all very subjective and dependent on people's past experiences.

Name: Anonymous 2011-08-31 13:28

Python is the language of choice for non-programmers. Therein lies the problem.

Name: Anonymous 2011-08-31 13:29

>>3
not humanely readable
So humans can read it, but it's inhumane? What, does reading it scare it into killing its cubs?

Name: Anonymous 2011-08-31 13:43

>>16
What, does reading it scare it into killing its cubs?
Yes ;_;

Name: Anonymous 2011-08-31 13:44

>>9
I will write my compiler in Haskell.

Name: Anonymous 2011-09-01 13:13

I am a necromancer

Don't change these.
Name: Email:
Entire Thread Thread List