Languages

Started by
14 comments, last by rip-off 12 years, 9 months ago

EDIT: Damn your quickness Brain!

I don't rely on your slow typing. My vat is directly connected.
Advertisement

Yes... I'm fairly able as a programmer in java, but I'm totally lost when it comes to computer science theory with the compilers and interpreters and everything. My main issue is school computers which don't seem to have any way of running code that is written on the spot. It is partially just for personal fun, as I can write java in text and move it between computers all the same, but it'd be nice to be able to run it from a school computer. Is there any chance of being able to directly write an exe or jar file, or is just not worth the effort?

@A Brain in a Vat: So if something were installed onto a flash drive, could it still run, even though it's not on the actual computer?




Nothing runs code "just from a text file." You either have an interpreter (as is the case with Python, batch, and many other scripting languages) or a compiler (as is the case with Java and C++). Some obscure languages, including older BASIC dialects and some flavours of C, can be run either way - but one of those tools must be present. An interpreter essentially runs the program "raw" whereas a compiler translates it into some other format, which can then be run "by itself" (for native programs) or with the aid of other programs again (for virtual-machine based platforms such as Java and C#).

Software relationships are incredibly complex and intricate; there may be literally dozens of different pieces of software involved in just installing and running something like Notepad or Calculator. Web browsers and programming language environments and video games can involve hundreds. Major server systems that power MMOs, web sites, and Youtube might involve thousands of distinct pieces of software, when you account for the entire ecosystem.

This is, by and large, actually a good thing. It means we can rely on other people to do a good job at certain features, while we focus on the features that matter to us. Hence the presence of libraries, APIs, platforms, frameworks, kits, and all manner of software that exists solely to help make other software possible.

One of the deep truths of modern computing is that no program is an island. There will inevitably be many different pieces of software involved in even the most apparently trivial computing job performed on a modern PC or game console. This is less true on embedded devices like the computer that runs the fuel injectors in your car engine, but it is still true to some extent.


So, all that to say: can you write an .EXE or .JAR file without needing a compiler or some other tools? No.

At the very least, you need a hex editor or something that can support writing out binary files. Even then, you'll need to master a handful of important things before you can make even trivial programs without a compiler:

  • Executable file formats on your platform of choice (PE, ELF, etc.)
  • Machine language encoding of instructions for your CPU of choice (x86, x64, PowerPC, ARM, etc.)
  • How to program in machine language for your CPU of choice
  • How executable files are packed and how they are loaded into memory on your OS of choice
  • Dynamic as well as static code linking on your OS of choice
  • Kernel vs user space distinctions
  • How to invoke kernel code from user space, and vice versa
  • Calling conventions, typical memory models, and other methods for communicating with other libraries, APIs, and programs

And of course that's just so you can write "hello world" on the screen. If you want to do anything interesting, plan on learning about ten times that much, plus a lot of hard lessons in software architecture.


In a nutshell, your situation is this:

  • You are learning to drive
  • You can't afford your own car
  • You can only borrow a car from, say, your parents, on an infrequent basis
  • You really want to be able to drive more

The question you are asking is, "How can I drive without buying a car of my own?" The answer, of course, is you build your own car.

But this is, unquestionably, ten million times harder than just getting a job and saving up for your own car. You have to learn a huge amount about how cars work, how the tools work that are used to make cars, and so on. If you're really hardcore, you have to learn about metallurgy, and how to cast your own engine blocks and such stuff. Maybe you refuse to buy wrenches from Home Depot and must manufacture those yourself, too. And so on.

Eventually, the obvious answer should start seeming attractive: just get a job, work for a while, pay your dues, and buy your own car when you can.

The analogous answer to your programming question is similarly straightforward, although probably not what you wanted to hear: use the tools, learn how they work, and learn to appreciate them. They really are saving you a tremendous amount of pain; you just don't know it yet.

Best of luck :-)

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

What Apoch said.

EDIT: Also, you might look at Windows Powershell instead of bat files, or whatever it's called. You might be able to have a lot of fun with what windows comes with out of the box.
+1 for powershell. It's a pretty cool system to learn for general tinkering and gluing together various elements of larger systems.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Um... given that this is the beginner's forum and this is the first question the OP has posted, maybe it's worth while to check that the OP is just looking for how to compile something in release mode? You know... do all the work on your development machine then compile it in release mode so you can take the exe file and run it on your mom's computer.

[edit]
Sorry, I guess it's his second topic.
I believe what you are struggling with is the distinction between development and deployment. Each of these environments requires and provides different runtimes and toolchains.

Speaking generally, statically compiled languages make an obvious distinction between the two environments, and dynamic languages provide the same environment for development and deployment.

So, the things you need to figure out for your language of choice are:

  • What do I need to provide as a deployment runtime?
  • Can I avoid installing this?

If you want to develop on the fly, you need to figure out the above for the development environment too.

My main issue is school computers which don't seem to have any way of running code that is written on the spot. It is partially just for personal fun, as I can write java in text and move it between computers all the same, but it'd be nice to be able to run it from a school computer. Is there any chance of being able to directly write an exe or jar file, or is just not worth the effort?
[/quote]
This may be possible, provided your school computers don't contain too many security restrictions. If the computers in question can run Java applets, then they have a JRE (Java deployment environment) already installed. All you need now is a portable JDK (Java development environment). On Linux I can download a JDK as a single zip, which extracted into a folder contains everything I need.

Looking at the JDK download page all the Windows packages are provided as executable installers, but it might be possible to similarly capture a JDK into a folder and make it portable. You can then move this to a USB key (if you are allowed to use them) and all you need to do is correctly set JAVA_HOME and PATH to point to the JDK. You can write a batch script that sets these variables and gives you a command prompt from which you can call the Java compiler. There are some promising ideas here.

If you get all that working then you should be able to edit, compile and run Java programs without installing an IDE. You might consider testing this deployment by using some kind of virtualisation software (e.g. VMWare) to run a "clean" Windows installation.

This topic is closed to new replies.

Advertisement