473,761 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What if...

Think for a moment:

IF you were Bjarne Stroustrup in 1985 (or whenever he were doing it)
writing down C++, and knowing all you know NOW of the C++ language,
(pro, cons, features of today languages)... What do *you* change of it
to make a better (in any sense you want) language?

some example issues:
Unicode?
Native string type?
Simpler syntax?
Boxing/unboxing?
Pascal-like units?
Jan 7 '06
24 1850
On Sun, 08 Jan 2006 15:11:21 +0100, Sebastian Wiesner
<Ba***********@ gmx.net> wrote:
W Marsh wrote:
On Sun, 08 Jan 2006 14:59:40 +0100, Sebastian Wiesner
<Ba***********@ gmx.net> wrote:
Once upon a time (Sonntag, 8. Januar 2006 12:38) Roland Pibinger wrote
some very nice things

On 7 Jan 2006 04:57:29 -0800, "peter koch"
<pe************ ***@gmail.com> wrote:
>> Native string type?
>
>There is already a native string-type. Just #include <string>.

#include <string> means that C++ has no _native_ string type. And yes,
even C should have one.

Many widely used languages like C# or Java don't have native string
types, so why should C or C++ have one? What is the advantage of a
native string type?


I thought that the string type in C# was native, but just had
reference value semantics and so felt different from the integral
types?


No, its implemented as a class (System.String) . The "native" string in C#
is just an alias for System.String.
Even integral types are implemented as classes. These classes only feel
like a value types.

I could be wrong though.


You are.

Basti


But surely that's a native type in the context of the language?
Jan 8 '06 #11
W Marsh schrieb:
On Sun, 08 Jan 2006 15:11:21 +0100, Sebastian Wiesner
<Ba***********@ gmx.net> wrote:
W Marsh wrote:
On Sun, 08 Jan 2006 14:59:40 +0100, Sebastian Wiesner
<Ba***********@ gmx.net> wrote:

Once upon a time (Sonntag, 8. Januar 2006 12:38) Roland Pibinger wrote
some very nice things

> On 7 Jan 2006 04:57:29 -0800, "peter koch"
> <pe************ ***@gmail.com> wrote:
>>> Native string type?
>>
>>There is already a native string-type. Just #include <string>.
>
> #include <string> means that C++ has no _native_ string type. And
> #yes,
> even C should have one.

Many widely used languages like C# or Java don't have native string
types, so why should C or C++ have one? What is the advantage of a
native string type?

I thought that the string type in C# was native, but just had
reference value semantics and so felt different from the integral
types?


No, its implemented as a class (System.String) . The "native" string in
C# is just an alias for System.String.
Even integral types are implemented as classes. These classes only feel
like a value types.

I could be wrong though.


You are.

Basti


But surely that's a native type in the context of the language?


The string type in C# is an alias for the class System.String, which is a
part of the class library of .NET. You could call it a faked native type.
It is not native type, but natively supported through the alias type of
C#.

Jan 8 '06 #12
>> #include <string> means that C++ has no _native_ string type. And yes,
even C should have one.

Best wishes,
Roland Pibinger

In what way should a native string behave differently to std::string?


Well, just one hint:

std::string x = "foo";

For native string I would expect no "strlen" call to deduce the length
of "foo" literal.

Mirek
Jan 8 '06 #13
Sebastian Wiesner ha scritto:
Many widely used languages like C# or Java don't have native string types,
so why should C or C++ have one? What is the advantage of a native string
type?


For example, pascal strings are not zero-terminated but have lenght at
first byte, which make them faster to concat and find length since there
is no need to scan the entire string for its terminator.
Jan 9 '06 #14
Massimo Soricetti wrote:
Sebastian Wiesner ha scritto:
Many widely used languages like C# or Java don't have native string
types,
so why should C or C++ have one? What is the advantage of a native string
type?


For example, pascal strings are not zero-terminated but have lenght at
first byte, which make them faster to concat and find length since there
is no need to scan the entire string for its terminator.


C++ strings are not null terminated either. It's unspecified how
it remembers the length but it has to do so somehow (I've seen
implementations internally that keep an length, and others that
keep and end pointer).
Jan 9 '06 #15
* Sebastian Wiesner:

The string type in C# is an alias for the class System.String, which is a
part of the class library of .NET. You could call it a faked native type.
It is not native type, but natively supported through the alias type of
C#.


By "native string type" we mean support for string operations on string
literals. Languages like Java and C# have that (the built-in aliases for
the types don't matter in that respect). C++ doesn't have that, but then,
C++ doesn't yet have a proper library string type, either, so it would have
been really unfortunate if the language supported std::string directly.

Instead of native support for some specific library class, I'd like to see a
proper string library class standardized, e.g. a non-mutable one with usual
string operations such as case conversions, substring replacement and so on,
and with at least one corresponding mutable string buffer class guaranteeing
contigous storage and constant time conversion to non-mutable string.

However, integrating that with the rest of the library would yield a de luxe
spaghetti tangle with side-effects from this and that, especially regarding
locales and iostreams (interestingly, as of early 2006 the wide character
standard streams are not yet supported by g++ for Windows...). So perhaps
we should do what I once tongue-in-cheek suggested, namely ditch everything
in the standard library except the original STL as defined by Stepanov
et.al. Hallelujah, that would be something!

Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jan 9 '06 #16
Mirek Fidler wrote:

In what way should a native string behave differently to std::string?


Well, just one hint:

std::string x = "foo";

For native string I would expect no "strlen" call to deduce the length
of "foo" literal.


Well, there would be no strlen check if std::string had a templated
constructor with char (&)[N] as the parameter. Also there is no reason
why a compiler can't optimise out the strlen check.

Jan 9 '06 #17
Massimo Soricetti wrote:
Think for a moment:

IF you were Bjarne Stroustrup in 1985 (or whenever he were doing it)
writing down C++, and knowing all you know NOW of the C++ language,
(pro, cons, features of today languages)... What do *you* change of it
to make a better (in any sense you want) language?

some example issues:
Unicode?
Native string type?
Simpler syntax?
Boxing/unboxing?
Pascal-like units?


In case you weren't aware, Stroustrup directly addressed this question
in his (now a bit dated) book "The Design and Evolution of C++." It's
an excellent read, and provides much insight as to why the language is
the way it is. Many features, for example, were not included because
they would have interfered with C compatibility. Many others were
rejected because they weren't necessary. C++ is already quite a large
language, and extraordinarily expressive, so frequently suggested
features are already implementable without explicit language support.

For example, std::string, when used properly, integrates (nearly) as
well as a built-in string type would. I think any built-in string type
that provided richer functionality would open a large can of worms --
none of the current built-in types dynamically allocate memory,
remember?

The one regret Stroustrup expressed was not having released a larger
library in Release 1.0.

Luke

Jan 9 '06 #18
java was designed to run on a hardware device that wasn't yet build.
they were developing set-top boxes for a major cable provider. the
provider went a different way and the hardware was abandoned. but it
was originally for microcontroller s

Jan 9 '06 #19
break label
continue label

Jan 9 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3102
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is burns. Here is the code: $frank = "burns";
220
19144
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
699
34110
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
92
6522
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption? cheers, reed
137
7172
by: Philippe C. Martin | last post by:
I apologize in advance for launching this post but I might get enlightment somehow (PS: I am _very_ agnostic ;-). - 1) I do not consider my intelligence/education above average - 2) I am very pragmatic - 3) I usually move forward when I get the gut feeling I am correct - 4) Most likely because of 1), I usually do not manage to fully explain 3) when it comes true. - 5) I have developed for many years (>18) in many different environments,...
12
11171
by: Dario | last post by:
The following simple program behaves differently in Windows and Linux . #include <stdexcept> #include <iostream> #include <string> using namespace std; class LogicError : public logic_error { public: string desc;
125
14832
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
47
9156
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
121
10149
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
8
3183
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that basically entitled to us to just about every .Net development tool you can imagine. I cant even begin to mention them. To begin with, my background is not that of a programmer, but a systems engineer and the closest I have come to "programming"...
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.