As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

PA Programming Thread :: PAdev.net - Need hosting for a service of yours? Check it out.

InfidelInfidel HereticRegistered User regular
Welcome to the Programming Thread, where people gather to share stories, lend a shoulder to cry on, and discuss how many bits would a woodchuck chuck if a woodchuck could chuck bits.

Making before Ecco does, his thread topic domination ends now!

padevnet.png

What is PAdev.net?

It is a project started up by this thread to support PA developers. A discussion about shared hosting turns into an idea to have hosting and a community to support those working on hobby programs and web services and what not.

Some things require a dedicated VPS but the bar of entry isn't that low. The cost is not extravagant but the know-how required to manage one is daunting for many. PAdev.net provides a share of hosting and support, a monthly fee nets you a shell account on the hub server and the expertise of your peers.

Community members looking to help out can request an account for the website, where all members can create and maintain guides and share project updates. There is no cost to have a community account, just contact an administrator. Also available are you@padev.net email accounts or forwarders.

Current administrators: @Infidel


Some writeups on various languages from the pros and such:
Jasconius wrote: »
Language: Python
Framework: Django
Purpose: Developing web applications rapidly

Django was created by a couple of nerds working for the newspaper industry, and they needed to solve the problem of having two practically identical sites (representing two newspapers owned by the same company) that had the ability to share content and generally be controlled from a central location. Thus Django, a flexible web framework that is different enough from Rails to be worth talking about.

Django is a batteries included framework that spends a lot of time trying to solve little things that are typically left to the gem community with Rails. The end result is a uniformly styled and extremely well documented web framework that can get you rolling pretty fast and is still easy enough to extend.

I've been using it for my new job and I've had very few complaints overall.
ASimPerson wrote: »
Language: C
Framework: Aahahahaha
Purpose: My job

Summary: C and its descendants (C++/Java/C#/etc.) are the most popular programming languages in the world. (As co-inventor Dennis Ritchie supposedly said, "C is quirky, flawed, and an enormous success.") The web browser you're using, the OS, most of your applications, most embedded software, the software on your router, the software on your ISP's router, the software on your game console, etc., were all written in C (well, or in C++).

For my job, I write in straight C. No libraries, no frameworks, no C++, no nothin'. C is a programming language for Real Men (tm), which means that there's no memory management and you're free to crash your program in various horrific ways. The trade-off for this is speed and size, attributes which give C its staying power - though proper C is losing favor as an application development language to C++, C#, and the like, it has found a second life in embedded applications and other small devices. I also think there's a certain elegance to the syntax - it's a language from an era when you didn't have a lot of memory, so statements are terse and lack the cruft of some more modern languages (*cough*C++*cough*). And best of all, no right minded C programmer would use LongVariableNamesLikeThis.

There's no shortage of manuals and documentation for the various incarnations of C, but the best reference is still from the source: The C Programming Language, by Kernighan and Ritchie. This book is so ubiquitous and standard that it's known simply as K&R in the field.
Nightslyr wrote: »
Language: C#
Framework: ASP.NET MVC 2 (soon to jump up to 3)
Purpose: Web Development

ASP.NET MVC is Microsoft's answer to the slew of MVC frameworks already available for a variety of open source languages - Rails for Ruby, Django (is that actually a MVC framework?) for Python, and Zend, Code Igniter, and Kohana for PHP. It's a nice addition because, well, web forms suck for the web, and it follows the same basic overall design methodology as everyone else. It's now in its 3rd version, with a completely new view engine - Razor - which is actually pretty cool. I like where Microsoft is going with MVC.

There are a ton of free resources and tutorials available to get started. Like everything else, MVC is fairly simple to learn but difficult to master. It can be as complex as you want it to be.

Personally, I'm having some growing pains getting myself up to the next level/tier in my own skill development. Learning TDD, IoC, Domain Driven Design, etc. I understand the basics, but I'm still learning OOP in general and both C# and ASP.NET, so piling the more advanced (to me) stuff on top of it has been slow going.

Still, I like it more than PHP.
ecco wrote: »
Language: Verilog
Framework: None
Purpose: Low level development

If you thought assembly language was low level, try Verilog or any of the other HDL languages on for size. Verilog is designed to describe how bits change every clock cycle. And not just one bit either, but potentially every bit available in the device that you are developing for.

This allows for massive parallelism - the sheer number of calculations per clock cycle can easily exceed both general purpose processors and DSPs.

It can also drive men insane.

I see square waves everywhere.
Phyphor wrote: »
Language: Lua
Framework: Custom
Purpose: Embeddable scripting

Lua is a neat little language. It is a dynamic, prototype-based language with relatively simple syntax (LL(1) ho!). There are primitive types (bools, numbers, strings, functions, nil), but the only structure for composition is the table, an associative array. Primitive types (except functions) are coerced to other primitive types as needed for operations. Functions are first class objects and it has closures.

Objects are created through special tables known as metatables, which define common operations and allow tables to take on characteristics of a class of objects, in effect allowing single inheritance.

The language is implemented in C and is designed to integrate easily with a host application. The API allows the host application to perform any operation the language can (and more). Lua can freely call functions provided by the host identically to native Lua functions and the host can create special object types that act as any other Lua object.

I mostly use it as a way to get scripting support into C, not as a standalone language, so I don't really know of any frameworks. I use a custom one to provide limited visibility of C++ classes to the scripts.

Oh and someone wrote a JIT compiler
lazerbeard wrote: »
Language: C++
Framework: Proprietary
Purpose: Video game tools/graphics

If you want to make AAA games on a console. You're probably going to end up working with C++, if you like it or not. With 512 megs of shared memory, multiple fiddly "special processing units", people clamoring over sending 64 players' worth of data over a network at an even pace and other wonderful things, performance down to the bit really does matter. Not to mention that the API (and compiler) is written for C++, so you're not getting away from it if you want to work on console games unless you're using XNA. C++ is the tacticool gun of programming languages. If you can do it, you can probably find a way to do it in C++, then you can probably find a way to hack it so that it only uses 10 bits at a time to do it.

Honestly, I don't spend the entirety of my time in this nether realm of pure data as I'm a tools programmer by trade. In a day I'll go between C++, C#, python and back again. Each language has its own sets of advantages and disadvantages, of the three I'd honestly say C# is the most "fun" to work with. C++ still wins out for me, just for being extremely versatile, while keeping performance high. I think the other thing I like about C++ is that the performance cost of anything is laid bare much more in the other languages I work with. Because you are tasked with moving around the bits other languages abstract away, I always feel the performance cost of code I write is much more impressed upon me when I write it in C++. When looking at performance in other langages, I often consider how it would effect performance had I tried the same trick, as underneath the hood the process is most likely similar.
Tallus wrote: »
Language: PHP
Framework: Custom
Purpose: Web development

Although slightly outshone by the relatively new Ruby on Rails, PHP is still a solid choice for Web development. An engine is available for pretty much every web server (Apache and IIS being the major ones of course), it's easy to learn if you come from any kind of c type background and it offers some really neat features if you dig deep enough. Recent releases (5.3 I think) offer true namespacing to add to the plethora of object orientated features already present (if you like that kind of thing). One of the best things about PHP though is that, because it's so widely adopted there's literally tons of tutorials, documentation and samples out there to get you going.


Language: VB (classic)
Framework: Ha, I wish
Purpose: Legacy application development

Yeah I know. I use VB in my day job since I have to maintain a ton of applications written in it. It's slow as hell, the IDE sucks and I really have nothing good to say about it. For all its flaws .Net is a massive improvement on Microsoft's legacy development environments. I did manage to find a plugin for the VB IDE that allows tabbed documents, full screen editing and some other nifty features. I'll see if I can find it if anyone is interested.

Language: Javascript
Framework: jQuery (and jQuery mobile)
Purpose: Web application front end development

Javascript has been around for donkey's years and is pretty much universally supported in modern web browsers. It allows you to do a ton of useful / cool stuff with pages once they're pushed down to the client. jQuery is a briliant javascript framework that offers some amazing features. The core of jQuery revolves aorund 'selectors', basically filters you can use to select any element (or group of elements) on a page before applying code / styles to them. There's also some nifty binding functions, to add functionality to elements after they're rendered and ooooh, all sorts of other things. One of the best things about jQuery (and something that sets it apart from other frameworks) is its support for plugins. There's thousands of plugins available for just about anything you can think of, and they make jQuery into (in my opinion) the best tool in any web designers toolkit. jQuery mobile is an addition to jQuery to enable the building of mobile applications in a consistent manner across just about any mobile platform.

I also do C# and Android development, but can't really think of anything interesting to say about them right now.
Language: F#/C#
Framework: .Net 4.0 Runtime
Purpose: HFT/Non-HFT systems

With Visual Studio 2010, F#, an ML-variant functional language, is now part of the .Net language family. It has full interop capabilities with any existing .Net assemblies and any other .Net languages are capable of loading .Net assemblies written in F# (with a couple of minor issues to watch out for). It's a full functional language and is best when you program it like a functional language and not ML with classes. There's some good resources out there on F#. I've done a couple of larger scale server applications with it and starting to move on to version 2.0 on a few of them. I also mix in C# when needed for things like COM-interop and certain client APIs.

Language: Clojure
Framework: JVM
Purpose: Large-scale data spelunking

Clojure is a neat little functional language that runs in the JVM. Very LISPy, with a heavy emphasis on macros. I mainly use it with Cascading/Hadoop to slam through the massive data sets and extract the various data of interest.

I also putter around with the CUDA/CULA stuff and data parallel Haskell when I have time.
seabass wrote: »
Language: OCaml / C++ / Fortran
Framework: Lisp converted to Ocaml handed To grad students
Purpose: Combinatorial Optimization, Automated Planning, Robot Path finding, other research topics

OCaml is, like F#, an ML-variant with objects. It's particularly nice because it isn't terribly pedantic and lets you mix imperative programming with functional code wherever you feel it's expedient to do so. It's got a full object system which I've never extensively used, but I hear it's nice. You can run the code in an interactive interpreter, or you can compile native binaries which are relatively quick for a language which manages your memory for you.

The big drawback is that we don't have a concurrent garbage collector yet, so while we have threads, they don't behave the way you would want them to. You can work around it by doing any concurrency you'd like at the process level with pipes or something like MPI.
Language: Ruby
Framework: Rails
Purpose: Developing web applications

Ruby on Rails (RoR or often just called 'Rails') is a web application framework with a practical slant. While most frameworks present themselves as a sort of toolbox, Rails goes a step further by favoring convention over configuration. Instead of configuring how the tools interact with each other yourself, Rails infers what you mean to do from a few naming conventions in your class, method, table and path names. If it gets in the way, you can always define what name it should look for instead yourself.

Rails uses the model-view-controller (MVC) architectural pattern to separate the concerns in your code. On the controller side, it favors RESTful style url method coupling. On the model side, it provides an object oriented representation of your database tables. For the views, it provides a templating engine called ERB (I prefer HAML though).

One of the best things of Rails is the developer community. A lot of Rails developers blog about their experiences or post their problems on Stack Overflow. There also is a sort of package manager/repository for Ruby libraries called RubyGems that helps you install, update and resolve dependencies. For configuring what gems you use in your Rails project, you should use Bundler (which is baked into Rails 3). Most gems can be found on github for easy forking.

I can heartily recommend Rails to everyone looking for an easy to use web application framework. It's as easy as "sudo apt-get install rails && rails new ~/myproject".
Infidel wrote: »
Language: SQL
Framework: None
Purpose: Manipulating your datas

SQL is ubiquitous and often taken for granted. Whether you're a Java or C or Access or PHP or what-have-you developer, you'll often be dealing with another language, being SQL. Some might have frameworks that abstract and/or obscure the SQL, but it's almost always there. The complexity required of your SQL can vary, and for a lot of projects it is relatively simple. Understanding SQL at a non-trivial level however will help you understand how computers work with large datasets, which will aid you in how you design and interact with your data even if you don't actually write any SQL directly.

Relational algebra and key theory is useful stuff for "thinking about it right" when it comes to schemas and queries. Also keep in mind that while SQL is a standard, every database system has a point where it diverges from the standard. When you start dealing with very complex queries or procedural code and triggers etc., you'll see very different syntax and often different approaches altogether due to vendor support of features available. For example, Microsoft SQL Server uses Transact-SQL (T-SQL), Oracle uses PL/SQL, and while both are the common system found in the business world and accomplishing the same objectives they are very different beasts to the developer. Methods and tricks for one are not always the best or feasible for the other, and you often rely on tricks to attain the performance demanded by the project.

In a rather different scope, web sites and services tend to use other systems, such as MySQL and PostgreSQL. The focus here is usually less on procedural code and more on efficient SQL-standard queries. The scale of the project might be trivially small where any design works to massive commerce sites that sell a hojillion products and track customer trends. Most people here will not be dealing with that, but many of us will have some sort of SQL database backend which we need to write queries for. Non-standard SQL is avoided as much as possible typically, in order to avoid vendor lock-in. This is the dangerous realm of SQL injection attacks which are one of the most common mistakes made by novice developers who need to use a database for persisting their data on their web site but don't have much experience or exposure. Sanitize your inputs and use parameterized queries! :^:

OrokosPA.png
Infidel on
«134567100

Posts

  • InfidelInfidel Heretic Registered User regular
    an_alt wrote:
    I whipped up an internal utility a few months ago for importing XML documents into software that our company makes. On a grey screen, It has three buttons - one to pick the input file, one to pick the destination, and one to do the import. There are friendly, verbose messages for success and different types of failure.

    After being in use for about two months, I was asked by our tech support manager to produce documentation for it. He was unable to tell me which of the three buttons needed further clarification.

    You must have done something to offend the manager. Don't you know that writing documentation is just a form of discipline/punishment?

    OrokosPA.png
  • zeenyzeeny Registered User regular
    Smells new & fresh!

  • bowenbowen How you doin'? Registered User regular
    I'm thinking about undertaking a portable UI system that uses XML and works on numerous platforms/languages. This seems like a crazy idea, but good golly most of the portable UIs are absolute shit, and I don't need the power from Qt that it thinks I do.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • an_altan_alt Registered User regular
    Infidel wrote:
    You must have done something to offend the manager. Don't you know that writing documentation is just a form of discipline/punishment?

    As it turned out, he wanted things like "workflows" and "best practices." I informed him that it was "his job" to tell his people how to do things, especially since he already knew exactly what he wanted and was just too lazy to type it up.

    Pony wrote:
    I think that the internet has been for years on the path to creating what is essentially an electronic Necronomicon: A collection of blasphemous unrealities so perverse that to even glimpse at its contents, if but for a moment, is to irrevocably forfeit a portion of your sanity.
    Xbox - PearlBlueS0ul, Steam
    If you ever need to talk to someone, feel free to message me. Yes, that includes you.
  • EtheaEthea Registered User regular
    bowen wrote:
    I'm thinking about undertaking a portable UI system that uses XML and works on numerous platforms/languages. This seems like a crazy idea, but good golly most of the portable UIs are absolute shit, and I don't need the power from Qt that it thinks I do.

    Just build a subset of Qt?

  • Jimmy KingJimmy King Registered User regular
    an_alt wrote:
    Infidel wrote:
    You must have done something to offend the manager. Don't you know that writing documentation is just a form of discipline/punishment?

    As it turned out, he wanted things like "workflows" and "best practices." I informed him that it was "his job" to tell his people how to do things, especially since he already knew exactly what he wanted and was just too lazy to type it up.
    I used to run into this all the time at my old job. I was always telling people basically the same thing. "I've provided the technology you requested, it's up to you to determine how and when using this fits in with the work you do."

  • bowenbowen How you doin'? Registered User regular
    Ethea wrote:
    bowen wrote:
    I'm thinking about undertaking a portable UI system that uses XML and works on numerous platforms/languages. This seems like a crazy idea, but good golly most of the portable UIs are absolute shit, and I don't need the power from Qt that it thinks I do.

    Just build a subset of Qt?

    Eh Qt feels bulky and hard to work with on things where I just need a form with 3 buttons. Lightweight is what I was going for.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • InfidelInfidel Heretic Registered User regular
    bowen wrote:
    Eh Qt feels bulky and hard to work with on things where I just need a form with 3 buttons. Lightweight is what I was going for.
    an_alt wrote:
    I whipped up an internal utility a few months ago for importing XML documents into software that our company makes. On a grey screen, It has three buttons - one to pick the input file, one to pick the destination, and one to do the import. There are friendly, verbose messages for success and different types of failure.

    After being in use for about two months, I was asked by our tech support manager to produce documentation for it. He was unable to tell me which of the three buttons needed further clarification.

    Make sure you do analysis and document the workflow!

    lightweight olol :(

    OrokosPA.png
  • SeolSeol Registered User regular
    Had fun today with Java and Spring. Even more so than usual!

    You'll never guess what happens if you try to set up dependency injection on a generic class, one of whose type parameters is bounded by two interfaces, like this:
    @Configurable
    public class Whatever<M extends IThis & IThat> {
       @Autowired
       private SomethingImportant;
    }
    
    You run out of heap space when you try to instantiate the class.

  • InfidelInfidel Heretic Registered User regular
    edited September 2011
    Here, I'll make an entry I guess!

    Language: SQL
    Framework: None
    Purpose: Manipulating your datas

    SQL is ubiquitous and often taken for granted. Whether you're a Java or C or Access or PHP or what-have-you developer, you'll often be dealing with another language, being SQL. Some might have frameworks that abstract and/or obscure the SQL, but it's almost always there. The complexity required of your SQL can vary, and for a lot of projects it is relatively simple. Understanding SQL at a non-trivial level however will help you understand how computers work with large datasets, which will aid you in how you design and interact with your data even if you don't actually write any SQL directly.

    Relational algebra and key theory is useful stuff for "thinking about it right" when it comes to schemas and queries. Also keep in mind that while SQL is a standard, every database system has a point where it diverges from the standard. When you start dealing with very complex queries or procedural code and triggers etc., you'll see very different syntax and often different approaches altogether due to vendor support of features available. For example, Microsoft SQL Server uses Transact-SQL (T-SQL), Oracle uses PL/SQL, and while both are the common system found in the business world and accomplishing the same objectives they are very different beasts to the developer. Methods and tricks for one are not always the best or feasible for the other, and you often rely on tricks to attain the performance demanded by the project.

    In a rather different scope, web sites and services tend to use other systems, such as MySQL and PostgreSQL. The focus here is usually less on procedural code and more on efficient SQL-standard queries. The scale of the project might be trivially small where any design works to massive commerce sites that sell a hojillion products and track customer trends. Most people here will not be dealing with that, but many of us will have some sort of SQL database backend which we need to write queries for. Non-standard SQL is avoided as much as possible typically, in order to avoid vendor lock-in. This is the dangerous realm of SQL injection attacks which are one of the most common mistakes made by novice developers who need to use a database for persisting their data on their web site but don't have much experience or exposure. Sanitize your inputs and use parameterized queries! :^:

    Infidel on
    OrokosPA.png
  • amnesiasoftamnesiasoft Thick Creamy Furry Registered User regular
    Infidel wrote:
    Sanitize your inputs and use parameterized queries! :^:
    And if you don't believe that, go look at half the Sony hacks.

    steam_sig.png
  • TomantaTomanta Registered User regular
    edited September 2011
    Infidel wrote:
    Sanitize your inputs and use parameterized queries! :^:
    And if you don't believe that, go look at half the Sony hacks.

    "Inputs come from someone that is either stupid or malicious. Note there is no 'may' in that sentence." should be taught day 1 in any programming-type course. Also mentioned in the introduction and at the start of every chapter of any programming book.

    Tomanta on
  • ecco the dolphinecco the dolphin Registered User regular
    My reign of bad puns and terror - stolen - while I was sleeping!

    Well played, Infidel. Well played.

    Penny Arcade Developers at PADev.net.
  • TomantaTomanta Registered User regular
    So when I started playing with Django a few days ago, I wrote down a multi-step project I thought would take me about a week per step.

    I finished the first step in three days (as in, the backend / programming stuff is done).

    I guess that gives me five days to play around with the layout/appearance of the pages.

  • ASimPersonASimPerson Cold... and hard.Registered User regular
    Hey, so who spent his Friday night debugging what turned out to be a typo in an #ifdef?

    This guy

  • ecco the dolphinecco the dolphin Registered User regular
    edited September 2011
    ASimPerson wrote:
    Hey, so who spent his Friday night debugging what turned out to be a typo in an #ifdef?

    This guy

    #ifdef 0 // TODO: Comment this back in after I've finished debugging

    Edit: Crap, 0 is not an identifier.

    ecco the dolphin on
    Penny Arcade Developers at PADev.net.
  • JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited September 2011
    I just finished building my first full Android app for the Nook Color after doing iOS for over two years.

    There are a few things about Android that are good and convenient, but there are just so many negatives. Not only in the development process but also in the actual user experience itself... and maybe some of this is Nook specific, but I have a feeling not all of it is.

    Pros:

    * The layout engine is interesting but ultimately inhibitive. The default Android interface suite is designed to be spartan, functional, and flexible in the sense that it must support so many screens. It succeeds in this area but it clearly sacrifices a lot in the way of more creative interface designs which would be borderline impossible with Android's platform fragmentation. To pull that stuff off you have to drill all the way down to OpenGL basically, whereas in iOS there is a middle-ground thanks to UIKit and QuartzCore. Is this really a pro? It is because I am making the assumption that Android owners are used to having apps that are "good enough". They show you what they need to show, they are organized, and they work. Getting this far in Android is really easy. Going the extra mile seems nearly impossible.

    * Android has a lot more in the arena of pre-authored UI controls. Probably as a result of point #1. A lot more potency in the area of form building, etc... these are important features IMO, as I often find form building in iOS to be hellish and needlessly complicated.

    * Java makes common necessities of UI development easier. Easy static variables, inline event handlers (sort of, but good enough), etc. I don't know what the official name is for the language technique where you define abstract methods in a constructor, but Android's API's use this to effect for things like complex event handlers, etc... I like it more than declaring 500000 delegate methods in an Objective-C class. iOS is catching up here with Blocks, but not everything supports Blocks yet.

    * Eclipse ADT's binary resource system is better than XCode's... and I like the way that the UI XML declarations are bound in Java... there is probably unspeakable evil that goes into this (like on-the-fly generated Java class files which probably are a function of Eclipse, not of Android), but as long as your are using Eclipse, it's OK.

    * Device testing is easier, but this is probably because

    Cons:

    * The emulator sucks untold amounts of ass. It is insanely slow and will kernel panic OS X in under 30 minutes of up time. Awful.

    * Strong typing is exhausting. It just is. Where Java gains in things mentioned under Pros, it loses badly in other areas like strongly typing every fucking thing, clunky getter names (for people who aren't accustomed to Java), and other annoyances. This is especially evident when unpacking a layout XML file into instance variables, where every goddamn thing must be cast to its type. Also maybe it's just Eclipse being a bastard, but does null not evaluate to false in Java? Eclipse was not liking it when I tried that

    * Managing text is weird. The control on every text field is highly granular and the defaults don't help you at all. Multiline text fields are broken out of the box, and basically everything about advanced text is lightly documented

    * Default themes are lacking. You'd think Google would spend 5 days and just build out like 25 themes or something, but no. Not pleasant given how troublesome it can be to integrate custom graphics into a UI.

    * Eclipse ADT is missing important things. Like a big shiny huge button that says "STOP PROCESS". I have searched and searched and I can't find a way to just kill an app via Eclipse. So in the event you launch your app and you get stuck in a hideous or dangerous loop, the easiest way from Eclipse to remedy this is to clean and rebuild your application entirely and re-run it. Uhh.

    * Controlling the keyboard is puzzlingly difficult. It's like four lines of code just to hide the keyboard. What the fuck?

    * Some UI controls are insanely difficult to use. I spent over 45 minutes trying to figure out how to make an indeterminate spinner progress bar function in Android and NEVER found the answer, and tried like 4 or 5 different approaches. In iOS this is one line of code.

    * A billion other examples of things in Android that take 4-8 lines of code, or an entire class implementation that are only one or two lines of code in Cocoa.

    Jasconius on
  • ASimPersonASimPerson Cold... and hard.Registered User regular
    ASimPerson wrote:
    Hey, so who spent his Friday night debugging what turned out to be a typo in an #ifdef?

    This guy

    #ifdef 0 // TODO: Comment this back in after I've finished debugging

    Edit: Crap, 0 is not an identifier.

    #if 0 works though!

  • The AnonymousThe Anonymous Uh, uh, uhhhhhh... Uh, uh.Registered User regular
    edited September 2011
    Can someone explain why this infix-to-postfix conversion code inexplicably either hangs or silently crashes?
                List<string> postfix = new List<string>();
                string stack = string.Empty;
                
                postfix.Add(String.Empty);
                
                for (int i = 0; i < input.Length; i++)
                {
                    int precedence = OperatorPrecedence(input[i]);
    
                    if (precedence == 0)
                        postfix[postfix.Count - 1] += input[i].ToString();
                    else if (precedence != 4 && precedence != -1)
                    {
                        if (stack.Length == 0)
                            stack += input[i].ToString();
                        else 
                        {
                            for (; stack.Length > 0 && OperatorPrecedence(stack[0]) >= precedence;)
                            {
                                if (postfix[postfix.Count - 1] == String.Empty)
                                    postfix[postfix.Count - 1] += stack[0].ToString();
                                else
                                    postfix.Add(stack[0].ToString());
                                stack.Remove(0, 1);
                            }
                            stack = input[i].ToString();
                        }
                    }
                    
                    if (i < input.Length && postfix[postfix.Count - 1] != String.Empty)
                        postfix.Add(String.Empty);
                }
                
                for (int i2 = 0; i2 < stack.Length; i2++)
                {
                    if (postfix[postfix.Count - 1] == String.Empty)
                        postfix[postfix.Count - 1] += stack[i2].ToString();
                    else
                        postfix.Add(stack[i2].ToString());
                }
    

    The Anonymous on
  • seabassseabass Doctor MassachusettsRegistered User regular
    So this semester they've got me TA'ing for the algorithms. This means I need to write in C. There isn't anything wrong with C, it's a lovely language (that I barely know how to use). The students hate that I make liberal use of function pointers, and I hate that I can't curry away arguments.

    What's a good guide to idiomatically programming C? I keep the bible (K&R) on my desk, but that's more of a "what does this function do" sort of thing, not "here is the way C wants you to design an iteration function".

    Run you pigeons, it's Robert Frost!
  • Jimmy KingJimmy King Registered User regular
    In git, can I manage submodules semi-separately? Like have an overall module which has its own remote and then have a submodule which also has its own separate remote? Basically, I've got a Django app which I'd like to distribute on its own, but 99% of my dev work on it and my own personal usage for it is within the context of one website so I'd like to be able to just have it as part of that website's module plus distributable on its own.

  • bowenbowen How you doin'? Registered User regular
    Can someone explain why this infix-to-postfix conversion code inexplicably either hangs or silently crashes?
                List<string> postfix = new List<string>();
                string stack = string.Empty;
                
                postfix.Add(String.Empty);
                
                for (int i = 0; i < input.Length; i++)
                {
                    int precedence = OperatorPrecedence(input[i]);
    
                    if (precedence == 0)
                        postfix[postfix.Count - 1] += input[i].ToString();
                    else if (precedence != 4 && precedence != -1)
                    {
                        if (stack.Length == 0)
                            stack += input[i].ToString();
                        else 
                        {
                            for (; stack.Length > 0 && OperatorPrecedence(stack[0]) >= precedence;)
                            {
                                if (postfix[postfix.Count - 1] == String.Empty)
                                    postfix[postfix.Count - 1] += stack[0].ToString();
                                else
                                    postfix.Add(stack[0].ToString());
                                stack.Remove(0, 1);
                            }
                            stack = input[i].ToString();
                        }
                    }
                    
                    if (i < input.Length && postfix[postfix.Count - 1] != String.Empty)
                        postfix.Add(String.Empty);
                }
                
                for (int i2 = 0; i2 < stack.Length; i2++)
                {
                    if (postfix[postfix.Count - 1] == String.Empty)
                        postfix[postfix.Count - 1] += stack[i2].ToString();
                    else
                        postfix.Add(stack[i2].ToString());
                }
    
                            for (; stack.Length > 0 && OperatorPrecedence(stack[0]) >= precedence;)
                            {
                                if (postfix[postfix.Count - 1] == String.Empty)
                                    postfix[postfix.Count - 1] += stack[0].ToString();
                                else
                                    postfix.Add(stack[0].ToString());
                                stack.Remove(0, 1);
                            }
    

    That is an infinite loop, and it doesn't look like you're doing anything to break out of it. So if there's ever a chance for it to enter the loop, it'll sit there forever as far as I can tell.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • The AnonymousThe Anonymous Uh, uh, uhhhhhh... Uh, uh.Registered User regular
    edited September 2011
    bowen wrote:
    Can someone explain why this infix-to-postfix conversion code inexplicably either hangs or silently crashes?
                List<string> postfix = new List<string>();
                string stack = string.Empty;
                
                postfix.Add(String.Empty);
                
                for (int i = 0; i < input.Length; i++)
                {
                    int precedence = OperatorPrecedence(input[i]);
    
                    if (precedence == 0)
                        postfix[postfix.Count - 1] += input[i].ToString();
                    else if (precedence != 4 && precedence != -1)
                    {
                        if (stack.Length == 0)
                            stack += input[i].ToString();
                        else 
                        {
                            for (; stack.Length > 0 && OperatorPrecedence(stack[0]) >= precedence;)
                            {
                                if (postfix[postfix.Count - 1] == String.Empty)
                                    postfix[postfix.Count - 1] += stack[0].ToString();
                                else
                                    postfix.Add(stack[0].ToString());
                                stack.Remove(0, 1);
                            }
                            stack = input[i].ToString();
                        }
                    }
                    
                    if (i < input.Length && postfix[postfix.Count - 1] != String.Empty)
                        postfix.Add(String.Empty);
                }
                
                for (int i2 = 0; i2 < stack.Length; i2++)
                {
                    if (postfix[postfix.Count - 1] == String.Empty)
                        postfix[postfix.Count - 1] += stack[i2].ToString();
                    else
                        postfix.Add(stack[i2].ToString());
                }
    
                            for (; stack.Length > 0 && OperatorPrecedence(stack[0]) >= precedence;)
                            {
                                if (postfix[postfix.Count - 1] == String.Empty)
                                    postfix[postfix.Count - 1] += stack[0].ToString();
                                else
                                    postfix.Add(stack[0].ToString());
                                stack.Remove(0, 1);
                            }
    

    That is an infinite loop, and it doesn't look like you're doing anything to break out of it. So if there's ever a chance for it to enter the loop, it'll sit there forever as far as I can tell.
    Well of course it would, if the stack went on forever. :P

    The Anonymous on
  • bowenbowen How you doin'? Registered User regular
    Assuming you're using .NET, you would want to do stack = stack.Remove(0,1);

    You're always referencing the same string, be careful with those methods. Strings aren't mutable in .NET.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • EtheaEthea Registered User regular
    Jimmy King wrote:
    In git, can I manage submodules semi-separately? Like have an overall module which has its own remote and then have a submodule which also has its own separate remote? Basically, I've got a Django app which I'd like to distribute on its own, but 99% of my dev work on it and my own personal usage for it is within the context of one website so I'd like to be able to just have it as part of that website's module plus distributable on its own.

    That is the exact point of submodules. When you add the submodule just point it to the remote branch that you want to track. Than you just need to update the submodule SHA1 when you want a newer version of that module.

  • The AnonymousThe Anonymous Uh, uh, uhhhhhh... Uh, uh.Registered User regular
    bowen wrote:
    Assuming you're using .NET, you would want to do stack = stack.Remove(0,1);

    You're always referencing the same string, be careful with those methods. Strings aren't mutable in .NET.
    Ah, good catch. I fixed that and it seems to be fine now...although it's still producing incorrect results.

    Ah, the joys of writing math parsers in .NET...:lol:

  • bowenbowen How you doin'? Registered User regular
    It was no better in C++ and Java when I had to do it. Ugh I think I'd rather do it in C#.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    It would probably be easy peasy with F# (and FParsec).

  • Jimmy KingJimmy King Registered User regular
    Ethea wrote:
    Jimmy King wrote:
    In git, can I manage submodules semi-separately? Like have an overall module which has its own remote and then have a submodule which also has its own separate remote? Basically, I've got a Django app which I'd like to distribute on its own, but 99% of my dev work on it and my own personal usage for it is within the context of one website so I'd like to be able to just have it as part of that website's module plus distributable on its own.

    That is the exact point of submodules. When you add the submodule just point it to the remote branch that you want to track. Than you just need to update the submodule SHA1 when you want a newer version of that module.
    Excellent, now make a backup of my repo and see if I can do this without making a mess.

  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    bowen wrote:
    It was no better in C++ and Java when I had to do it. Ugh I think I'd rather do it in C#.

    I wrote something to parse full C++ expressions once, it was... ugly

  • bowenbowen How you doin'? Registered User regular
    I think we wrote a lexical analyzer for some made up language. That was kinda fun, actually.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • IncindiumIncindium Registered User regular
    edited September 2011
    Hey can anyone familiar with TFS tell me what happens to shelved code when performing a branch? Does it get copied to the new branch or does it only stay in the original branch? Also less important but would be nice to know what is the behavior for checked out files when performing a branch?

    We are working on our first project using TFS (having moved from VSS) and going to be needing to do our first branch of the project and would be nice to know what behavior to expect.

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • EvilMonkeyEvilMonkey Registered User regular
    If I remember correctly, to lock a branch all files must be checked-in but you should be able to create a branch with no issues.

    As for shelved changes, by default they stay in their original branch but it looks like you can migrate them if needed
    http://grekai.wordpress.com/2011/09/14/branch-project-after-checked-outwith-shelving-in-visual-studio-2010/

    [PSN: SciencePiggy] [Steam]
  • EvilMonkeyEvilMonkey Registered User regular
    So I've recently moved back to C#/VS2010 after a year working in Eclipse and I'm finding a small list of features that Eclipse gave me that seem to be missing in the .NET world. Since I'm failing to think of the proper terms for these features my Googling has failed me.

    Is there a configuration/plugin to add "context sensitivity" to the scroll bar in the code editor? Like a red line marking a error, yellow for warning, black for occurrences of the currently highlighted member? ReSharpen looks to have this feature (plus a hell of a lot more) but it's painful paying $150 for a feature I'm used to having for free.

    [PSN: SciencePiggy] [Steam]
  • IncindiumIncindium Registered User regular
    edited September 2011
    Productivity Power Tools adds some of that enhanced scroll bar functionality(plus a ton of other awesome stuff).
    http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • EtheaEthea Registered User regular
    Incindium wrote:
    Productivity Power Tools adds some of that enhanced scroll bar functionality(plus a ton of other awesome stuff).
    http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef

    I love this tool and came to say the same thing.

  • EvilMonkeyEvilMonkey Registered User regular
    Incindium wrote:
    Productivity Power Tools adds some of that enhanced scroll bar functionality(plus a ton of other awesome stuff).
    http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef
    Looks promising, thank you good sir!

    [PSN: SciencePiggy] [Steam]
  • templewulftemplewulf The Team Chump USARegistered User regular
    edited September 2011
    So, I've been tasked with adding functionality to our TimeOffRequest form which was written in InfoPath.

    I finally figured out that the CurrentUser field is getting filled out by the userName() function in the Document_On_Load event which is only accessible through Tools -> Form Options -> "Open and Save" -> Rules. Which brings me to my big question about InfoPath:
    why.jpg

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • bowenbowen How you doin'? Registered User regular
    Because the solution is to make programming accessible to anyone so you don't need to hire programmers! But then you should hire programmers because you'll probably fuck it up anyways. You should still use this because you spent all that money on it.

    That's why.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    When in doubt always use an expert system!

This discussion has been closed.