Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

ErnestoNet

@ErnestoNet
About
Posts
28
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • FOLLOWUP:Winamp lovers beg AOL to open source code
    E ErnestoNet

    A friend told me to try it as the latest version of Winamp was pretty slow. It's very fast and neat. Sound quality is excelent. The installer is 7Mb... It has skins and addons. The most important thing is that it seems to be gaining momentum.

    it´s the journey, not the destination that matters

    The Lounge com

  • FOLLOWUP:Winamp lovers beg AOL to open source code
    E ErnestoNet

    Try Aimp (http://www.aimp.ru/index.php[^]) It's similar to Winamp, faster and uses less resources.

    it´s the journey, not the destination that matters

    The Lounge com

  • What makes C and C++ a "good" language?
    E ErnestoNet

    You said it yourself, in C and C++ you can statically link. Or not use. In Java/C# you can't. You load 42Mb rt.jar in Java. About embedded Java in http://www.avidwireless.com/Products.html[^], it looks rather expensive and not a custom solution. Most embedded code I've seen are for PIC modules http://en.wikipedia.org/wiki/PIC_microcontroller[^] We are talking about different kind of machines here.

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • Why prime factorization ?
    E ErnestoNet

    Interesting web resource: GIMPS search for the biggest prime: http://www.mersenne.org/[^] The latest maximum prime has 12,978,189 digits. Also, why look for prime numbers: http://primes.utm.edu/notes/faq/why.html[^]

    it´s the journey, not the destination that matters

    The Lounge question html com

  • What makes C and C++ a "good" language?
    E ErnestoNet

    It's not about being right, but if you want to be right, there you have it: YOU'RE RIGHT! That said, the STL, if you don't use it, you don't load it. The header approach only loads (and compiles) what you use. In fact, when you compile and link, only the functions that you use are linked. In Java and others, you load everything (even if you don't use it). About Embedded development, I know a lot of people that work with it and they work mostly with Assembler and C. Java and C++ may exist, but they are not used. Today embedded has changed with ARM cellphones. A 2Gb memory dual core CPU cellphone is closer to a PC that to embedded. There you can run Java, as in the PC. A real, cheap embedded chip with 64Kb of memory and a few cycles processor can't run (with decent performance) Java or C++. Java embedded only runs on ARM to start with. It requires at least 130Kb (with tweaking) and 700kb by default. It requires a network connection! It does not support real time. You can check everything here: http://www.oracle.com/ocom/groups/public/@otn/documents/digitalasset/1852008.pdf[^] I'm going to say it again, just because Bjarne Stroustrup said it and I think he is right: Java and .NET ARE PLATFORMS.

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • What makes C and C++ a "good" language?
    E ErnestoNet

    It's good to know different languages and try to understand why they are the way they are. Even more, it's good to know about different technologies (SQL, COM, OLAP, EJB, Corba, XML, JSON, CSS, HTML, etc). It's not about being good, but keeping the right attitude towards developing knowledge. People that know a lot about developing are the ones that admit they know nothing and keep learning, with an open mind. About the pay...that usually involves other skills that have very little to do with technologies or programming...:): http://www.theregister.co.uk/2012/03/21/how_to_get_paid_more/[^]

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • What makes C and C++ a "good" language?
    E ErnestoNet

    Call it availability. C is the most available language. There is an important point you make: I can always (within resource limits) create compiler/interpreter that originated on one platform and implement it for another. "within resource limits" is the key here. C is simple. Java JVM is complicated (and owned). It's important that you know that I'm not defending C. It's really ugly compared to other languages and prone to error. But it's fast (predictable fast, no GC collection pause), very "available", flexible and stable. Most of the programs I use everyday are built in C/C++. None in Perl. None in Java.

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • What makes C and C++ a "good" language?
    E ErnestoNet

    The problem with C (and C++) is that they have to be compatible with older code. And they are too flexible (too much for my taste). Don't think of high or low level. Templates in C++ are higher level than C# and Java generics (for sure). Think it this way. C/C++ is compatible with new and old stuff. ansi AND Unicode. Asm, procedures, objects and templates. Don't be sad for C/C++. They will outlast C#, Objective-C and Java (Java has started to decline and C again tops the tiobe index). You ask what makes C/C++ "good". Speed, portability, flexibility, huge codebases and an absense of an owner. But, most of all, a compromise of compatibility, no matter how complex the language becomes, how outdated the structure is. New features will be added, old features will not be replaced. To be "better", C/C++ should be incompatible with older code or fork. Luckily that won't happen. It will sacrifice simplicity and ease of use for compatibility. Oh, and C/C++, in certain cases, can be MUCH faster than C#/Java. I have an article where C/C++ is 10x faster that well written C#/Java.

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • What makes C and C++ a "good" language?
    E ErnestoNet

    Consider that C can work in microchips with very little memory and a very reduced CPU instruction set (for example http://www.microchip.com/[^]). Java and .NET are very different that C. They are "platforms", not languages. Java and .NET runtime is in the 20Mb+ size libraries. Latest versions don't support old operating systems. rt.jar is 42.6Mb (compressed!!). Java and .NET strings are inmutable, etc. I'm not defending C, but most modern languages aren't languages, they are frameworks. And C/C++ are few of the languages out there not owned by a corporation (.NET-Microsoft, Java-Oracle). C/C++ do not target app developers. They target compiler developers, OS developers, driver developers and libraries developers. I guess thats why C tops TIOBE (and C++ is 4º).

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • What makes C and C++ a "good" language?
    E ErnestoNet

    Headers provide an easy "standard" to build a compiler from. If there are more compilers, there is more portability. Java is not more portable than C. Java is (that I know) very portable, just not more portable than C. C has compilers built from a lot of companies for a variety of products (PIC, PIC32, ARM, X86, etc). Java mostly from Sun for X86.

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • What makes C and C++ a "good" language?
    E ErnestoNet

    Text based compilers are easier to write that binary based compilers. The headers approach is easy to build a compiler from. C is a very simple language to write a compiler. There are LOTS of C compilers. More compilers provide better portability. Portability is also usually the result of compatibility. So the reason why the headers approach doesn't change... There are not many cross platform/architecture languages. Name a crossplatform language and I'll compare that to C in terms of portability....

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • Fight !
    E ErnestoNet

    C/C++ have a different "model". The compiler based model. The C/C++ approach users are not only developers, but architecture builders and libraries developers. In most languages, you have the companies that support the language, that provide the compiler of the code you write to binary. In C/C++ you have the text based .h, .c and .cpp files that represent a "standard". That standard is implemented by multiple companies by different compilers. To make that work, the standard has to be flexible, easy to implement and should not change (very often). It was designed to be easy to build a compiler and libraries of it. And as a result, the portability of the code would benefit the developer. C/C++ main goals are portability and compatibility (with written code). Easy of use are secondary goals. When you think of C/C++ you must understand that, as a developer, that language was not designed only for you as a user of it.

    it´s the journey, not the destination that matters

    The Lounge c++ com discussion

  • What makes C and C++ a "good" language?
    E ErnestoNet

    C headers provide portability. There are LOTs of C compilers. Headers provide an easy way to build a C compiler for any PIC, ARM, X86, (name your own) architecture. It's not about the developer. It's about the CPU/Memory. About the C/C++ to machine conversion. Headers give a lot of headaches to developers, but developers pay that price to see their code run "everywhere" and not have to rewrite ALL the code every 2 years (for other architecture). Now you tell me that developers should have better tools. And they have. They have a lot of other languages that don't keep the "header" problem. The slow, very basic, error prone compiling. But that languages don't have the portability of C/C++ headers. Portability cannot be enforced. It is the result of ease of implementation of a language for an architecture. C/C++ compiler based approach is unmatched in this area.

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • What makes C and C++ a "good" language?
    E ErnestoNet

    1. Compatibility. If you want code to run on different architectures (X86, ARM, PIC, etc) and different operating systems, C (and sometimes C++) is the only way to go. 2. Performance. Predictable, excelent performance. Unrestricted use of memory and system resources. 3. Libraries (GLib, STL, etc). 4. Huge codebases. 5. Games (most games are done in C++). 6. Flexibility. C++ for example, doesn't impose "objects" and "interfaces". You can write code "the way you want" mixing objects, procedures and templates. You can write abstract code or go directly to asm in the same project. C tops in portability. C++ tops in flexibility. In these areas they have little competition (if any). Both usually top in performance (there are exceptions, but they are that, exceptions). That said, they are complex and require discipline. They are error prone. They are difficult to master (years). They don't have "unique" GUI or libraries. They are not controlled or improved by any corporation. They move at slow pace, considering that improvements should not break existing software.

    it´s the journey, not the destination that matters

    C / C++ / MFC question c++ com announcement

  • Tips for photographs
    E ErnestoNet

    Lots of good tips, with good photo samples: http://www.photographymad.com/[^]

    it´s the journey, not the destination that matters

    The Lounge question

  • Friday's Coding Challenge
    E ErnestoNet

    There are some Microsoft cache tools here too: http://msdn.microsoft.com/en-us/windowsserver/gg675186[^]

    it´s the journey, not the destination that matters

    The Lounge c++ algorithms architecture performance help

  • Friday's Coding Challenge
    E ErnestoNet

    Memcache sets a TTL (in milliseconds) when it adds the entry. After it expires it requeries. The parameters to set that TTL should be how often data changes in that table. I guess you could keep track of how many "visits" each item has and how often it changes in the original table. So, a simple algorithm would set to set the TTL based on a formula on which are visited a lot (increase TTL) and how fast they change (decrease TTL). Memcache itself uses MRU, LRU and lazy expired-LRU cleanup when memory is full.

    it´s the journey, not the destination that matters

    The Lounge c++ algorithms architecture performance help

  • Friday's Coding Challenge
    E ErnestoNet

    The solution to that problem is "memcached" (http://memcached.org/[^]). Of course, you can write your own, but being the code opensource, I´d check at what they're doing. They say some of how it works, here: http://amix.dk/blog/post/19356[^] Basically: They focus primarily on memory fragmentation. About the algorithm: "why would you waste processor cycles on finding expired items when you're not receiving any requests for it (as in, no one sees the data) *and* you haven't reached your memory constraints yet ?"

    The Lounge c++ algorithms architecture performance help

  • Coding Challenge
    E ErnestoNet

    Need to check this with other strings, debug some more, improve comments and string handling in main(), etc. But still....here it goes:

    #include "stdafx.h"

    const wchar_t whitechar = ' ';
    const bool IncludeWhiteSpace = true;
    const wchar_t* wordstoremove[] = {L"dog", L"cat"};

    const wchar_t* strtoparse = L"dog cat monkey dog horse dog"; //Len 28
    int ltoparse;
    const int numwords = 2;

    int wordlen[numwords];

    //Positions in the original string to rip
    int pos_orig_from;
    int pos_orig_to;

    //Len of left and right copies
    int left_len;
    int right_len;

    //Gets hoy many bytes per char
    void ProcessLeft(wchar_t* strresult)
    {
    bool bContinue = true;

    pos\_orig\_from = left\_len = 0;
    
    while (bContinue)
    {
    	//Check for whitespaces. If there are, copy them
    	if (strtoparse\[pos\_orig\_from\] == whitechar)
    	{
    		pos\_orig\_from ++;
    		if (IncludeWhiteSpace)
    		{
    			strresult\[left\_len\] = whitechar;
    			left\_len ++;
    		}
    	}
    	else
    	{
    		bContinue = false;
    		for (int i = 0; i < numwords; i++)
    		{
    			//Compare strings
    			wchar\_t\* strcompare = (wchar\_t\*)strtoparse + pos\_orig\_from;
    			if (wcsncmp(strcompare, wordstoremove\[i\], wordlen\[i\]) == 0)
    			{
    				pos\_orig\_from += wordlen\[i\];
    				bContinue = true;
    				break;
    			}
    		}
    	}
    }
    

    }
    void ProcessRight(wchar_t* strresult)
    {
    bool bContinue = true;

    pos\_orig\_to = right\_len = ltoparse - 1;
    
    while (bContinue)
    {
    	//Check for whitespaces. If there are, copy them
    	if (strtoparse\[pos\_orig\_to\] == whitechar && IncludeWhiteSpace)
    	{
    		pos\_orig\_to -= 1;
    		if (IncludeWhiteSpace)
    		{
    			strresult\[right\_len\] = whitechar;
    			right\_len -= 1;
    		}
    	}
    	else
    	{
    		bContinue = false;
    		for (int i = 0; i < numwords; i++)
    		{
    			//Compare strings
    			//To check right, start from end and substract string to compare len
    			wchar\_t\* strcompare = (wchar\_t\*)strtoparse + pos\_orig\_to - wordlen\[i\] + 1;
    			if (wcsncmp(strcompare, wordstoremove\[i\], wordlen\[i\]) == 0)
    			{
    				pos\_orig\_to -= wordlen\[i\];
    				bContinue = true;
    				break;
    			}
    		}
    	}
    }
    

    }

    int _tmain(int argc, _TCHAR* argv[])
    {

    //Load len of words to avoid rechecking
    for (int i=0; i
    
    The Lounge c++ architecture help

  • PrintPreview in MFC SDI Application
    E ErnestoNet

    You´re welcome. I spent a LOT of time making print preview work for different controls and situations.

    it´s the journey, not the destination that matters

    C / C++ / MFC help c++ architecture
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups