|
You last visited: Today at 15:42
Advertisement
Programming Languages Discussion
Discussion on Programming Languages Discussion within the CO2 Private Server forum part of the Conquer Online 2 category.
01/14/2016, 02:47
|
#1
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,191
|
Programming Languages Discussion
Hello,
I recently made a comment on  , and noticed that a lot of people had a problem with my opinion on C++. Since a few people mentioned they'd be interested in a separate discussion on programming languages and Conquer Online, here you are. Feel free to discuss, if need be.
Have fun,
Spirited
|
|
|
01/14/2016, 09:47
|
#2
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Wouldn't this have been more fitting in CO2 Programming? Or generally not even here?
|
|
|
01/14/2016, 10:30
|
#3
|
elite*gold: 0
Join Date: Feb 2014
Posts: 397
Received Thanks: 205
|
I believe the best and most efficient way to program a server is in html.
|
|
|
01/14/2016, 12:34
|
#4
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Quote:
Originally Posted by InsomniacPro
I believe the best and most efficient way to program a server is in html.
|
I heard the version 2 called .ini is way better!
|
|
|
01/14/2016, 14:03
|
#5
|
elite*gold: 0
Join Date: Sep 2010
Posts: 291
Received Thanks: 95
|
Programming Languages Discussion
I'm very interested in functional programming and have tried out languages like Scala, F#, and Erlang. Recently I've been playing around with Elixir (built on the Erlang vm). Really liking the language so I Might try implementing a server in it soon.
|
|
|
01/14/2016, 17:34
|
#6
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,191
|
Quote:
Originally Posted by tkblackbelt
I'm very interested in functional programming and have tried out languages like Scala, F#, and Erlang. Recently I've been playing around with Elixir (built on the Erlang vm). Really liking the language so I Might try implementing a server in it soon.
|
I also tried other functional programming languages such as Haskell and F#. I found that they were too radically different from what I was working with, and that they had different purposes than what I wanted to accomplish. I like C because most of what I was doing already related to C (in my C++ project, at least), and it has decades of support behind it.
Just in general, programming in a functional language has shown me just how unnecessary my implementations were. Like, I had five classes for constructing MySQL statements which inherit from an abstract command class with the interface for implementing a SQL statement class. I replaced those with a string table that I can insert into sscanf functions. That way I can very quickly just define a new type of statement or define my own.
So yeah, I'm getting some benefit from the change of thinking. It definitely requires a completely different thought process, which I've really enjoyed so far. It takes practice before driving straight in though, or that's what I found. I started by creating my own compiler for a very simple programming language called C1. That helped me put together my style for programming in C. I'd like to know more about Elixir, since you mentioned it runs on a VM. Is that similar to JVM in Java, or does it run bear metal?
Quote:
Originally Posted by Super Aids
I heard the version 2 called .ini is way better!
|
Everyone knows that XML is the future of programming. I mean, who wouldn't want the possibility of an infinitely complex configuration file with the worst syntax and amount unnecessary padding imaginable? Get with the times, grandpa. (Edit: Just realized that I shit on XML as well. I wonder how many markup junkies that'll upset, lol).
|
|
|
01/14/2016, 17:37
|
#7
|
elite*gold: 17
Join Date: Sep 2015
Posts: 2,487
Received Thanks: 1,032
|
Did anybody tried AAL? it's seems like AutoIT but better
|
|
|
01/15/2016, 03:56
|
#8
|
elite*gold: 0
Join Date: Sep 2010
Posts: 291
Received Thanks: 95
|
Quote:
Originally Posted by Spirited
I also tried other functional programming languages such as Haskell and F#. I found that they were too radically different from what I was working with, and that they had different purposes than what I wanted to accomplish. I like C because most of what I was doing already related to C (in my C++ project, at least), and it has decades of support behind it.
Just in general, programming in a functional language has shown me just how unnecessary my implementations were. Like, I had five classes for constructing MySQL statements which inherit from an abstract command class with the interface for implementing a SQL statement class. I replaced those with a string table that I can insert into sscanf functions. That way I can very quickly just define a new type of statement or define my own.
So yeah, I'm getting some benefit from the change of thinking. It definitely requires a completely different thought process, which I've really enjoyed so far. It takes practice before driving straight in though, or that's what I found. I started by creating my own compiler for a very simple programming language called C1. That helped me put together my style for programming in C. I'd like to know more about Elixir, since you mentioned it runs on a VM. Is that similar to JVM in Java, or does it run bear metal?
Everyone knows that XML is the future of programming. I mean, who wouldn't want the possibility of an infinitely complex configuration file with the worst syntax and amount unnecessary padding imaginable? Get with the times, grandpa. (Edit: Just realized that I shit on XML as well. I wonder how many markup junkies that'll upset, lol).
|
So Elixir is running on the Erlang VM. Erlang is a programming language & VM built way back in the 1980's. The purpose of the platform was to run on massively parallel telecom systems. The whole platform is designed to be extremely fault tolerant, concurrent, and high availability.
Code is compiled down to beam byte code (similar to the JVM). When running code, you spin off processes. These processes are very tiny and communicate with each other by passing messages (Actor Model). On a standard laptop you could potentially spin up millions of processes that take advantage of all cores on your machine. WhatsApp uses Erlang to handle millions of connections per server.
For example, if you run the below function it will spin off 100,000 Erlang processes to map all 100K elements by applying a function. If you had a 100,000 core computer (I wish  ), this would run all in parallel.
Code:
Parallel.pmap 1..100_000, &(&1 * &1)”
Code:
defmodule Parallel do
* def pmap(collection, func) do
* collection
* |> Enum.map(&(Task.async(fn -> func.(&1) end)))
* |> Enum.map(&Task.await/1)
* end
* end”
Erlang also follows the pattern of "let it fail". Essentially you create supervisor processes that monitor child processes. If a child process dies, the supervisor can restart it. Erlang encourages you not to code defensively.
One use of this for a conquer server could be a mob supervisor. The mob supervisor will spin off mob processes and when a player kills the mob, the process dies and then the supervisor spawn up a new one to takes it place.
The platform also allows you to create distributed environment very easily. Basically you ping two nodes together and then you can spawn processes, send messages, etc between severs!.
Now as for Elixir... Elixir is a fairly new language (version 1.2) that is built on top of the same VM, gives you all the features of Erlang/OTP, has more features, and gives you a much more modern syntax (Some people describe it similiar to Ruby).
Anyways, whenever I learn a new language I usually try to implement a conquer server in it as it forces me to use almost every aspect of a language. Last year, when I was learning Scala I built a CO 1.0 server in it for testing. Source code is available below if anyone is interested. I will be attempting a server in Elixir once I'm fairly comfortable with the language  .


|
|
|
01/15/2016, 05:41
|
#9
|
elite*gold: 0
Join Date: Feb 2014
Posts: 156
Received Thanks: 81
|
Quote:
Originally Posted by tkblackbelt
|
This is a pretty interesting, even more astounding read.
|
|
|
01/15/2016, 09:14
|
#10
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Quote:
Originally Posted by Spirited
Just in general, programming in a functional language has shown me just how unnecessary my implementations were. Like, I had five classes for constructing MySQL statements which inherit from an abstract command class with the interface for implementing a SQL statement class. I replaced those with a string table that I can insert into sscanf functions. That way I can very quickly just define a new type of statement or define my own.
|
Who even writes sql queries in code anymore?
|
|
|
01/15/2016, 10:25
|
#11
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,283
Received Thanks: 4,191
|
Quote:
Originally Posted by Super Aids
Who even writes sql queries in code anymore?
|
Object-relational mappers seem to have a thing against non-object oriented languages. That, and I'm just not sure how comfortable I am using an object relational mapper for a high performance server. Caching and optimizations are already done on the MySQL server, so I guess the only reason you'd implement an ORM is to manage complexity. "sscanf" and string tables are simple enough and do the job. It also gives me a reason not to use a bloated parsing engine from an ORM when I can just use C's parsing functions (which those engines eventually call anyways). It also means no map files like the ones I keep seeing in XML. So yeah, I guess that's my reasoning.
|
|
|
01/15/2016, 11:29
|
#12
|
elite*gold: 0
Join Date: Feb 2014
Posts: 397
Received Thanks: 205
|
Quote:
Originally Posted by Super Aids
Who even writes sql queries in code anymore?
|
Sql queries in code are so old they belong in the Lands of The Forgotten......
|
|
|
01/15/2016, 13:06
|
#13
|
elite*gold: 0
Join Date: Dec 2012
Posts: 1,761
Received Thanks: 950
|
Quote:
Originally Posted by Spirited
Object-relational mappers seem to have a thing against non-object oriented languages. That, and I'm just not sure how comfortable I am using an object relational mapper for a high performance server. Caching and optimizations are already done on the MySQL server, so I guess the only reason you'd implement an ORM is to manage complexity. "sscanf" and string tables are simple enough and do the job. It also gives me a reason not to use a bloated parsing engine from an ORM when I can just use C's parsing functions (which those engines eventually call anyways). It also means no map files like the ones I keep seeing in XML. So yeah, I guess that's my reasoning.
|
You can do ORM's without XML or whatever. I wrote my own ORM for my source, that just looks up types in your projects and compiles your queries based on that.
Ex. for my accounts table.
Code:
// Project by Bauss
using System;
using System.Linq;
using Candy;
namespace CandyConquer.Database.Models
{
/// <summary>
/// Database model for the 'Accounts' table.
/// </summary>
[DataEntry(Name = "Accounts", EntryPoint = ConnectionStrings.Auth)]
public sealed class DbAccount : SqlModel<DbAccount>
{
/// <summary>
/// Ban range type.
/// </summary>
public enum BanRangeType
{
OneDay,
ThreeDays,
OneWeek,
OneMonth,
ThreeMonths,
SixMonths,
OneYear,
Perm
}
[DataIgnore(IgnoreType = DataIgnoreType.Write)]
[DataSpecialType(DataType = SpecialDataType.Id)]
public int Id { get; set; }
public string Name { get; set; }
public string Password { get; set; }
public string Email { get; set; }
public string SecondaryEmail { get; set; }
public string SecurityQuestion { get; set; }
public string SecurityAnswer { get; set; }
public string RegistrationIP { get; set; }
public string LastIP { get; set; }
public string FirstLoginIP { get; set; }
public string RegistrationIPRegion { get; set; }
public string FirstLoginIPRegion { get; set; }
public string LastLoginIPRegion { get; set; }
public string Country { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public byte? Age { get; set; }
public string LastAuthKey { get; set; }
public string LastServer { get; set; }
public bool Banned { get; set; }
public string BanDescription { get; set; }
public DateTime? BanDate { get; set; }
[DataSpecialType(DataType = SpecialDataType.AsString)]
[DataReadFormat(ReadFormat = "EnumExtensions.ToEnum<DbAccount.BanRangeType>(@value as string)",
AssociatedNamespaces = new string[]
{
"CandyConquer.Drivers",
"CandyConquer.Database.Models"
})]
public BanRangeType BanRange { get; set; }
public DateTime? RegistrationDate { get; set; }
public DateTime? FirstLoginDate { get; set; }
public DateTime? LastLoginDate { get; set; }
}
}
It provides me flexibility and the ability to do instant updates.
Ex. for player's money.
Code:
/// <summary>
/// Gets or sets the money.
/// </summary>
public uint Money
{
get { return DbPlayer.Money.Value; }
set
{
value = Math.Min(Data.Constants.GameMode.MaxMoney, value);
DbPlayer.Money = value;
DbPlayer.Update();
UpdateClient(Enums.UpdateClientType.Money, DbPlayer.Money.Value);
}
}
This way I don't have to worry about my queries and what data I read/write. All I have to worry about is keeping my database model the same as the table in the database.
|
|
|
01/15/2016, 17:42
|
#14
|
elite*gold: 0
Join Date: Jul 2014
Posts: 402
Received Thanks: 540
|
Quote:
Originally Posted by Spirited
Object-relational mappers seem to have a thing against non-object oriented languages.
|
Uhm ... it's called OBJECT-relational mapping for a reason (it's obviously meant for object-oriented languages).
Quote:
Originally Posted by Spirited
That, and I'm just not sure how comfortable I am using an object relational mapper for a high performance server. Caching and optimizations are already done on the MySQL server, so I guess the only reason you'd implement an ORM is to manage complexity.
|
There's a HUGE difference between caching on the client and caching on the database server, though.
|
|
|
01/15/2016, 17:48
|
#15
|
elite*gold: 0
Join Date: Jul 2006
Posts: 2,216
Received Thanks: 794
|
I have not seen XML object mapping for a very very long time, who on earth even does that?
|
|
|
 |
|
Similar Threads
|
Programming Languages
01/08/2012 - DarkOrbit - 31 Replies
Hello all, I want to learn how to program. I am 14, and I have a great passion towards programming. I want to know what scripting language to learn, not only for hacking but Also other helpful programs? Thnx
|
Question About Programming Languages
11/09/2011 - CO2 Programming - 24 Replies
Hello EveryBody First Thanks To EveryBody Who Answer My Questions Before And Very Special Thanks To Mr.pro4ever
And My Question Is:
When Someone Create A Program How He Create The Complex Codes?
I Mean When I Learn A Programming Language And I Need To Make A Program With
That Language How Can I Make It Complex Program Or All I Want To Say
|
Another question about programming languages
09/14/2011 - CO2 Programming - 8 Replies
So I'm probably well-known for asking questions about programming, especially about what it takes to make a server. Well I guess this is another question but in a way it's a different question.
PHP:
Ability to make classes
Ability to make functions
Database Connections are made easy
I have taken an extreme liking to PHP
|
All times are GMT +1. The time now is 15:42.
|
|