Forums

On Snakes

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

On Snakes

Postby Nichdel » Tue Sep 13, 2011 10:35 am

Hello,

I'm a college freshman studying Computer Science and Linguistics. I do hobby programming. Recently, when just getting into the swing of a game project, I got frustrated. So far the code has been in Python. I like to think I'm pretty good at python, but not amazing. My frustration comes from a few sources:

1. Python is JIT, not compiled. This makes it hard to distribute a game (Unless I make it a giant frozen mess).
2. Python is fully dynamic and the code is a bit irregular. Maybe this is just me not writing good code, but I find it really hard to read my own code and predict what will happen when this does that and what not. Especially when working with 3 dimensional arrays :cry:.
3. Python isn't very fast, and sucks at math. Have you programmed anything in Python that's math intensive? It sucks. It takes forever and sometimes doesn't even give the right answer. Games like quick math, and accurate answers.

So anyway I started looking at Jython and Cython and all that, and one way or another I found my way to your language's wikipedia page.

I admittedly haven't done much at all with the language yet, but it looks like Python, but much more what I need. I'll probably spend some time this week and this weekend messing with the language, and if I'm content I might work on my game project in it.

Thanks for a very interesting (and hopefully very good) language.
Nichdel
 
Posts: 4

Re: On Snakes

Postby Charles » Tue Sep 13, 2011 1:21 pm

You're welcome. Python does have some "answers" regarding performance, but it's kind of maze with the various choices and how they are used. I ended up concluding that performance should be paid attention to in the core design of the language.

Technically speaking, the main Python product is a byte code interpreter with no JIT compilation, which is a term generally used with .NET and JVM, which do JIT compilation to x86 machine code (and potentially other chips).

Some tips regarding Cobra:

-- I recommend you start with the very latest Cobra. See HowToInstallFromSource

-- You've probably already found these, but just in case:
How to use OpenTK/OpenGL
How use XNA

-- Cobra will probably be fast enough for you out of the box, but if you need even more speed the -turbo option turns off all kinds of run-time checks and will give you another speed boost. A "turbo boost" if you will...

-- The How to Learn Cobra page has key links to other Cobra pages.

-- I'd love to see a game in Cobra. Good luck with your coding.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: On Snakes

Postby Charles » Tue Sep 13, 2011 10:29 pm

I forgot to mention that I cooked up an n-dimensional Matrix class to make it easier to work with such data. Announced here.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: On Snakes

Postby Nichdel » Wed Sep 14, 2011 9:07 am

I'm actually having trouble installing from source. I'm on Windows 7 x64 with .NET 4.0. I follow the instructions, run the installer, and get 71 errors and 1 warning.

Most of the errors are something like:

The type or namespace name "WhateverItsCalled" does not exist in the namespace "System.SomethingorAnother" <are you missing an assembly reference?>


There are also a few:

The non-generic type "System.Collections.Stack" cannot be used with type arguments


I can dump the whole thing if you'd like.
Nichdel
 
Posts: 4

Re: On Snakes

Postby Charles » Wed Sep 14, 2011 3:28 pm

Sorry to hear that. We have a Troubleshooting wiki page, but I don't see a section with that form of error message being given during installation, although there is a section on 64-bit you could look at.

I have Win 7 64-bit as well in a virtual machine (VM). I'll fire it up later tonight and see what I find.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: On Snakes

Postby Charles » Thu Sep 15, 2011 2:51 am

I fired up Win 7 Ultimate 64-bit, installed all updates and gave Cobra a go. I'm having problems as well, although a different error:
Code: Select all
Compiling installation program...

The Cobra Programming Language
Install From Workspace

Working...

==== Verify running as admin user

==== Verify installation directory

found dir: C:\Cobra

==== Verify running in workspace

Verified.

==== .NET 4.0 Prompt

Cobra can be installed for .NET 2.0/3.0/3.5 or .NET 4.0.
Do you want to install for .NET 4.0? [no] yes

==== Locate and test Cobra Snapshot compiler

run: Snapshot\cobra.exe -about
   : The Cobra Programming Language svn:2575 (post 0.8) / 2011-07-22 on .NET CLR v2.0.50727
   : Copyright (C) 2003-2011 by Cobra Language LLC.  All Rights Reserved.
   :
   : On the web:  http://cobra-language.com/
   : Source:      http://cobra-language.com/source
   : Support:     http://cobra-language.com/support
   : License:     http://www.opensource.org/licenses/mit-license.php
   :
   : Usage:       cobra -h

==== Build new Cobra compiler

run: Snapshot\cobra.exe -compile -native-compiler:C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe -turbo -ert:yes
cobra.cobra -files:files-to-compile.text
   : Compilation succeeded

==== Retrieve Cobra base version number

run: cobra.exe -version
   : svn:2618 (post 0.8) / 2011-09-15 on .NET CLR v4.0.30319

base version: 4.0.30319-post

==== Build Cobra.Lang library

run: cobra.exe -build-standard-library -debug -native-compiler:C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe -tu
rbo -out:Cobra.Lang.dll -key-file:Cobra.Lang\Cobra.Lang.snk Cobra.Lang\AssemblyAttrs.cobra
   : Compilation succeeded

==== Install Cobra.Lang library to the GAC

Invoking Publish.GacInstall...
Done.

==== Verifying Cobra.Lang.dll installed to the GAC

Skipping due to running on .NET 2, but installed for .NET 4.

==== Build Cobra.Lang.Compiler library

run: cobra.exe -c -t:lib -namespace:Cobra.Lang.Compiler -files:files-to-compile.text -debug -native-compiler:C:\Windows\
Microsoft.NET\Framework\v4.0.30319\csc.exe -turbo -out:Cobra.Lang.Compiler.dll -key-file:Cobra.Lang\Cobra.Lang.snk cobra
.cobra
   : Compilation succeeded

==== Install Cobra.Lang.Compiler library to the GAC

Invoking Publish.GacInstall...
Done.

==== Verifying Cobra.Lang.Compiler.dll installed to the GAC

Skipping due to running on .NET 2, but installed for .NET 4.

==== Verify newly built Cobra compiler

run: cobra.exe -about
   : The Cobra Programming Language svn:2618 (post 0.8) / 2011-09-15 on .NET CLR v4.0.30319
   : Copyright (C) 2003-2011 by Cobra Language LLC.  All Rights Reserved.
   :
   : On the web:  http://cobra-language.com/
   : Source:      http://cobra-language.com/source
   : Support:     http://cobra-language.com/support
   : License:     http://www.opensource.org/licenses/mit-license.php
   :
   : Usage:       cobra -h

run: cobra.exe -ert:no Misc/hello.cobra
   : Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Cobra.Lang, Version=0.0.2618
.1, Culture=neutral, PublicKeyToken=0a4783a5c7c9616e' or one of its dependencies. The system cannot find the file specif
ied.
   :    at Program.Main()
   :    at MainWrapper.Main()

** ERROR: Cannot run hello.cobra with new compiler.
Need help with the above error?
 * Make sure you ran as a Windows Administrator.
 * Install .NET or a Visual Studio product if you have not before.
 * Review http://cobra-language.com/troubleshooting
 * Ask at http://cobra-language.com/discuss
 * Ask at http://cobra-language.com/irc

Interestingly, when I try to launch "hello.exe" from the command line after that, it complains about a different version of the Cobra.Lang.dll library:
Code: Select all
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'Cobra.Lang, Version=0.8.0.1, Culture=neutral, PublicKe
yToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'Cobra.Lang, Version=0.8.0.1, Culture=neutral, PublicKeyToken=null'
   at Program.Main()
   at MainWrapper.Main()

Hmm... that's an old hello.exe. I'll tweak the installer to remove that.

And that "Misc/hello.cobra" path looks suspicious given that I'm in Windows...

I think my error is a different problem than yours. You should post the whole output after all. Make sure you run as admin.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: On Snakes

Postby Nichdel » Thu Sep 15, 2011 6:34 am

I apparently had the client version of .NET Framework installed instead of the full version.

I noticed because I attempted to check the version of DisUtils (as per your other thread) and didn't get anything.
Nichdel
 
Posts: 4

Re: On Snakes

Postby Charles » Thu Sep 15, 2011 2:52 pm

Cool. After I installed, I still had problems where "cobra test.cobra" would not find the Cobra standard library. This was only if I installed for .NET 4 and has to do with the separate library areas for .NET 2/3/3.5 vs. .NET 4. I'm working on a fix. In the mean time, the work around is to embed the run-time:
Code: Select all
cobra -ert:yes test.cobra

You only need to do this if you experience a problem about "Cobra.Lang.dll".
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: On Snakes

Postby Nichdel » Thu Sep 15, 2011 5:29 pm

I just messed with some simple scripts earlier and did have that problem. My solution was to just throw a copy of the dll in the same folder as the resulting .exe.
Nichdel
 
Posts: 4

Re: On Snakes

Postby Charles » Thu Sep 15, 2011 10:23 pm

I forgot to mention that works as well.
Charles
 
Posts: 2515
Location: Los Angeles, CA


Return to Discussion

Who is online

Users browsing this forum: No registered users and 51 guests