Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » The Go Programming Language (by Google)

This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
The Go Programming Language (by Google)
Samuel Henderson
Member #3,757
August 2003
avatar

Project's main page

From what I understand they are trying to combine the speed of development of a dynamic language with the performance and security of a compiled language.

So... I wonder how long before Allegro gets ported to Go? ;D

=================================================
Paul whoknows: Why is this thread still open?
Onewing: Because it is a pthread: a thread for me to pee on.

axilmar
Member #1,204
April 2001

Go is not a dynamic language. It is a statically and strongly typed language. The dynamic part is explicitly programmed by the programmer by using interface casts like in Java.

Personally, I don't understand what's the fuss.

Slashdot says "Parallelism is emphasized in Go's design. The language introduces the concept of 'goroutines' which are executed concurrently", but if you look at the documentation, goroutines are nothing more than threads and channels are nothing more than synchronized data queues...big deal. I can do a synchronized queue in C++ with very little effort. Example:

#SelectExpand
1#include <pthread.h> 2#include <deque> 3 4template <class T> class Queue { 5public: 6 Queue() { 7 pthread_mutex_create(&m_mutex); 8 pthread_sem_create(&m_semaphore, 0, 0); 9 } 10 11 ~Queue() { 12 pthread_mutex_destroy(&m_mutex); 13 pthread_sem_destroy(&m_semaphore); 14 } 15 16 T get() { 17 sem_wait(&m_semaphore); 18 pthread_mutex_lock(&m_mutex); 19 T result = m_data.front(); 20 m_data.pop_front(); 21 pthread_mutex_unlock(&m_mutex); 22 return result; 23 } 24 25 void put(T item) { 26 pthread_mutex_lock(&m_mutex); 27 m_data.push_back(item); 28 pthread_mutex_unlock(&m_mutex); 29 sem_post(); 30 } 31 32private: 33 sem_t m_semaphore; 34 pthread_mutex_t m_mutex; 35 std::deque<T> m_data; 36};

The interface decoupling from the class is a nice feature, but I can do with with C++ as well, with very little coding, using duck typing. For example:

#SelectExpand
1class IBuffer { 2public: 3 virtual void read() = 0; 4 virtual void write() = 0; 5}; 6 7template <class T> class Buffer : public IBuffer { 8public: 9 Buffer(T *object) : m_object(object) { 10 } 11 12 void read() { 13 m_object->read(); 14 } 15 16 void write() { 17 m_object->write(); 18 } 19 20private: 21 T *m_object; 22};

What else is there? nothing much, really.

Go does not have templates, so writing any compile-time safe reusable code that has minimal performance is not possible.

Samuel Henderson
Member #3,757
August 2003
avatar

... they are trying to combine the speed of development of a dynamic language with the performance...

I didn't say they were actually making a dynamic language ... but rather a language that feels like one.

I still think it will be interesting to see how much momentum this gains...

=================================================
Paul whoknows: Why is this thread still open?
Onewing: Because it is a pthread: a thread for me to pee on.

SiegeLord
Member #7,827
October 2006
avatar

Go looks like a crippled version of D with bizarre syntax. In fact, it looks like D from like 5 years ago (D started out with no templates too) with bizarre syntax.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

bamccaig
Member #7,536
July 2006
avatar

It sounds interesting to me. I'd like to see it take off. Hopefully the language improves and the toolchain stabilizes. I'm anxious to try it, but don't have access to a Linux system right now[1]... :(

** EDIT

Quote:

package main

I've already got two problems with the language. Number one, it's using packages, instead of namespaces. I find namespaces, as implemented in C# (and I guess .NET) work a lot better than packages.

namespace identifier
{
    // code.

    namespace identifier
    {
        // code.
    }

    // code.
}

The structuring is obvious in the code. It's hierarchical. Also, the package declaration should have to end in a semi-colon (;). >:(

** EDIT **

Now that I've seen the first two example programs in the tutorial, I don't really care for the syntax of the language. It seems too disorganized and loose. Semi-colons are optional, variable types are declared after the name, etc. Not my dream language. I might use it if it becomes stable enough, but I don't see it becoming my favorite language.

References

  1. Stupid FSCKING 1and1's Linux images have crippled software repositories and I've been unsuccessful in switching to official repositories...
Billybob
Member #3,136
January 2003

Parentheses around if statements are optional, but curly brackets for the block are required. Personally, I've never had grief with the parentheses, but being forced to use curly brackets bloats the code.

Based on that, I am going to assume the designer is making another Java-like language. By that I mean a language which arbitrarily restricts the code for "best practices". We are supposed to be giving more control to programmers, not less. Java was a step backwards from C++ in my mind, even with all of its modern features. Think of those cars that steer themselves during an accident. Imagine if they didn't have the override feature. Do you really want to trust your life to a computer? In this case, I'm fine with trusting the compiler for most things, but I want an override.

C# is much more the language I prefer. It has the feature describe in the OP; being dynamic yet compiled. It's loaded with features, a nice set of standard libraries, and best of all provides that all essential override in case of accident. It is a shame C# is VM based. It sure does run fast, and pretty much every Windows system has .NET on it by now (and Linux has Mono). Still, I consider that a major flaw.

Kibiz0r
Member #6,203
September 2005
avatar

At first, I was repulsed. But after taking another look at it, there are a lot of things that I like about it.

I like that channels are first-class citizens. I tried out Microsoft's Axum for that very reason.

I also like the dynamic feel. It seems like the dynamism you get from template metaprogramming in C++ but without the brittle megastructure required to get it going.

The thing I am most happy to see is that interfaces are looser than most static languages. Managing that boilerplate stuff has always seemed like a painful waste of time to me, and it's only useful as long as everything plays nice.

It's an interesting language, and definitely Google-esque. You can really see the influence of languages like Newsqueak, Java, and JavaScript.

Peter Wang
Member #23
April 2000

The involvement of Rob Pike and Ken Thompson alone makes it worth a longer glance than most new languages. I only looked briefly yesterday, but it could be quite nice for a certain niche.

axilmar said:

goroutines are nothing more than threads and channels are nothing more than synchronized data queues...big deal

Actually, goroutines are green threads, so you can have a lot more of them before running out of memory, as compared to OS threads. Which is of course not new, but is a feature which works best when its natively supported by the compiler/runtime rather than hacked on. Further, programming languages are not about who came up with what feature first, but how the features combine (or not combine).

Martin Kalbfuß
Member #9,131
October 2007
avatar

Billybob said:

By that I mean a language which arbitrarily restricts the code for "best practices". We are supposed to be giving more control to programmers, not less. Java was a step backwards from C++ in my mind, even with all of its modern features

You should try Common Lisp. As I know, you can customize nearly everything to your needs. Or Assembler :P Maximum control.

But if it's best practise, why not use it? No one produces perfect code. Especially when the project is getting bigger. A good amount of rules helps.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Billybob
Member #3,136
January 2003

But if it's best practise, why not use it?

Because:

Quote:

No one produces perfect code.

Do you trust the car makers to have a perfect piloting system? Even if they did, why not have the override option?

I guess what it all comes down to is freedom; the freedom to choose my own best practices rather than follow blindly the ideas of another.

Quote:

A good amount of rules helps.

I totally agree, but the people writing the code should choose the rules, not some skanky compiler. I will reference C# again as a fair example. The compiler generally does not enforce best practices with errors. The C# language specification, however, comes with a list of best practices, including how to space code. Visual Studio will automatically do the specified code spacing, but I can override it any time I wish.

Perhaps it would be nice if compilers could be loaded with sets of custom rules, instead of having a fixed set.

Martin Kalbfuß
Member #9,131
October 2007
avatar

The ada gnat compiler has such a tool.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Tobias Dammers
Member #2,604
August 2002
avatar

Billybob said:

It is a shame C# is VM based. It sure does run fast, and pretty much every Windows system has .NET on it by now (and Linux has Mono). Still, I consider that a major flaw.

It does impact performance, but there are HUGE advantages to such a model; to name a few:
- Proper reliable reflection
- Constructing classes, instances, etc. on-the-fly
- Access control that goes beyond what the OS has to offer
- Self-contained assemblies (just dump a DLL into your project, and the types it contains, including documentation, are available to the compiler and the IDE)

Billybob said:

I guess what it all comes down to is freedom; the freedom to choose my own best practices rather than follow blindly the ideas of another.

This is all fine and dandy if it's a solo project, or if you are the lead and the rest of your team follows your guidelines. In other situations however, I'm thankful for any sane rule that the language, the compiler, or the IDE, forces on me and my team.

You should try Common Lisp. As I know, you can customize nearly everything to your needs.

Which is exactly why nobody uses it these days.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Neil Walker
Member #210
April 2000
avatar

Seems like another waste of space Google project to me. Aren't there enough programming languages in the world at the minute that do the job well.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

Billybob
Member #3,136
January 2003

that do the job well.

No.

ImLeftFooted
Member #3,935
October 2003
avatar

Quote:

that do the job well.

No. (once more for added effect)

Goalie Ca
Member #2,579
July 2002
avatar

I watched the talk.. rather half of the talk. The big names got my interest since everyone including google is involved. Then the introduction really got my attention: a simple grammar, orthogonal features, systems level language with GC, etc. It really seems like simplicity at its best! .. And then I saw the code itself.

-------------
Bah weep granah weep nini bong!

Arvidsson
Member #4,603
May 2004
avatar

And??? The suspense is killing me!

Trezker
Member #1,739
December 2001
avatar

Quote:

that do the job well

No. I think it's time for the next big language beyond C and C++.
One that:
executes just as fast or very close to C++.
makes programming easier and safer than C++.
still lets you mess things up if you want to.
lets the programmer use the full power of multiple cores easily and safely.

Anything more?

axilmar
Member #1,204
April 2001

It does impact performance, but there are HUGE advantages to such a model; to name a few:
- Proper reliable reflection
- Constructing classes, instances, etc. on-the-fly
- Access control that goes beyond what the OS has to offer
- Self-contained assemblies (just dump a DLL into your project, and the types it contains, including documentation, are available to the compiler and the IDE)

Why all these things cannot be done in a native programming language, i.e. a programming language with a virtual machine? I think that they are entirely possible.

-Reflection is a matter of storing type information in the binary.
-Constructing instances on the fly is already a capability.
-Constructing classes on the fly can be done, if reflection exists.
-Access control is a matter of type system: if it's strong enough and it can not be circumvented, as in C++, then any type of access control can be offered.
-self-contained assemblies is a matter of what meta-information you put in a DLL. Right now, C++ dlls are dumb raw binary blobs with the only information being the entry point table.

Why do all things things need a VM? they don't.

No. (once more for added effect)

NO!!!!! (more effect!)

One big disadvantage of decoupling interfaces and classes is the inability to send messages to self.

miran
Member #2,407
June 2002

I didn't read the project page, so I'm just going to ask here. Is Go's standard library named Ogle? :D

--
sig used to be here

anonymous
Member #8025
November 2006

I think Go! is better (because of the exclamation mark).

Evert
Member #794
November 2000
avatar

miran said:

Is Go's standard library named Ogle? :D

Apparently that's the proposed name of the debugger.

piccolo
Member #3,163
January 2003
avatar

dynamic language would be sweet we could have a program program itself at run time.

this is posible now but not with out memory hacks.

and a module design where you have module prgraming module.

wow
-------------------------------
i am who you are not am i

Ben Delacob
Member #6,141
August 2005
avatar

anonymous said:

I think Go! [en.wikipedia.org] is better (because of the exclamation mark).

Why would Google name it "Go"? Sure, it's catchy and has a similarity to their name but I can't even search for the board game Go. C was bad enough. However, not nearly as many people just start using the letter C when talking but Go is everywhere. I'd prefer to search for something in another language rather than try to find it done in Go.

__________________________________
Allegro html mockup code thread -website-
"two to the fighting eighth power"

Evert
Member #794
November 2000
avatar

I agree, they could have named it "G" to stick with the tradition of single-character names (there's "D" obviously and there's "F", not sure if there's "E", but "G" would be the next one up).
Or Gortran.

 1   2   3   4 


Go to: