• Welcome to Valhalla Legends Archive.
 

Languages in the workplace

Started by shout, November 17, 2005, 02:32 PM

Previous topic - Next topic

iago

Quote from: Kp on November 17, 2005, 11:33 PM
Quote from: iago on November 17, 2005, 10:50 PMHave people actually started writing drivers in C++?  I couldn't even imagine doing some of the onboard programming I've done in C++, what a mess it would make..

Well, it depends on which C++ features you use.  For instance, I classify almost all my source as C++ just to turn on the strict type checking (linker errors on mismatched prototypes and no implicit cast-from-void, for instance).  Some projects will make use of inheritance, destructors, or other clever features (where a clever feature is anything that causes implicit or non-obvious code generation, which I can see might be a definite downside when trying to write a driver and ensure that it does exactly what you say), but others just use it as "C with more strict checks."

I typically compile all my code (lately) with "gcc -Wall -ansi -std=c89 [....]".  Since most of what I'm doing is homework and has to work on a variety of machines (my home Linux, school's Solaris, who knows what else profs/markers use), I like conform to older standards.  But that's just me. 

I don't like purely OO C++ code.  I don't think C++ does a very good job at OO, everything just ends up looking like a mess.  But that's more of an opinion than  fact. 
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


shout

Quote from: iago on November 18, 2005, 04:54 PM
I don't like purely OO C++ code. I don't think C++ does a very good job at OO, everything just ends up looking like a mess. But that's more of an opinion than fact.

Same with me, I find that OO C++ seems to just be messy.

Joe[x86]

I'm not a programmer for a living, but I want to ++ my post count (kidding), so I'll post.

Probably C++. I think I read somewhere that the programming world is leaning towards Java, but oh well. If you plan to program in the mathematics field, you will probably want to learn x86 assembly as well. The reason I say this, is although C++ is efficient, even seemingly trivial tasks can produce MANY processor cycles and slow you down a whole lot. For example, finding the prime factorization of 5444 in Visual Basic (using code I wrote, but its about as efficient as it can be) took a good two seconds.  With inline assembly, you're probably going to cut the processor cycles used by half, if not more, causing it to run twice as fast, if not more.

Thats my opinion, as invalid as it may be. =p
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

rabbit

That took less than a second with my Java code.  Maybe you just need to learn to code efficiently?

Took less than a second with my VB6 code too, and not very long with my PHP code either;
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

MyndFyre

Wow Joe, that's.... really sad.

It takes my C# code approx. 6.5 seconds to perform prime factorization 1,000,000 times on random numbers less than 9998.  My code can be found here.


This program is capable of finding prime factors of numbers up to
(but not including) 9998.
What value would you like to find primes for?
8988
This program will now verify that your number is not prime before attempting to
factor it.
The largest number that can be a factor is 4493 at index 609.
The program is now determining prime factors of 8988.
5 prime factors were found for 8988:
107, 7, 3, 2, 2
The program will now perform a test to evaluate the amount of time
required to calculate the prime factors of 1 million random numbers.

There was a total time of 00:00:06.6404550 required for 1000000 iterations.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

iago

Quote from: Joe on November 29, 2005, 06:48 PM
I'm not a programmer for a living, but I want to ++ my post count (kidding), so I'll post.

Probably C++. I think I read somewhere that the programming world is leaning towards Java, but oh well. If you plan to program in the mathematics field, you will probably want to learn x86 assembly as well. The reason I say this, is although C++ is efficient, even seemingly trivial tasks can produce MANY processor cycles and slow you down a whole lot. For example, finding the prime factorization of 5444 in Visual Basic (using code I wrote, but its about as efficient as it can be) took a good two seconds.  With inline assembly, you're probably going to cut the processor cycles used by half, if not more, causing it to run twice as fast, if not more.

Thats my opinion, as invalid as it may be. =p

CPU speed, harddrive, and RAM are much, much cheaper than hiring developers. 

If you have 10 programmers, 40 hours a week, $40/hour (the cost of having them, not what they're being paid), that's $16,000/week.  If you can reduce a project by a week, but it's going to cost you $12000 in hardware, you're saving $4000.  And $12000 is a lot of hardware. 

That's why Java and C# are so popular, they save on programmer hours, which is the most expensive resource. 
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Joe[x86]

@MyndFyre:
private static readonly int[] primes = new int[] {...}
You cheated. =p

Public Function PrimeFactorization(ByVal p_lNumber As Long) As String
          Dim m_sReturn As String, m_lNumber As Long, I As Long
10        m_lNumber = p_lNumber
20        For I = 2 To m_lNumber
30            If Not IsPrime(I) Then GoTo 90
40            If IsDivisible(m_lNumber, I) Then
50                m_lNumber = m_lNumber / I
60                Call strcat(m_sReturn, CStr(I) & " * ")
70                GoTo 40
80            End If
90        Next I
100       m_sReturn = Left(m_sReturn, Len(m_sReturn) - 3)
110       PrimeFactorization = m_sReturn
End Function

Public Function IsDivisible(ByVal p_lValue1 As Long, ByVal p_lValue2 As Long) As Boolean
    If p_lValue2 = 0 Then IsDivisible = False: Exit Function
    If Int(p_lValue1 / p_lValue2) = (p_lValue1 / p_lValue2) Then
        IsDivisible = True
    Else
        IsDivisible = False
    End If
End Function

Public Function IsPrime(ByVal p_lValue As Long) As Boolean
    Dim I As Long
    For I = p_lValue / 2 To p_lValue
        If IsDivisible(p_lValue, I) Then IsPrime = True: Exit Function
    Next I
    IsPrime = False
End Function

Public Sub strcat(ByRef p_sString1, ByVal p_sString2)
    p_sString1 = p_sString1 & p_sString2
End Sub


And I shouldn't even be using strcat, but eh?
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

MyndFyre

Quote from: Joe on November 29, 2005, 08:58 PM
private static readonly int[] primes = new int[] {...}
You cheated. =p
No.  Prime numbers are known.  I got those primes from prime-numbers.org.  Why would you call a library function to determine when a number is prime when you already know them?  You said your code was pretty much as optimized as possible.  That is a major optimization and it's almost completely free; it took up 610*4 bytes, or 2440 bytes.

QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

UserLoser.

Quote from: Joe on November 29, 2005, 08:58 PM
@MyndFyre:
private static readonly int[] primes = new int[] {...}
You cheated. =p

Public Function PrimeFactorization(ByVal p_lNumber As Long) As String
          Dim m_sReturn As String, m_lNumber As Long, I As Long
10        m_lNumber = p_lNumber
20        For I = 2 To m_lNumber
30            If Not IsPrime(I) Then GoTo 90
40            If IsDivisible(m_lNumber, I) Then
50                m_lNumber = m_lNumber / I
60                Call strcat(m_sReturn, CStr(I) & " * ")
70                GoTo 40
80            End If
90        Next I
100       m_sReturn = Left(m_sReturn, Len(m_sReturn) - 3)
110       PrimeFactorization = m_sReturn
End Function

Public Function IsDivisible(ByVal p_lValue1 As Long, ByVal p_lValue2 As Long) As Boolean
    If p_lValue2 = 0 Then IsDivisible = False: Exit Function
    If Int(p_lValue1 / p_lValue2) = (p_lValue1 / p_lValue2) Then
        IsDivisible = True
    Else
        IsDivisible = False
    End If
End Function

Public Function IsPrime(ByVal p_lValue As Long) As Boolean
    Dim I As Long
    For I = p_lValue / 2 To p_lValue
        If IsDivisible(p_lValue, I) Then IsPrime = True: Exit Function
    Next I
    IsPrime = False
End Function

Public Sub strcat(ByRef p_sString1, ByVal p_sString2)
    p_sString1 = p_sString1 & p_sString2
End Sub


And I shouldn't even be using strcat, but eh?


40            If IsDivisible(m_lNumber, I) Then
50                m_lNumber = m_lNumber / I
60                Call strcat(m_sReturn, CStr(I) & " * ")
70                GoTo 40
80            End If

w-t-f?


While (IsDivisible(m_lNumber, I)
...
Wend