Declarative language to describe abstract objects and behaviour - c++

I don't know a lot about declarative languages. I'm looking for simple and minimalistic language to describe objects, their attributes and a way that they react when any environment event occurs.
I would like to use, process and write this code from c++.
It would be useful for 2d rogue-like or strategy games, any simulations etc.
Does exist anything like that or similar?
I would like to try to write this on my own, but I don't want to reinvent the wheel :)

I am pretty sure there are no Declarative Languages that do what you are looking for. Declarative Languages are highly tailored to their problem domain. When you say you want a language that describes "a way that [objects] react when any environment event occurs" makes me think that a Declarative Language is not what you're looking for since that implies side effects.
If you are looking for Embeddable Languages then Lua and Python are both proven. The Warcraft 3 engine used a Lua derivative for its scripting which is very similar to what you are describing, and Python is widely used for embedding in general.
If you are looking for a standard minimalistic data format, JSON is pretty much the way to go, and lord knows there are standard parsers out there.

Related

Scripting languages and Game Dev/Programming

Okay, so I've been getting into 2D game developing/programming , and many games I've seen use some sort of scripting language too. So I'm wondering - What's the purpose of using scripts in games? I know there's not simple one reason answer, and I've been trying to consider all the possibilities. Here's what I 'think' I know so far:
1) Scripts allow for changing the game without having to re-compile.
2) Scripts are easier for non-programmers to use.
3) Scripts allow me to separate the engine from the game itself allowing me to make other games with the same components quicker?
That's about all I'm aware of. My next question is, if I'm going to be Dev/programming a game alone - do I really need to use scripts? Or could I prototype the game using something like python or ruby, to allow for rapid testing, then rewrite the code in C++ saving time and compiler bugs, etc?
Another thing I'm wondering, Am I better off using Ruby or Python since I'm most experienced with those? Or should I use Lua, Perl or something else if it better fits what I aim to achieve? Speaking on that matter, what really should I use scripts for? should I use them to position and model game menu UI's, write/read save-files, load map levels, hold arrays or structures of game terminology such as "New Game" or "Quit," all of the above, none of the above?
If I make use of scripts, won't that allow game mechanics to be edited by the end user? Or is there a way to package the scripts into one compressed file that the engine can read?
Most basically, I'm wondering:
What should I use scripting in my game for? And why?
Do I need use scripting languages if I'm working alone or with programmers as opposed to Devs?
What scripting language 'should' I use if I were to be making platformers, RPGs, or what-have-you?
your top 3 reasons are all 100% correct and are the main reasons for using scripting languages along with your game engine.
Personally I've only really had experience with Lua through Luabind. It's a little tricky to setup but it was worth it. What you can do with scripting languages is expose the data structures and/or functionality that you want the 'user' in this case yourself, to be able to use. Generally speaking the only game mechanics etc that can be editted would be the ones you allowed them to.
What should I use scripting in my game for? And why?
Asset loading, exposing features/types, ie, for our game engine (written in c++), we had a base level, and then many different types of level inherriting from it, such as wave level, death match, etc. The user simply states in the script what type of level they need, and then chucks in the assets here too. In my demo we had;
Level="wavelevel"
--Level Initial number of enemies
EnemyNumbers="3"
--Level Total number of waves
WaveNumbers="4"
--Wave coefficient
WaveCoeff="1.1"
--Size of terrain
TerrainSize="256"
--Terrain file
TerrainFile="resource/Models/mountainous.raw"
Don't worry too much about the numbers and all of that.
As you can see that does some asset loading as well as determining the level type
We also gave a lot of control for the AI to scripts, in fact, the data structures were almost completely exposed to Lua.
Do I need use scripting languages if I'm working alone or with programmers as opposed to Devs?
Yes no maybe? We all prefer 'real' coding of course. If you can make your game engine abstract enough to build completely different games just with Lua, then it means you've done a great job and have designed it very well.
The other thing you have to think about, especially if you're game engine is quite huge, and lets face it, there isn't really going to be a small one, each time you compile, it can take minutes! It's the linker that's taking time here.
What scripting language 'should' I use if I were to be making platformers, RPGs, or what-have-you?
I've only ever used Lua, so that's the only advice I can give here.
Hope this is helpful info for you.
Honestly, as this sounds like your first attempt at a game ever, you shouldn't even be worrying about this sort of thing. Instead, I'd be more worried about keeping the scope of your project down to a level where you have a snow ball's chance of actually completing something. If you haven't done something at the level of Tic-Tac-Toe or Pong yet, do that first. What you learn there will be more valuable than worrying about a scripting language.
Oh and if you are doing an RPG as your first attempt at a game. Don't. They are by far the hardest type of game to do even for professional developers with many, many times the resources available to them. Keep it simple and and use this as a learning experience.
Back to your questions:
If you are the only one who will ever see your game, your choice on using a scripting language or not. If it will save you time overall or you want to learn how to do integration of scripting with code, go for it, but beware it will be a bit of a time sink.
Yes/no/depends on your second. If the scope of your game is small, scripting isn't as important. If you doing this alone, scripting isn't as important.
Your choice on what you know or what your engine will support (or what engine tools you cna buy to support). Lua is popular, but even hand rolled scripts will work as well. It's more about decoupling data from code and design type work from engineer type work.
Your initial points above apply. Scripts keep non coders out of code and allow anyone on a team to easily change data related stuff that should be in code anyways. Scripts also act as a very high level language allowing lots of game level changes in controlled ways that would/will look ugly if placed in code. I've personally worked on games that were done both ways. Scripted games were a bit easier to maintain at the end of the game cycle - IF IF IF the script support code was mature and had been run through some debug cycles. New script support code is harder to debug than coding things straight because there are more possible points of failure. Games that were coded without scripts tended to get done a touch faster, but required a lot more programmer/engineer time which means the overall scope of things had to be limited to stay on budget.
I will say that well designed scripting and overall gaming system will always beat straight coding. Look at Unity for an example of how scripting and code and everything else can be coupled into a slick interface that allows very quick game development.
What should I use scripting in my game for? And why?
The reasons you cited are good ones. One thing that you might need to understand is that most professionnal games are still built with C++ and it's far from being flexible to change if the code base is big. So if you use C++ you'll need scripting languages to make quick changes where it's imporant to be allowed to do so accordingly to the reasons you listed.
If you don't use C++, maybe you use a language that can absorb changes quickly, making the main purpose of scripting not so obvious. I wouldn't use scripting language in a Flash or Python game for example.
Do I need use scripting languages if I'm working alone or with
programmers as opposed to Devs?
As my previous answer : it depends on the timing of changes. Think that the core rules of games rarely change but everything relative to level design will, and should be testable ASAP. If you can do it in the game's programming language, why bother? If you can't, then any way to speed-up change integration will pay.
What scripting language 'should' I use if I were to be making
platformers, RPGs, or what-have-you?
Frankly, there is no one solution to any problem. I personally use Falcon and ChaiScript, Lua is well known but any scripting language that can be used with your game programming will do. That's a question already asked around and if you have doubt, just choose Lua as it's the most common in gaming.
I'll give you a quick and short answer. Scripts are mostly for changing things while the game is still running which you can edit things faster. This is much better then recompile, reloading the assets, going to the specific point in game, activate certain conditionals (items, talking to people in specific order, etc) and etc.
Things done in script are character speech, NPC interaction with triggers (for example walking somewhere stopping to talk to another NPC, then run somewhere, scripting is used for timing), triggers or events in general and enemy stats (health, speed, accuracy, sometimes logic for said character).
The reasons you list are all valid reasons for using scripting languages in games. I'd also add another reason though: different languages are better suited to different kinds of programming tasks and a high level scripting language allows you to write parts of your game in a language that might be a better fit than C++.
The main reasons C++ is widely used in games are performance, easy access to low level native APIs or hardware (on consoles) and inertia - most games are written in C++ so most third party libraries and middleware for games are written in C++ and most easily interfaced with from C++. For many tasks however higher level languages like Python, C# or Ruby have programmer productivity benefits over C++ that can outweigh the advantages of C++ for code that is not performance critical or does not have to interface with native APIs.
A well designed C++ game engine with a high level scripting language can give you the best of both worlds - the performance and low level access of C++ where it's most needed and the productivity benefits of a high level language where they are most needed.
As a matter of fact, almost all MMORPG game servers are programmed in script.
All the C++ engin will embed a script language for logic handling, lua is a suitable script language for it.
In bigworld, python is the default embed language.
And node.js is also a good candidate for game server programming. Because its network io ability is superior. There is an open source framework in node.js:
https://github.com/NetEase/pomelo/
I've found it unhelpful to use scripts, both when I was employed in a large game studio and in my work as an indie developer. On the other hand I have friends who've used professional-grade, modern engines with scripting technology successfully. As you're doing indie game development on your own (or in a small team), I think you should avoid it. The main reasons are:
It adds overhead pretty much everywhere: one more language to master (per developer in the team), performance is slower than native, and the API the weakest link which means you often need to rebuild the binary anyway.
The only real gain with a higher-level language is less development hours up front (if you're using a mature engine), but in my experience that time is eaten up by time-consuming bug-smashing in the end.
Many game scripting languages uses dynamic typing (Lua, Stackless Python, Pawn), which I find error-prone compared to statically typed languages. If you too feel it's only good for simple things, you might as well do it natively instead.
As a side-note I do find game scripting languages exceptionally useful, but only for quick-hack/prototype apps, not for huge components within games. See my answer here.
I'm not convinced scripting interfaces for games you write yourself are so useful. I did some work on Freeciv once, and immense effort went into enabling "modding" using the scripting interface. A feature that seemed little used. I think there is a danger of the inner platform effect. You don't need a scripting language to customize your game: you already have a perfectly good programming language (C++, in your case) for doing that. It's a WTF.
What should I use scripting in my game for? And why?
As everyone (including you) has said, scripts make your game easier to edit. On a larger team scripting also has a very good productivity effect: the tech-savy folks can continue to polish the engine, while the creative people can work on the actual game, and the two teams don't have to get in each other's way.
Do I need use scripting languages if I'm working alone or with programmers as opposed to Devs?
You don't need it and depending on what you're final goal is, it might actually be a waste of time to implement scripting. I also develop a 2D scriptable game atm; I'm alone but I'm making it scriptable also as a personal challenge and also because I want the game to be easily modifiable.
What scripting language 'should' I use if I were to be making platformers, RPGs, or what-have-you?
The top two most popular options are Lua and Python. Most people recommend Lua because it's slightly faster. I went with Python because it has (native) support for classes — which works well with my existing C++ architecture — and also because I find it to be a much more enjoyable language to work with.
Okay, I know this is a bit dead, but I have to say this. There is literally no such thing as programming without scripts. It honestly doesn't matter if you write them in yourself or not, fact is, somebody wrote those scripts. Like ruby, in order to use it, you need a program like say notepad+ in order to set it up, or any computer based RPG Maker from enterbrain uses a form of ruby to operate. like it or not, when using computers to design a game, learn to script. Now as for the language, look some up and try different ones out. Don't cheap out with using a pre compiled engine, just work from scratch. trust me, you will be better off. I am still trying to decide which I like better, Lua(C++) or Ruby. I may just use pure C++

C++ Implementing scripting (Repeatable Actions)

I have a desktop app written in C++. It does a variety of different things and interacts with a database. I have made most actions that need to be performed selectable from a list. Actions are performed serially on data sets and need to be saved and played back at a later time on a different result set.
The actions are typically performed from a drop down menus and there are no load/save to disk operations. I dont' necessarily need scripting capability, but if thats the easiest way to go that's fine.
How would you approach this?
Added, This application is NOT written in OOP style
Lua
It's a great, simple scripting language, easily embedded into your apps.
Sounds like the GoF Command design pattern:
http://en.wikipedia.org/wiki/Command_pattern
http://www.oodesign.com/command-pattern.html
lua with LuaBind is quite widely used
Python with boost::python is also widely used but heavier on space
Now I know less know scripting languages that are useful in game programming, so useful in whatever application you need scripting for:
Falcon : the more versatile and flexible solution I know and use
ChaiScript : the easier to integrate I know
AngelScript : didn't try yet
GameMonkey : didn't try yet
IO : didn't try yet

Mixing Haskell and C++

If you had the possibility of having an application that would use both Haskell and C++.
What layers would you let Haskell-managed and what layers would you let C++-managed ?
Has any one ever done such an association, (surely) ?
(the Haskell site tells it's really easy because Haskell has a mode where it can be compiled in C by gcc)
At first I think I would keep all I/O operations in the C++ layers. As well as GUI management.
It is pretty vague a question, but as I am planning to learn Haskell, I was thinking about delegating some work to Haskell-code (I learn in actually coding), and I want to choose some part where I will see Haskell benefits.
The benefit of Haskell is the powerful abstractions it allows you to use. You're not thinking in terms of ones and zeros and addresses and registers but computations and type properties and continuations.
The benefit of C++ is how tightly you can optimize it when necessary. You aren't thinking about high-minded monads, arrows, partial application, and composing pure functions: with C++, you can get right down to the bare metal!
There's tension between these two statements. In his paper “Structured Programming with go to statements,” Donald Knuth wrote
I have felt for a long time that a talent for programming consists largely of the ability to switch readily from microscopic to macroscopic views of things, i.e., to change levels of abstraction fluently.
Knowing how to use Haskell and C++ but also how and when to combine them well will knock down all sorts of problems.
The last big project I wrote that used FFI involved using an in-house radar modeling library written in C. Reimplementing it would have been silly, and expressing the high-level logic of the rest of the application would have been a pain. I kept the “brains” of it in Haskell and called the C library when I needed it.
You're wanting to do this as an exercise, so I'd recommend the same approach: write the smarts in Haskell. Shackling Haskell as a slave to C++ will probably end up frustrating you or making you feel as though you wasted your time. Use each language where its strengths lie.
Here is how I see things:
Functional languages excel at transforming things. Whenever you write programs which take an input and map/filter/reduce it, use functional constructs. Wonderful real world examples where Haskell should excel are given by web applications (you basically transform things stored in a database to web pages).
Procedural languages (OOP languages are procedural) excel at side effects and communication between objects. They are cumbersome to use to transform data, but whenever you want to do system programming or (bidirectional) interaction with humans (user interfaces of any kind, including client-side web programming), they do the job cleanly.
However, some may argue that user interfaces should have a functional description, I answer that well established frameworks are easy enough to use with OOP languages that one should use them this way. After all, it is natural to think of UI components in terms of objects and communication between objects.
IO is only a tool: whenever you transform input to output, Haskell (or whatever FP language) should do the IO. Whenever you speak to a human, C++ (or whatever OOP language) should do the IO.
Don't care about speed. When you use Haskell for the right job, it's efficient. When you use C++ or Python for the right job, it's efficient.
Therefore, let's say I'm fluent in Haskell, C, C++ and Python, here's how I write applications:
If my application's main role is to transform data, I write it in Haskell, with possibly some low-level parts written in C (which may, in turn, call some high-tech low level parts written in C++, but I'd stick with C as an interface for portability reasons).
If my application's main role is to interact with a user, I write it in Python (PyQt for instance), and let Python call performance-critical routines written in C++ (boost::python is pretty good as a binding generator). I may also have to call subroutines which transform or fetch data, which will be written in Haskell.
If I have to write a part of an application in Haskell, I segregate it into a C-callable API.
Sometimes, a Haskell application which reads things on stdin and write back on stdout is useful as a submodule (that you call with fork/exec, or whatever on your platform). Sometimes, a shell script is the right wrapper for such applications.
This answer is more a story than a comprehensive answer, but I used a mix of Haskell, Python and C++ for my dissertation in computational linguistics, as well as several C and Java tools that I didn't write. I found it simplest to run everything as a separate process, using Python as glue code to start the Haskell, C++ and Java programs.
The C++ was a fairly simple, tight loop that counted feature occurrences. Basically all it did was math and simple I/O. I actually controlled options by having the Python glue code write out a header full of #defines and recompiling. Kind of hacky, but it worked.
The Haskell was all the intermediate processing: taking the complex output from the various C and Java parsers that I used, filtering extraneous data, and transforming it the simple format the C++ code expected. Then I took the C++ output and transformed it into LaTeX markup (among other formats).
This is an area that you would expect Python to be strong, but I found that Haskell makes manipulation of complex structures easier; Python is probably better for simple line-to-line transformations, but I was slicing and dicing parse trees and I found that I forgot the input and output types when I wrote code in Python.
Since I was using Haskell a lot like a more-structured scripting language, I ended up writing a few file I/O utilities, but beyond that, the built in libraries for tree and list manipulation sufficed.
In summary, if you have a problem like mine, I would suggest C++ for the memory-constrained, speed-critical part, Haskell for the high-level transformations, and Python to run it all.
I have never mixed both languages but your approach feels a little upside down to me.
Haskell is more apt at high-level operations while C++ can be optimized and can be most beneficial for tight loops and other performance critical code.
One of the largest benefits of Haskell is the encapsulation of IO into monads. As long as this IO isn't time critical I don't see any reason to do it in C++.
For the GUI part you are probably right. There is a plethora of Haskell GUI libraries but C++ has powerful tools such as QtCreator which simplify the tedious tasks a lot.

Which could become a strong alternative JVM language: Scala, Clojure, Fan, JavaFX Script, or other?

I am currently deciding on an alternative JVM language to port an existing Swing desktop application written in Java 6. Given that JavaFX specifically targets this kind of application, it would seem that my best option is JavaFX Script.
However, what about other kinds of applications and libraries? Would JavaFX Script be the best choice in general for a second JVM language?
Currently, it seems that Scala is the most talked about alternative to the Java language. This month (October 2009), it is at position 34 in the TIOBE index, while JavaFX Script is at position 44, and Clojure, Fan, and Groovy are at positions below 50.
So, what are your impressions? Which language would you invest your time in learning and using (and why), assuming you can freely choose the language for a given project to run in the JVM?
My main question would be: why are you porting an existing application? The answer to this question may give you some idea of where you want to go.
Some quick perspectives on the main choices:
Scala is in my view, a better Java than Java. If you want a language that takes the best bits of Java buts adds a lot of new innovations and features, then it may well be for you.
Clojure is an amazingly well designed language, particularly if you believe in a future of highly complex, concurrent applications. It's also extremely productive - I can probably create more value/hour in Clojure than any other language. However, unless you already know Lisp it will seem very unfamiliar at first. If you are willing to live on the cutting edge to get these benefits, Clojure may well be for you.
JavaFX script - has some very nice features for GUI design, and clearly has support of Sun/Oracle. On the other hand, I don't see it having massive traction outside this domain. I'd suggest giving it a trail run to see if it meets you needs.
Java - should still be on your list! If the reason you are porting is because the code has become difficult to maintain, then maybe a focused phase of re-factoring while staying on Java can get you the benefits you want. It's possible to write perfectly good GUI applications in Java.
Groovy - really nice scripting language on the JVM. Particularly good if you want to embed scripting features within an existing Java/JVM application. Not sure I'd choose it for (re)writing a complete application however.
JRuby / Jython - haven't seen these much myself but heard good things. Probably most suitable if you have Ruby / Python skills in the team but also want the benefits of the JVM platform.
The best alternate language, and the best language overall, IMO, is that which best allows you to write the program in the best model for you.
So, if you are writing a GUI app, then Scala may be the incorrect choice, as you wouldn't be moving away from Swing.
If JavaFX best meets your needs, then use that language.
If you know LISP then Clojure would be a good choice, but, like Scala, not for this problem, it sounds like.
If you don't know lisp and you want/need a functional programming language, then Scala would be the best choice.
Basically, there is no one language that is best in all situations, it helps to know what you want to do, and the strengths/weaknesses of the various options.
Those all sound like good choices. You could add JRuby to the list...

Absolute beginning in programming [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have worked for the last 10 years in Networking & Web Development and always had an interest in programming. When I was in School I started in Basic, (To date myself) the other languages at that time were Cobol & Fortran, Where should I start in 2009? is C+ or C++ a good place? Is it better to Start Java or .net? I'm in need of some direction from Coders, Programmers, developers who can point me in the right direction. The technology changes in the blink of an eye, I'd like a good starting point to begin learning & understanding relevant code.
I think your best bet is to learn Python because
It is simple and easy language to learn
Python is capable of doing what any other main stream language can do
Python is also a very good choice for web development, with good frameworks like Django, Pylons, Turbogears etc
Google uses Python and using google appengine you could be able to quickly write web applications.
Python is also great for cross-platform desktop applications using wxPython, PyQT, Tkinter,gtk etc
Python has very rich set of libraries and frameworks e.g. PIL for imaging, numpy for computing, twisted for networking etc etc etc
Python has implementation in Java and .NET so you can program for those platforms in Python
I agree with most of the posts on here but I would like to add my own slant on this. Learning a programming language should change the way you think about programming and allow you to make useful programs. The list below is a mix of easy to learn (the basics) and helps you think about programming problems
Python it makes programming fun and easy. You will learn a lot about programming and make some cool programs in a relatively small amount of code. Will help you think about programs at a higher level than C which is a good thing.
C it's the basis of a massive number of languages and will teach you a good deal of stuff that is now considered low level. Stuff that will be useful for any programmer to know.
Haskell its a functional language which will have you thinking about programming from a different perspective. It is very useful to know this stuff - can help reduce many bugs.
I would start by gaining a basic knowledge. i.e. be able to make a text based Connect 4 game in each of these three languages (in order). Which books help you do that is largely personal preference.
Programming is not only about the code and the language. It's about everything you do at the computer read The Pragmatic Programmer and Code Complete 2. Extra points for SICP and Hacker's Delight
From there if you want to know more about how programming languages work by writing a interpreter for Scheme (by reading SICP again) And/or look at FORTH. Or learn more about how to program by writing more and more programs. Once you get basic knowledge write, then re-write as many different computer programs as you can.
It all depends on your focus.
If you're looking at getting into straight development, I would recommend C#, Java or C++. (C++ is a learning curve though, and would be great to "learn", whereas C# and Java will get you started a lot quicker in doing "cool" things)
If you're looking at Web Development, look into PHP (as it's free to setup and run with) or ASP.NET (which will link to platform at a point, as you use C# or VB.NET syntax).
If you're looking at something different, have a look at ERLANG or Prolog, or those types, however I don't recommend it for a start, as it's not AS quick to get results that you might be looking for.
You'll get a dozen different people all pushing you to learn their favourite language.
When it comes down to it though it doesn't make a lot of difference. As long as you pick something that is modern and object oriented you should be fine.
Assuming you are talking about programming and not web development, any of the following would be a perfectly acceptable first language:
C#
Java
Python
C++
Ruby
VB.net (not VB6)
There are advantages and disadvantages to each; there probably aren't as many jobs in Python and Ruby, C++ is harder for a beginner, but it's stuff you need to know eventually, C#/Java hide you from that hard stuff to begin with, but like I said you'll need to learn it eventually. VB.net is derived from BASIC syntax so you might feel at home to begin with, but a lot of programmers prefer C style syntax.
If you have a specific focus in mind, then that might dictate some choices over others, but if you are just out to learn programming, then any will do. If you are ever planning on being a good programmer you will naturally learn several.
Well, technically, technology doesn't change in the blink of an eye. For instance:
Lisp: Came out in 1958. It's always had a cult following in various fields, but it's becoming more hip now with the clojure variant.
C: Came out in 1972. Obviously influences C++, Java, JavaScript (as does lisp), and still has a strong following.
Smalltalk: Came out in the 70's. Now it's hip via the ruby language.
I'm not suggesting you learn these, just that if you had learned them in the past, you'd still have relevant skills. Many of the modern languages actually take aspects from past languages. JavaScript, for instance, is a scripting language with object oriented aspects (Smalltalk, C++), functional aspects (lisp), and the syntax of C.
Learn what you're interested in, and find out what will help you accomplish your goals . But learn one and you can learn many.
The question is what you want to achieve in learning a programming language.
Do you want to get used to the basics? Then you might want to try a scripting language like Ruby or PHP. I would recommend Ruby as it's really easy to learn and advance (e.g. with IRB).
Want to write "fat" (desktop) applications? Then you should stick to C++, Java or C#.
For web applications you should use Ruby on Rails, Django (Python) or a similar web framework for the language of your choice. So you should already know a bit of the language.
C
Because it's not difficult to learn. TO LEARN, not to do "cool things".
Because is the languague that any good programmer SHOULD KNOW at least if he wants to know what's happening in the machine.
When you've learned C, then you should go to OOP: I would recommend C++ or Java, but there are a lot of OPP languages (C#, .Net), so you can choose.
Java, C++ may change a lot, but not C. So, first learn C.
Furthermore, if you want to do some Web Development, the step C -> PHP is trivial, really.
PD: C is not my favourite language, but I know that if you learn C, you will be able to learn any language you want in very few time.
Nobody can really tell you which language you should learn. Just try a few of them and then decide for yourself. Just take the one that you like the most.
Of course I wouldn't start learning a language that's already "dead", but every modern language is good for something. What you should actually do is to decide in which area of programming you want to code - so, for example, would you like to develop desktop or web applications, should the program run on any platform or are you fine with just windows or just linux or whatever. When you have decided on that, take a look at the languages that are commonly used for the area you choose and try all/many of them. Then take the language you like the most.
Read and do the assignments in The C Programming Language before anything else. It will really help you get a solid grip on fundamentals and some of the trickier issues like memory management. Then go on to OOP whether it be Java, .NET, C++ or Python.
If you start in C you'll have a tougher time starting out but will learn a lot more by the time you understand the language as compared to starting with another language. C won't teach you Object-Oriented Programming though, so after C it would be easy to move to C++ and learn the differences and then about Objects. A good book to learn C from is The C Programming Language.
Or you could go a route where you start off easier so things aren't so frustrating to start, learn a bit less, and then slowly pick up more and more about programming. You could start with Python and understand the basics of programming very quickly, and then start expanding what you know by learning other languages.
I personally started with C++, which then made a lot of other higher level languages, like Python, super easy to learn. If you want to start out learning more of the basics of programming I would probably recommend C++ first as it is a bit easier than C, and then you can learn C afterwards and it will be a bit easier, and then it'll be super easy to pick up something like Python, Java, Ruby, etc.
I think choosing a language or technology is overrated, especially when you have to learn fundamental things like object orientation or algorithms. Try to focus on the basics first and especially try to use more than one language.
In order to understand the concepts you should at least learn a dynamic language (Ruby, Python, PHP) and a "traditional" one (I would recommend either Java or C#). Functional languages are all at rage now and provide a different view onto programming than the latter two approaches.
New technologies are always nice to know, but in the end a good set of fundamental knowledge will empower you to learn them faster than they disappear.
I would say there is a massive difference between a Programming language & a Programming Language + Framework(s), usually when people say Learn Language X they are probably thinking about the Framework(s).
So if you want to actually Learn to program, try to learn the language with as little framework 'baggage' as possible, perhaps C?
Once you have gained enough working knowledge of a programming language (eg variables, loops, conditions) then move onto more broader subjects like OOP, then start looking at functional style etc.
From personnel experience I would say try and learn as many programming languages as possible (it actually gets easier the more you learn) but you will never master them all, just have enough to get by.
You will then realise that the language is the easy part, the framework and related methodology is what your actually learning when going from one language to another.
Much as I love Delphi, I think I would suggest either Java or Python. Why? Assuming you are learning on your own, I think these languages have the clearest texts and web sites for learning on your own (esp. Java).
Seeing that you're coming from two different fields (networking and web development) you can either work your way top down or bottom up in terms of high- or low level languages. If you think you want to make use of your networking knowledge (which I assume is pretty close to hardware), you might want to start with something like C, maybe Unix network programming. If you want to build on your web developer skills, you might want to try something more high level. I think Python is a good suggestion, but also Java - maybe in combination with JSP. C# would be a good choice too in my eyes.
Don't forget about platform. Are you most interested in web, mobile, or desktop development? As for languages, there are a ton out there and you'll never be able to learn them all. So I think you should determine what your goal is and whether you plan to program for fun, profit, or both. But most important of all, be sure the journey is fun for you and that you're building stuff you love.
A good reason to learn Java - besides the fact it's currently the most popular language - is that the Java Trails tutorials are really good, and really far-reaching.
C# is very, very similar to Java in most regards; also interesting to learn, and it's gaining marketshare while Java slows down.
Other than those two, I'd also strongly consider Python, for being easy to learn and very, very useful personally and professionally.