Author Topic: DIY programming language  (Read 81750 times)

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #60 on: August 22, 2016, 06:22:41 AM »
Java is compiled into a specific form of byte code

Yes, it's for java, not for any other language. At least I haven't heard you could compile some other language to java byte code and run with jvm (well, except Scala I guess?). So the java byte code IS java, just in a sort of half-ass-compiled way, slower than pure machine code.

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: DIY programming language
« Reply #61 on: August 22, 2016, 06:30:00 AM »
Java is compiled into a specific form of byte code

Yes, it's for java, not for any other language. At least I haven't heard you could compile some other language to java byte code and run with jvm (well, except Scala I guess?). So the java byte code IS java, just in a sort of half-ass-compiled way, slower than pure machine code.

"Argument from (personal) incredulity (divine fallacy, appeal to common sense) – I cannot imagine how this could be true, therefore it must be false."

Here's a handy list of languages that target JVM: https://en.wikipedia.org/wiki/List_of_JVM_languages

But I was wondering. If you are after OO language that has similar syntax as C/C++, have you had a look at C#? Pretty familiar language, but has bunch of constructs that make your life easier.

You could write down list of features that you definitely want, would like to have and which would be nice. Armed with that list and internet, your search might turn up some language(s) that could be good candidate for next project.
Everyone you will ever meet knows something you don't.
 - Bill Nye

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #62 on: August 22, 2016, 10:00:42 AM »
Here's a handy list of languages that target JVM: https://en.wikipedia.org/wiki/List_of_JVM_languages

Yes, yes. But they all become java. There are some languages that "compile" to other languages, I think Ruby (could remember wrong) is strangely compiled to C! And then I guess compiled to executable. Weird if you ask me.

Quote
But I was wondering. If you are after OO language that has similar syntax as C/C++, have you had a look at C#?

I don't know if it has to be similar to C++. More like better if it's not.

tuturto

  • Rogueliker
  • ***
  • Posts: 259
  • Karma: +0/-0
    • View Profile
    • pyherc
Re: DIY programming language
« Reply #63 on: August 22, 2016, 10:17:26 AM »
I don't know if it has to be similar to C++. More like better if it's not.

It'll be easier to find when you know what you're searching for. When you find your language, do let us know  :-*
Everyone you will ever meet knows something you don't.
 - Bill Nye

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #64 on: August 28, 2016, 05:13:13 PM »
I wonder if I really have to try Ruby on Windows, because I can't make any sense of installation instructions for OSX. You need like zillion programs already installed before you can start to install Ruby. This is unix/linux style stuff, right?

Antsan

  • Rogueliker
  • ***
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: DIY programming language
« Reply #65 on: August 28, 2016, 05:43:20 PM »
The official page says that you can install Ruby via homebrew like this:
Code: [Select]
$ brew install ruby
https://www.ruby-lang.org/en/documentation/installation/#homebrew

This should install all dependencies automatically.
Are you trying to compile yourself? This almost always requires all kinds of dependencies, even on Windows. The equivalent to using an installer is doing it with a package manager like homebrew.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #66 on: August 28, 2016, 07:39:41 PM »
I need to install homebrew? I wonder how difficult it is to install. Maybe first I need to install something else.

Antsan

  • Rogueliker
  • ***
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: DIY programming language
« Reply #67 on: August 28, 2016, 08:02:09 PM »
http://brew.sh/
Code: [Select]
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Seems you need ruby. ;D

But seriously though, you actually might try compiling yourself. The Ruby page says this about compiling:
Quote
Of course, you can install Ruby from source. Download and unpack a tarball, then just do this:

Code: [Select]
$ ./configure
$ make
$ sudo make install

By default, this will install Ruby into /usr/local. To change, pass the --prefix=DIR option to the ./configure script.

Using the third-party tools or package managers might be a better idea, though, because the installed Ruby won’t be managed by any tools.
No idea whether these instructions work for OS X. There is no mention of any dependencies.
Is make normally installed on OS X?

Actually, OS X supposedly comes with ruby preinstalled. Installing homebrew and installing ruby with that might still be a good idea, though – the preinstalled version is probably very much out-of-date.
« Last Edit: August 28, 2016, 08:06:34 PM by Antsan »

doulos05

  • Newcomer
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: DIY programming language
« Reply #68 on: August 29, 2016, 09:56:10 AM »
Java is compiled into a specific form of byte code

Yes, it's for java, not for any other language. At least I haven't heard you could compile some other language to java byte code and run with jvm (well, except Scala I guess?). So the java byte code IS java, just in a sort of half-ass-compiled way, slower than pure machine code.

Java byte code is Java only in the loosest possible definition of that word. You wouldn't look at an executable compiled from a C++ program for a Windows machine and say, "Oh, that was written in Windows. I don't do windows."

It wasn't written in Windows, it was written in C++, it just happens have been compiled against the windows environment. JVM is the same. It's an environment you can compile code against. I can't think of any reason you couldn't compile any language against the JVM environment (though I can think of several reasons why you shouldn't compile done languages against JVM).

JVM allows you to write once, play anywhere. That's why it's a "half-ass-compiled" sort of thing. The local JVM interprets the specifics of X vs. DirectX vs. iDisplay (no clue what apple calls their display suite) or various file system things or other interoperability concerns. It is slower, a fact highly unlikely to matter unless you've implemented particle physics in your game (in which case, don't do that. The world doesn't need 2 Dwarf Fortresses) because it's pretty damn fast. For reference, Minecraft is written in Java. It runs just fine speed wise.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #69 on: August 29, 2016, 09:57:02 AM »
Actually, OS X supposedly comes with ruby preinstalled.

Funny, it does. The version seems to be 2.0.0. which is good enough I guess. But when I'm reading the documentation of Ruby it looks like it's a gigantic language. I don't know where to start. Probably just hacking in some classes and trying to create some kind of basic io for a roguelike. Man this is hard!

ps. I wonder what -else- is pre-installed on OSX.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #70 on: August 29, 2016, 09:59:11 AM »
I can't think of any reason you couldn't compile any language against the JVM environment

Well you can't. Unless you write a compiler to compile C++ (or whatever) to Java first.

Antsan

  • Rogueliker
  • ***
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: DIY programming language
« Reply #71 on: August 29, 2016, 10:25:15 AM »
I can't think of any reason you couldn't compile any language against the JVM environment

Well you can't. Unless you write a compiler to compile C++ (or whatever) to Java first.
The code run by the JVM is not Java. It's bytecode that has exactly nothing in common with Java at all. The only connection they share is that Java was the first language to be compiled into that form of bytecode. So no, you don't need to compile anything to Java to run it on the JVM.

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #72 on: August 29, 2016, 12:22:22 PM »
The code run by the JVM is not Java. It's bytecode that has exactly nothing in common with Java at all.

Read the first line of text in Wikipedia:
"A Java virtual machine (JVM) is an abstract computing machine that enables a computer to run a Java program."

..to run a Java program.
..a Java program.
..Java..

Antsan

  • Rogueliker
  • ***
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: DIY programming language
« Reply #73 on: August 29, 2016, 12:57:01 PM »
The code run by the JVM is not Java. It's bytecode that has exactly nothing in common with Java at all.

Read the first line of text in Wikipedia:
"A Java virtual machine (JVM) is an abstract computing machine that enables a computer to run a Java program."

..to run a Java program.
..a Java program.
..Java..
At the end of that same pararaph:
Quote
An instance of a JVM is an implementation running in a process that executes a computer program compiled into Java bytecode.
Quote
a computer program compiled into Java bytecode.
Quote
compiled into Java bytecode.
Quote
Java bytecode.
Quote
bytecode

So, what's Java bytecode?
Quote
Java bytecode is the instruction set of the Java virtual machine. Each bytecode is composed of one, or in some cases two bytes that represent the instruction (opcode), along with zero or more bytes for passing parameters.
Hmmm… One or two bytes per instruction. Somehow that doesn't sound like Java at all, since Java isn't instruction based. I think the language doesn't even have a concept called an "instruction".
Also:
Quote
A Java programmer does not need to be aware of or understand Java bytecode at all. However, as suggested in the IBM developerWorks journal, "Understanding bytecode and what bytecode is likely to be generated by a Java compiler helps the Java programmer in the same way that knowledge of assembly helps the C or C++ programmer."[2]
Seems the relationship between Java and Java bytecode is roughly the same as the relation between C++ and Assembly.

Here's an example of Java bytecode in human-readable instead of binary form:
Code: [Select]
0:   iconst_2
1:   istore_1
2:   iload_1
3:   sipush  1000
6:   if_icmpge       44
9:   iconst_2
10:  istore_2
11:  iload_2
12:  iload_1
13:  if_icmpge       31
16:  iload_1
17:  iload_2
18:  irem
19:  ifne    25
22:  goto    38
25:  iinc    2, 1
28:  goto    11
31:  getstatic       #84; // Field java/lang/System.out:Ljava/io/PrintStream;
34:  iload_1
35:  invokevirtual   #85; // Method java/io/PrintStream.println:(I)V
38:  iinc    1, 1
41:  goto    2
44:  return
Huh, it doesn't even look like Java at all.

Being a self-taught Cowboy programmer is nice and all, but if you're missing formal education you'll have to be more careful when reading and talking about stuff you're new to.
« Last Edit: August 29, 2016, 01:00:01 PM by Antsan »

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: DIY programming language
« Reply #74 on: August 29, 2016, 03:31:10 PM »
I'm sorry, it still requires a language that can be processed by the JAVA vm. You know, not all languages are compatible with JVM.