The tag has no wiki summary.

learn more… | top users | synonyms

4
votes
2answers
93 views

Correct terminology in type theory: types, type constructors, kinds/sorts and values

In an answer to a previous question, a small debate started about correct terminology for certain constructs. As I did not find a question (other than this or that, which is not quite the right thing) ...
0
votes
1answer
106 views

comparison of an unsigned variable to 0

When I execute the following loop : unsigned m; for( m = 10; m >= 0; --m ){ printf("%d\n",m); } the loop doesn't stop at m==0, it keeps executing interminably, so I thought that ...
0
votes
2answers
93 views

Which layer should service errors be handled in?

I am coding in a multitier architecture in Java, and I perform a query to a web service. Is it better form for the errors returned by the service be handled in the data access layer or in the ...
2
votes
3answers
137 views

Knowing the range of variable types needed

So, if I (as the programmer) know that my value will never exceed a small number (say 100) because it is really just a counter-controlled loop or whatever, may I use short or char instead of int for ...
1
vote
2answers
75 views

Is there a stricter strtoull() in any ubiquitous C library?

I want a function that will interpret a string as a strictly unsigned integer, failing when the string overflows, represents a negative number, or does not represent a number. strtoull() does set ...
0
votes
1answer
126 views

Why are floats called “real numbers” in some languages?

Some programing languages, notably Pascal, have a type of numbers called "real". However, mathematically speaking, these types aren't real. For them to be "real", these types have to be able to ...
3
votes
2answers
138 views

How can a true Vector be implemented in Haskell?

How could a true Vector type be implemented in Haskell? In order for something to be a Vector, it has to be stored sequentially in memory, with O(1) random access. But Haskell hides its memory ...
6
votes
7answers
707 views

Why isn't there a next operation on enums?

In most popular programming languages like Java and C# there is a way to define enums, which are essentially datatypes with a fixed set of values, e.g. DayOfWeek. The problem is, given a value, e.g. ...
1
vote
4answers
200 views

Best datatype to store a ternary, or three-state variable

Disclaimer: I know that datatypes are a little bit subjective to which scripting/programming language you are using, I like to write in Python as a matter of preference; though I am happy to hear ...
1
vote
2answers
198 views

What is the underlying mechanism behind va_list and where is it defined?

http://www.cplusplus.com/reference/cstdarg/va_list/ According to the above link, va_list is an argument or parameter used in some macros - va_start, va_arg, va_end. These macros are present in the ...
0
votes
1answer
103 views

If a variable containing a function gave the function's return instead of a reference to the function, what would an array of functions return? [closed]

I'm creating a prototype scripting language similar to something like Javascript. In my language, every single reference to a variable is actually a function call (a getter function), whether it has ...
0
votes
2answers
138 views

What are and how do (data-) types work?

What is a "variable"/data type? How does a compiler / interpreter handle types? My specific concern has to do with the different types in lower and higher level languages. For instance in Python, ...
22
votes
11answers
3k views

Why do we still use floats? [duplicate]

I understand why floats served a purpose in the past. And I think I can see why they're useful in some simulation examples today. But I think those example are more exceptional than common. So I ...
1
vote
3answers
385 views

Is it bad practice to check object types with an identifying member variable?

Preamble: I am making a simple board game in C++, in which AI characters move around squares on the board. There are different types of squares, each inherited from an abstract class, each with ...
0
votes
1answer
174 views

Generic name for types and values [closed]

In computer science, what is the abstract common name of types and values (I mean an abstract "something" that can be a type or a value) ? To be more specific: If we have template <typename X> ...
0
votes
2answers
478 views

Assert equality in mstest when types may differ

I've been working on some MSTest automated test infrastructure, that is testing a tool that merges data sets into SQL Server database tables. The basic structure of the test is to: Define the ...
2
votes
2answers
95 views

Should I put the datatype of a class attribute in its name?

Most of my system's class attributes are just text, but in this case it makes more sense to place this particular class's attributes into one single hash (from a "keep the source code pretty" aspect). ...
1
vote
1answer
193 views

Improving the efficiency of containers with dynamically allocated objects

This is not strictly related to C++ but its type system serves to illustrate the problem well. Assume: We have a generic template Container<T> (such as a std::vector<T>) which stores an ...
2
votes
1answer
139 views

Is every object rounded to the same size in Java?

According to this answer every object in Java is of the same size? Is the answer talking about the object itself or the reference to the object? Here's the statement: every object size is rounded ...
6
votes
3answers
1k views

Why do some of object oriented languages let programmer use primitive types?

Why do some object oriented languages let the programmer use primitive data types? Aren't classes like Integer, Boolean, etc. enough?
16
votes
5answers
1k views

Would it make sense to use objects (instead of primitive types) for everything in C++?

During a recent project I've been working on, I've had to use a lot of functions that kind of look like this: static bool getGPS(double plane_latitude, double plane_longitude, double plane_altitude, ...
0
votes
2answers
166 views

Boolean-Integer Typecasting to Replace Conditional

When choosing a value based off of 2 boolean values in this format var foo:int; if (X){ foo = 50; } else if (Y){ foo = -50; } else { foo = 0; } I discovered that I can condense this ...
3
votes
4answers
1k views

Why many programming languages have only 2 data-structures: arrays and hashes?

Many programming languages have only those 2 structures, and even some languages that have more structures still only provide special syntax for those 2; usually, [] and {}. Why is this? Is there ...
18
votes
4answers
3k views

Why does Java not do type inference?

I have always wondered why Java does not do type inference given that the language is what it is, and its VM is very mature. Google's Go is an example of a language with excellent type inference and ...
2
votes
1answer
2k views

Java default Integer value is int

My code looks like this import java.util.Scanner; public class StudentGrades { public static void main(String[] argv) { Scanner keyboard = new Scanner(System.in); byte q1 = ...
1
vote
3answers
264 views

I want to create an open data format… but I don't really know what that is

I have found a need for a standardization for storage and recording of data relating to diabetes information (I don't think there's any, but I may have missed it). To that end I made this github ...
8
votes
4answers
330 views

Origin of structures and classes

What design and implementation issues did programmers have to solve when they decided first to use structures and classes? When did this happened and who were the pioneers behind these ideas? Note, ...
24
votes
9answers
17k views

What is meant by a primitive data type?

My understanding of a primitive datatype is that It is a datatype provided by a language implicitly (Others are user defined classes) So different languages have different sets of datatypes ...
2
votes
3answers
227 views

Web Development: is always Typing necessary or can type on demand work?

I realize this idea might seem really foreign but I started thinking about this a bit back. Far as web sites go, at least in my experience, there is far more time spent retyping things to a String ...
4
votes
5answers
996 views

Why disallow int-to-short assignment but allow multiplication and other math?

In Java, the following code does not compile: int val = 1; short shortVal = val; // Incompatible types Anyone know why Java chooses to complain about this assignment, instead of simply truncating, ...
9
votes
5answers
288 views

Examples of limitations in IT due to different bit length by design

I am teaching the course "Introduction in Programming" for the first-year students and would like to find interesting examples where the datatype size in bits, chosen by design, led to certain known ...
5
votes
3answers
251 views

Eliminating Dependencies vs Eliminating Redundancy

Upon my assignment to a project, I discovered that many message classes were received and then kept intact and passed around inside the receiving application. When these messages changed, code ...
12
votes
4answers
3k views

Why were short, int, and long invented in C?

I'm having trouble understanding, what were the exact purposes of creating the short, int, and long data types in C? The reason I ask is, it doesn't seem like their sizes are bounded -- they could be ...
1
vote
2answers
134 views

Does hierarchial inheritance belong to the past? [closed]

Recently it came to my attention that hierarchical inheritance may be a relic of thinking of classes as "structs with functions" rather than a product contract-driven mentality. Consider, as a simple ...
8
votes
4answers
680 views

Is integer used too much as a data type?

Do most application developers use signed integers in places where they really mean to use unsigned integers? I do it all the time, so do my co-workers. I haven't seen a lot of other extensive ...
3
votes
1answer
237 views

What are the advantages of having a built-in datatype in a data interchange format over not having it?

Due to the requirement of a project we had to develop a data interchange format with a built in data types. The format served the purpose well in the scope of that project. But I was thinking that ...
9
votes
2answers
1k views

What Are The Uses of Algebraic Data Types?

I'm reading about Algebraic Data Types (thanks to Richard Minerich I found this excellent explanation of the concept). While I think I understand the notion of sum types and product types etc., what ...
40
votes
21answers
12k views

Is type safety worth the trade-offs?

I began coding in in Python primarily where there is no type safety, then moved to C# and Java where there is. I found that I could work a bit more quickly and with less headaches in Python, but then ...
20
votes
6answers
9k views

C#: Explicitly defining variable data types vs. using the keyword 'var'?

In C#, am I encouraged to use the all-purpose var keyword for every variable declaration? If yes, do I have to mention those special characters for literal values within the variable declaration like ...
18
votes
24answers
1k views

Interesting or unique types in programming languages? [closed]

We have all seen integer, floating point, string, and the occasional decimal type. What are some of the most strange or unique or useful types you have encountered, useful or not?
10
votes
5answers
2k views

Understanding Abstract Data Types (ADTs)

Just browsing through Code Complete last night and I came across the explanation of abstract data types. I must have read it 5 times, and the Wikipedia article doesn't help much either. So what I'm ...
12
votes
16answers
3k views

What's the idea behind defining rectangles with two points?

It's not that this doesn't make sense, but it just works out awkward 99% of the time. Often in 2D graphics rectangles are initialized, stored and manipulated as a pair of points. In no particular ...
2
votes
2answers
383 views

Data structures for bioinformatics

what are some data structures that should be known by somebody involved in bioinformatics? I guess that anyone is supposed to know about lists, haseshes, balanced trees etc, but I expect that there ...