Choosing a Programming Language

For discussing go computing, software announcements, etc.
averell
Dies in gote
Posts: 61
Joined: Tue May 04, 2010 7:14 am
GD Posts: 0
Has thanked: 57 times
Been thanked: 19 times

Re: Choosing a Programming Language

Post by averell »

I don't know what your main goal is, but if this is mainly to broaden horizons and further your education you should consider functional languages as well, like haskell or something like scheme. If you stick with programming you will never regret learning one of these.

Also, the project does indeed seem quite ambitious, maybe if you start with only an SGF parser you will be busy for a few weeks, and decide to switch languages based on your experience then :)

If you only want something to put into your CV, Java is still your best bet. Same goes if portability is an issue. The performance will not be an relevant with normal sized databases (<100k), or at least not due to language limitations.

Then again i mainly use C++ and it does have it's advantages, and for a go playing engine it would be my first choice.

If you do think you can stick with such a large project, i cannot recommend any scripting language such as Python, Ruby or Perl. These are the modern day Visual Basic in my opinion, good for small scale stuff and quick hacks, easy to learn and more lenient with some bad practices but unsuitable for any large application.
Mike Novack
Lives in sente
Posts: 1045
Joined: Mon Aug 09, 2010 9:36 am
GD Posts: 0
Been thanked: 182 times

Re: Choosing a Programming Language

Post by Mike Novack »

I agree that learning programming "functional" rather than "procedural" not necesarily a bad idea (the "functional" programmers usually know that they can prove equivalent but the "procedural" programmers usually haven't clue about the "functional" alternative)

But I disagree that this is necessarily a matter of choice of language. You can treat C as a functional language even though 99% of C programmers/programs use it procedurally. After I retired and began doing things like learning C and on a list where a language argument broke out I got challenged to rewrite one of my learning exercises as a pure function. Wasn't that hard. BTW -- you can ignore my use of C instead of C++. Just means I'm one of the old hands who would be writing the object defintions for a project. So I'd normally "roll my own". Hey, in the original C book the exercises were constructing your own definitions for the functions that came built in (the "standard library").

Programming languages is not the place to start. You need to learn how to design programs (algorithms or functions) irrespective of in what language they will be implemented. It's normal to learn this in the context of a particular language but that's only because you need some way to try out what you are learning. If at the end you only can conceive of doing it in that language (too concrete) then you haven't learned programming.

Don't try to run before you can walk. You will need to start out with simple problems.
User avatar
flOvermind
Lives with ko
Posts: 295
Joined: Wed Apr 21, 2010 3:19 am
Rank: EGF 4 kyu
GD Posts: 627
Location: Linz, Austria
Has thanked: 21 times
Been thanked: 43 times

Re: Choosing a Programming Language

Post by flOvermind »

nagano wrote:... but also be faster than something like Java ...


Java is faster. Seriously. If you want faster than Java, C/C++ is pretty much your only option, but only if you know how to exploit the performance advantages of C++. If not, Java is faster.
rubin427
Lives in gote
Posts: 338
Joined: Sat Dec 05, 2009 9:24 pm
GD Posts: 0
Location: Las Vegas, NV
Has thanked: 163 times
Been thanked: 62 times

Re: Choosing a Programming Language

Post by rubin427 »

fwiffo wrote:Since you don't have much programming experience, I suggest Python. It's a very good learning language, and fun to work with.

C++ has its place, but it is much more difficult.


I agree with fwiffo.

Even though I am typically a C++ zealot.

People get down on python because interpreted languages are "slow". I once wrote a serious project in python for work. The philosophy was we would rapid prototype in python, and when we finally hit the performance wall, we would re-implement key algorithms in c++ for speed. guess what? We never had performance issues. the final product shipped 100% python code.

Even though at the start of the project I was an experienced C++ programmer, but a first day beginner to python. I know for a fact that the total time to learn python AND complete the project was faster than if the team had done the project in C++ from the start.
User avatar
fwiffo
Gosei
Posts: 1435
Joined: Tue Apr 20, 2010 6:22 am
Rank: Out of practice
GD Posts: 1104
KGS: fwiffo
Location: California
Has thanked: 49 times
Been thanked: 168 times

Re: Choosing a Programming Language

Post by fwiffo »

People get down on python because interpreted languages are "slow". I once wrote a serious project in python for work. The philosophy was we would rapid prototype in python, and when we finally hit the performance wall, we would re-implement key algorithms in c++ for speed. guess what? We never had performance issues. the final product shipped 100% python code.

^^^ This

95% of the time if your project is running too slow it has nothing to do with your choice of programming language. It could be IO bound. It could be a badly designed algorithm. It could be computationally intractable. Premature optimization is usually a bad idea (you should get it working correctly, then optimize), and preemptive optimization through choice of language is particularly bad.

@nagano: Given that you don't have much programming or CS background, this might be a pretty ambitious project for a first programming project. Searching a database of go games efficiently is something I would describe as a Hard Problem. You might want to choose something simpler for a first project.
phrax
Dies with sente
Posts: 92
Joined: Wed Apr 21, 2010 10:24 am
GD Posts: 0
Has thanked: 48 times
Been thanked: 6 times

Re: Choosing a Programming Language

Post by phrax »

The choice is obvious, Go http://golang.org/ :)

If you're primarily focusing on Windows, C# is nice to work with. There is also limited portability using Mono for other platforms. Disclaimer: I have no Mono experience, so I don't know how well this actually works.

It might not be the best choice for this particular project, but I'd be remiss if I didn't at least mention Perl :) It already has decent sgf libraries, and is cross-platform.
User avatar
Harleqin
Lives in sente
Posts: 921
Joined: Sat Mar 06, 2010 10:31 am
Rank: German 2 dan
GD Posts: 0
Has thanked: 401 times
Been thanked: 164 times

Re: Choosing a Programming Language

Post by Harleqin »

I use Common Lisp for almost everything I program. If you want to go that route, which I recommend, you should read "Practical Common Lisp" by Peter Seibel.
A good system naturally covers all corner cases without further effort.
User avatar
daniel_the_smith
Gosei
Posts: 2116
Joined: Wed Apr 21, 2010 8:51 am
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
Location: Silicon Valley
Has thanked: 152 times
Been thanked: 330 times
Contact:

Re: Choosing a Programming Language

Post by daniel_the_smith »

I was going to advocate golang as it is easy to learn, compiled and statically typed, however you are on windows and want a gui, the two things golang does not do well yet. Otherwise I would recommend it. (I did my website backend in go, my website does some similar things to what you're talking about.)

I'll +1 python. C++ is great for what it's great for, and an ambitious first project ain't it. (I can say this, I do C++ for my day job.) Don't write something in C++ because you want it to be fast. Premature optimization is the root of all evil. You don't even know what will be slow until you write it, so write it in something easy to begin with. It's much easier to optimize correct code than it is to correct optimized code and all that.
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com
Bill Spight
Honinbo
Posts: 10905
Joined: Wed Apr 21, 2010 1:24 pm
Has thanked: 3651 times
Been thanked: 3373 times

Re: Choosing a Programming Language

Post by Bill Spight »

Forth language perfect, it is. Programmer excellent, I am.

-- Yoda

:)
The Adkins Principle:
At some point, doesn't thinking have to go on?
— Winona Adkins

Visualize whirled peas.

Everything with love. Stay safe.
Suji
Lives in gote
Posts: 302
Joined: Wed May 19, 2010 2:25 pm
Rank: DDK
GD Posts: 0
KGS: Sujisan 12 kyu
OGS: Sujisan 13 kyu
Has thanked: 70 times
Been thanked: 8 times

Re: Choosing a Programming Language

Post by Suji »

fwiffo wrote:Python isn't web based in the way that PHP or something is. There are web frameworks for it, of course.


Interesting.

nagano wrote:
schilds wrote:What platform are you targeting? I assume it'll have a GUI?

The latter 2 issues you listed (databases, networking) will have similar library support whichever language you choose as long as it's reasonably mainstream. I think platform and tools/libraries are the first things you need to consider.


I am mostly focused on windows, though I would like it to have as wide a compatibility as possible. Of course it will have a GUI! :shock: I'm aware that most languages can support those features, but I read that languages such as Java or Python are slower than C++ and not necessarily as good with data intensive applications. I don't know if its just because many of those applications haven't been coded well, but I've noticed Java applications tend to run slower than most other programs on my computer. I'm talking about very large databases here, think Chessbase (>1 million games). As for the libraries, I don't know enough about the differences to really say. I guess that's one of the areas I could use some help. Question: what was Chessbase written in?


I'd be willing to bet it's written in either C or C++.

nagano wrote:
Suji wrote:Nagano: You might want to consider PHP, too.

I want the program to be accessible offline. Is that possible with PHP?


Not stock, no. So PHP might not be the best choice. If at some point you want it to be web-based, PHP is really the way to go (or perl).

I'm personally not acquainted with Python so I can't vouch either for or against it, but from what I've seen it's pretty friendly. I've also had a bad experience with Java, so I'm biased against it. Java would be fine as a first language and it has it's uses. C++ isn't a bad choice either, but make sure that the tutorials you go through are really, really good. Also, whatever language you do it in, stick with code you understand and don't try anything fancy.

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
- Brian W. Kernighan
My plan to become an SDK is here.
User avatar
fwiffo
Gosei
Posts: 1435
Joined: Tue Apr 20, 2010 6:22 am
Rank: Out of practice
GD Posts: 1104
KGS: fwiffo
Location: California
Has thanked: 49 times
Been thanked: 168 times

Re: Choosing a Programming Language

Post by fwiffo »

I have an anecdote relating to this subject...

At a previous job, I was involved in maintaining a big inventory management, CRM, order processing thing. It was mostly written in PHP with a web interface, with a PostgreSQL back-end, and also interacted with some legacy AS/400 systems. It was pretty terrible, but typical for the kind of code you see in the wild, written by incompetent programmers for an ossified, disorganized company.

There were certain reports generated by the system that would sometimes take hours to complete. Some very clever programmer in the distant past thought to themselves "Ah, well, this is written in PHP, and everyone knows C is much faster, so I'll rewrite this part in C and bolt it on." Sadly it didn't get any faster at all, and we were all left with some really crappy C code to maintain in addition to everything else.

The problem wasn't the choice of language. The problem was that the programmers didn't understand SQL at all, and SQL joins and subqueries specifically, and didn't know how to design a database schema that makes any kind of sense. Instead of using joins, they issued thousands of queries inside nested loops. It was something like:

Code: Select all

query list of customers
for each customer {
    query list of orders
    for each order {
        query list of parts in order
        for each part {
            query part information
            if order was in the last week and customer is a distributor {
                total_distributor_sales += whatever
            }
        }
    }
}

Once we rewrote it to just issue one query with joins, it took like 100ms to run instead of an hour, with 1/5 the number of lines of code.
User avatar
nagano
Lives in gote
Posts: 448
Joined: Wed Apr 28, 2010 6:44 pm
Rank: Tygem 4d
GD Posts: 24
Has thanked: 127 times
Been thanked: 34 times

Re: Choosing a Programming Language

Post by nagano »

Thanks, everyone. Not sure I've made a decision yet, but you've definitely given me some thing to think about.
"Those who calculate greatly will win; those who calculate only a little will lose, but what of those who don't make any calculations at all!? This is why everything must be calculated, in order to foresee victory and defeat."-The Art of War
User avatar
daniel_the_smith
Gosei
Posts: 2116
Joined: Wed Apr 21, 2010 8:51 am
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
Location: Silicon Valley
Has thanked: 152 times
Been thanked: 330 times
Contact:

Re: Choosing a Programming Language

Post by daniel_the_smith »

fwiffo wrote:I have an anecdote relating to this subject...


I'm surprised that anyone smart enough to figure out how to connect to a database could do that so incredibly badly... have you posted that to daily wtf?
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com
amnal
Lives in gote
Posts: 589
Joined: Fri Apr 23, 2010 10:42 am
Rank: 2 dan
GD Posts: 0
Been thanked: 114 times

Re: Choosing a Programming Language

Post by amnal »

nagano wrote:Thanks, everyone. Not sure I've made a decision yet, but you've definitely given me some thing to think about.


If you haven't programmed before (which it sounds like you haven't), your time will be better spent downloading a language - any language - and getting going! You simply can't embark properly upon a large project as soon as you set out; even if you manage to focus on it, the early work will almost certainly be terrible and you'll have to rewrite it anyway. The most important thing is to get a general idea of what's going on, then you can choose a language whilst properly understanding why you're making the choice.

FWIW, I recommend getting started with python. If you can't learn how python works and then transfer this knowledge easily to C or whatever, you wouldn't have managed to learn C in the first place anyway.
User avatar
fwiffo
Gosei
Posts: 1435
Joined: Tue Apr 20, 2010 6:22 am
Rank: Out of practice
GD Posts: 1104
KGS: fwiffo
Location: California
Has thanked: 49 times
Been thanked: 168 times

Re: Choosing a Programming Language

Post by fwiffo »

daniel_the_smith wrote:I'm surprised that anyone smart enough to figure out how to connect to a database could do that so incredibly badly... have you posted that to daily wtf?

I would submit it to daily WTF if I still had a copy of the code.

The biggest problem is that it was something developed over a period of time, by multiple different people, with limited experience in a place with high turnover. It had all the horrors you'd expect in a system without any kind of version control too. A typical chunk of the directory structure might look something like

Code: Select all

potemplate6.php
potemplate6a.php
potemplate7.php
potemplate8.php
potemplate8-delme.php
potemplate8-new.php
potemplate8-version2.php
potemplate8-version2new.php
potemplate8-version2real.php
potemplate8-version2real-2004-02-01.php
potemplate8-version2real-2004-02-01_SPECIAL.php
potemplate8-version2real-2004-04-09XXBUGGEDXX.php
potemplate8-version2real-2004-04-09XXBUGGEDXX-fixed.php
potemplate8-version2real-2004-04-09XXBUGGEDXX-fixed-dontuse.php
potemplate9.php
potemplate9-2001-11-14.php


Other files in use pointed to different versions and it was all just horrible. Not to mention, copious use of the worst two variable names in the world and similar face-palm moments.
Post Reply