What is wrong with the BASIC language?

For other topics related to the FreeBASIC project or its community.
Pritchard
Posts: 5492
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: What is wrong with the BASIC language?

Postby Pritchard » May 01, 2015 4:56

agamemnus wrote:
Pritchard wrote:Dude, v8 is f*ing fast these days :)

http://benchmarksgame.alioth.debian.org ... &lang2=gcc

Considering most people are processing server-side js using v8 + node.js (which then hands execution off to async c++ modules), those benchmarks are not bad at all given everything JavaScript can do.


It's far faster to code with than many other languages. But still, static typing and weak garbage collection will always be faster than non-static typing and automatic garbage collection... right?

Depends on how much you depend on those features, but I'm just speculating. (It's not like I have the capacity to work on V8 or LLVM myself, for example.)

How much faster than "normal" automatically optimized code, vs code that was specifically structured to avoid cache misses and optimize for a specific system (which a JIT can do, but an optimizing static compiler can only do if you target that system specifically)? Or how about garbage collection vs manual memory management? How good are people at manual memory management, really? (Allocating memory is one of the most expensive operations, and thus it's often done in big batches in highly optimized code by, for example, turning separate arrays into a vectorized single array.)

I'd say that if you're just writing code, not optimizing it at the framework level, you're not getting as many benefits from C or C++ as you might think. That depends on the underlying libraries as well as compiler implementation. Of course, the reference Ruby compiler is still entirely interpreted from what I recall. It's very slow. Scaled horribly for Twitter when it got to that point. Ruby's still an incredibly useful language. You just wouldn't want your game engine's inner loop written in Ruby, for example.

Now, Node.js and JavaScript with V8 is particularly interesting because JavaScript can be made extraordinarily fast. One, you have the V8 compiler which is going to determine the best ways to cache and optimize code. Thank you, Google. Two, you have the architecture which delegates the "inner loop"-type processing to async C++ threads, so there, your code is as basically as optimized as it's going to get already. (How expensive are function calls or marshalling between languages, really? Java does it all the time and it's maybe a fraction slower than C++ except for the cases, again, where people specifically optimize their code.)

So yeah, obviously there's overhead (RTTI, processing) to permit dynamic typing. I'm not soooo sure about garbage collection because that's already being done in modern C++ apps anyways. At least some sort of automated memory management via auto / smart ptrs.

Again, if you are using something like JavaScript how you would a statically typed language, maybe there are things that can be optimized. There will certainly still be overhead, but it appears to be surprisingly minimal for most uses. With something like ASM.js and the right JS compiler, I think you can achieve real desktop client performance now anyways... but don't quote me on that. I haven't followed that particular end of technology in a while.

ASM.js removes a lot of info / safety checks from JS, which makes it more barebones. And there's an important question... Can you remove features of a language at compile-time to allow optimizations? That's a crazy thought. It's what C, C++ allow you to do. C++ is really complex, but so much of that complexity is built on top of these surprisingly powerful and heavily optimized core features. But imagine JS without all of the safety, RTTI information, maybe even remove duck typing capabilities (although that might break the core of how the language functions in other places).

The fact that you get all of these features in JS and it's still fast as hell really confuses me to an extent. It's just crazy to think about. Or how algorithms written in JS or Ruby could actually perform faster than the same algorithm implementations in C or C++. That's weird, right? Just because a language offers ways to accomplish different things out of the box without interference from language, runtime or syntactical restrictions. One might think that shouldn't matter when you're comparing something to C or C++ (I think especially C++ because of its powerful standard library) because you're so close to how processing on the CPU actually works, but it apparently does.

I'd be interested in seeing the resultant processing / ASM from the simplest possible cases when JS or Ruby significantly outperform C or C++ implementations.
marcov
Posts: 2796
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » May 01, 2015 7:32

Keep in mind that these benchmarks with their high locality are a sweet spot for JITs though.

I don't know JS' internals that well, but you can actually push Java a lot by pretending it is C and only using value types.
caseih
Posts: 1390
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » May 01, 2015 13:22

Seems like Javascript is becoming a new virtual machine in its own right. There are many compilers out there that can emit JS now. Using emscripten, almost any language that has a compiler in the LLVM system can be targeted to Javascript. So in theory evey FreeBasic could compile to Javascript and run in any of the JS virtual machines out there. I'm honestly not sure what to think of this!
ike
Posts: 383
Joined: Jan 17, 2011 18:59

Re: What is wrong with the BASIC language?

Postby ike » May 01, 2015 18:35

the new generation of Delphi compilers (and also the C++Builder compilers) utilize the LLVM architecture.

it is worth mentioning that the LLVM architecture is gaining a lot of traction both in the open source tools world and in the proprietary world

The idea is to be able to compile Delphi source code to the LLVM IR and offer support for several CPU targets, starting with the ARM compilers for iOS and Android
caseih
Posts: 1390
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » May 01, 2015 19:27

The Gnu Compiler Collection still is a good set of tools, is still a lot more portable actually (many more platforms, though some obscure ones are probably bitrotting). FB's emitted C code could probably compile fine under llvm clang compiler, though. LLVM seems to be a bit easier for compiler writers to work with. FB could probably emit LLVM AST directly.

I am in favor of sticking with the c emitter and gcc compiler though. Wonder if there's a use case for a native client port of the FB compiler. The basics are already available, even SDL.
marcov
Posts: 2796
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » May 01, 2015 19:48

ike wrote:the new generation of Delphi compilers (and also the C++Builder compilers) utilize the LLVM architecture.


Afaik only the ARM compilers use LLVM, the x86 and x64 Windows compiler are still the old. And the "mobile" compilers only support part of the dialect.

it is worth mentioning that the LLVM architecture is gaining a lot of traction both in the open source tools world and in the proprietary world


I would say the traction is a bit less than a few years ago. GCC seems to be invigorated and pushed out a generally lauded 5.0, and in small language communities you hear the complained that CLang and LLVM are more and more entangled, and it is harder as an external to keep up.

The idea is to be able to compile Delphi source code to the LLVM IR and offer support for several CPU targets, starting with the ARM compilers for iOS and Android


They started with that 4 versions ago, but still no better optimization for x86/x86_64. I begin too suspect it isn't as succesfull as they hoped.
caseih
Posts: 1390
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » May 01, 2015 22:48

GCC goes through cycles of decline and resurgence. Back in the GCC 2.x days, it actually completely died. It was replaced by the EGCS project, so GCC 3 was essentially a fork. Rather than merging it back into the mainline, it simply replaced GCC. Now GCC is being reinvigorated by its LLVM competition, as well as the rise of JIT languages that rival compiled language speed. Like I say, GCC has a long life ahead of it. It's typically first to get ported to new platforms and architectures.
Pritchard
Posts: 5492
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Re: What is wrong with the BASIC language?

Postby Pritchard » May 01, 2015 23:14

Wow, didn't even know about the 5.0 release.

Look at this :)
https://gcc.gnu.org/wiki/JIT
caseih
Posts: 1390
Joined: Feb 26, 2007 5:32

Re: What is wrong with the BASIC language?

Postby caseih » May 02, 2015 2:44

Very cool. I hadn't heard about that part either. Some of what drew people to LLVM was that it could be used as a library to emit code in a JIT-like fashion. Or just do cool analysis by having the parser and abstract syntax tree available to a program. For example a smart code completion module that dynamically pulls in symbols and names from the complete project.
marcov
Posts: 2796
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » May 02, 2015 9:39

caseih wrote:GCC goes through cycles of decline and resurgence. Back in the GCC 2.x days, it actually completely died. It was replaced by the EGCS project, so GCC 3 was essentially a fork. Rather than merging it back into the mainline, it simply replaced GCC. Now GCC is being reinvigorated by its LLVM competition, as well as the rise of JIT languages that rival compiled language speed. Like I say, GCC has a long life ahead of it. It's typically first to get ported to new platforms and architectures.


Yeah, it was all to be expected, the world dominance plans of LLVM were a bit overly optimistic. As said the LLVM propaganda reminded me a lot of the GCC propaganda (when they introduced GIMPLE and the IR before) in the mid nineties.

That doesn't mean that either GCC or LLVM are on the way out (Even FPC has a LLVM and JVM backends nowadays), it is just that the honeymoon period of LLVM is over. Reality set in.

Still I fail to see the Javascript attraction other than the web tie-in. Yes it is a cheap runtime to maintain for mobile vendors since they to anyway for the browser, and for smaller apps it doesn't matter much. But to say it is great and the future of everything? Brrrr.
Last edited by marcov on May 02, 2015 12:06, edited 1 time in total.
jcfuller
Posts: 324
Joined: Sep 03, 2007 18:40

Re: What is wrong with the BASIC language?

Postby jcfuller » May 02, 2015 9:41

One of my favorite distros just updated:
http://nuwen.net/mingw.html

Note: 64bit only
James
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: What is wrong with the BASIC language?

Postby TESLACOIL » May 16, 2015 15:12

ref What is wrong with the BASIC language?

Q What is wrong with ALL programing languages ?

None of them are designed with common sense in mind ! , Ive not seen a single language that even comes close to close to being 'fit for human consumption' ...the chasm between what we should have as a programming language and what we do have is so vast and so deep that it not only defies explanation it defies my comprehension !!!

The blame for this deficit
lies almost entirely with experienced programmers, for they are the human beings responsible for creating computer languages. Paid or unpaid, it matters not, their crime is the same, their guilt the same, such truths are self evident and set out plain clear and clear to all humankind !

Guilty !

To close to the problem to see the solution
marcov
Posts: 2796
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: What is wrong with the BASIC language?

Postby marcov » May 19, 2015 13:09

TESLACOIL wrote:
None of them are designed with common sense in mind ! , Ive not seen a single language that even comes close to close to being 'fit for human consumption' ...the chasm between what we should have as a programming language and what we do have is so vast and so deep that it not only defies explanation it defies my comprehension !!!


If you know so well what we should have, why don't you simply create it then?

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests