Need advice about which tool to choose?Ask the StackShare community!
C++ vs Lua: What are the differences?
C++ and Lua are both popular programming languages used for different purposes. Let's explore the key differences between the two.
Data Types and Typing: In C++, data types must be explicitly declared before use, and the language has a static typing system. This means that variables have fixed types at compile-time, and type mismatches are found at compile-time. On the other hand, Lua is dynamically typed, allowing variables to change their type during runtime without explicit declarations. This flexibility comes at the cost of potential runtime errors due to type mismatches.
Syntax and Complexity: C++ has a more complex syntax compared to Lua. C++ supports object-oriented programming concepts like classes, inheritance, and templates, making it more suitable for large-scale projects. Lua, however, has a simpler syntax and is often used for scripting tasks due to its lightweight design and ease of use.
Performance and Execution: C++ is a compiled language that generates machine-level code, resulting in faster execution and better performance. Lua, on the other hand, is an interpreted language, which means it is executed at runtime using an interpreter. This makes Lua slower than C++ but allows for dynamic behavior and code modification during execution.
Memory Management: C++ provides manual memory management, allowing developers to allocate and deallocate memory explicitly. This gives C++ programs more control over memory usage but also requires careful management to avoid memory leaks and other issues. In contrast, Lua has automatic memory management through garbage collection. It takes care of memory deallocation, reducing the need for manual memory management at the cost of potentially slower performance.
Standard Libraries and APIs: C++ has a vast standard library that provides a wide range of functionalities for various purposes. It includes standard data structures, algorithms, file I/O, networking capabilities, and more. Lua, being a lightweight language, has a minimalistic standard library. It provides basic functionalities but lacks extensive support for complex operations. However, Lua can easily interface with C/C++ libraries, giving access to a wide range of functionalities.
Portability and Platform Support: C++ is a widely supported language and can be compiled and executed on various platforms, including Windows, Linux, macOS, and embedded systems. Lua, too, is portable but is primarily used as an embedded language within specific applications or game engines. Its runtime can be integrated into different platforms, providing flexibility for customization and extension.
In summary, C++ is mainly used for system programming and game development, and Lua is commonly used as an embedded scripting language in various applications.
Hi, I'm just starting to learn code, and I stumbled upon this website. I think I should learn JavaScript, Python, and C++ to begin with. I'm a quick learner so I am only worried about what would be more useful. Suppose my goal is to build an online clothing store or something. Then what languages would be best? I need advice. Please help me out. I'm 13 and just beginning and it's hard to understand when people use technical terms so please keep it simple. Thanks a lot.
Go with Python. It's syntax is really simple and less verbose compare to others. You can use Python for basically anything like web dev, task automation, data science, data engineering, cybersecurity etc. At initial level, it's more important to get an understanding of programming fundamentals. Once you get conformable with coding in general, then you can explore other languages.
I would worry less about languages when you're first starting out. If you want to build an online store, then javascript is a great language that is used all over the web! Get comfortable with your first language, learn some computer science concepts and how to build things the right way, and then just work towards a goal and learn as you go!
https://www.w3schools.com/ is a great resource and it's completely free, everything you need to know to build a website is on that page if you have the drive to learn it. Best of luck to you!
Here's a neat roadmap too, in case you find yourself lost on what to learn next https://roadmap.sh/frontend
I recommend JavaScript to build your first website, for both FrontEnd and BackEnd , even tho I am a BIG fan of C++ it is not well suited yet to create websites, and Python would be just as good for the BackEnd as JavaScript but having everything written in only one language will make your learning curve way easier, so it is easy to recommend JavaScript.
Python is an easy and beginner-friendly language. As you've mentioned about Online Clothing store, you'll need to deal with the website part and you'll need Javascript to make the site accessible and functional. Javascript will be more easy to learn if you learn Python first, so you can just start with Python.
Hello Rachel, as a fellow programmer, I am glad that you are planning on expanding your coding knowledge and skills.
I recommend learning python first as it has a very simple syntax (syntax is how your code looks and how simple it is to type) and is also very user-friendly. Once you get to know how to code in python, you can use this thing called Flask.
Flask is what you call a "web application framework" or a WAF, it basically is a tool used to develop websites and other similar things. You don't have to worry much about it's difficulty because it is based on python. You will still have to learn how to use Flask though as it could be a bit complicating in first glance.If you are looking for simpler ways for making website without having to learn a lot of programming, you can learn HTML and CSS. These 2 will help you in making a basic and functional website. The catch is, from a career perspective, HTML won't get you far, as literally every programmer knows it. So it is best to use programming languages.
I hope this gave you a clear understanding of the ways in which you can build websites. Wishing you the best of luck!
I have worked with all these a ton. I make ecommerce and enterprise apps now. The only one of these you need is JavaScript. You can use JS on the backend as Node.js in AWS Lambda. You will need HTML and CSS skills, as well as a database. I recommend MongoDB. Please forget about C++ until you built your first company. Python fits the same purpose as Node.js but is currently popular in the Data Science community so skip it until you have a LOT of customers.
Since you're new, I'd recommend Javascript and Python. With Javascript, just learn React and Node. And with Python, learn Django. With JavaScript, Node, React, Python, and Django; you can accomplish quite a lot for both frontend and backend.
Hi, When saying that "Suppose my goal is to build an online clothing store or something", I would go for a ready to use platform like Wordpress. it will give you a fast jump into the online world. By using WP you'll have to catch on with PHP\JQuery Goodluck.. Ping me when store is ready, I might buy something....
I am trying to make Roblox game which requires Lua. I quite don't want to go with Lua just because other tools just might let me do more projects later on. I heard that Python is most similar to Lua, but I am still not sure which tool to use. Java, I think it will help me with many stuff later on for websites, projects, and more!
Since you are trying to make a Roblox game, you have no other option than to use Lua, since Roblox only allows coding in Lua. Yes, you've heard right, Python is identical and as easy as Lua, although Lua is easier than Python. Beginning from Lua and then escalating to Python is recommended. Java is only helpful when you are creating a heavy, big-budget, enterprise-level product, otherwise, Python would suffice.
If you really hate lua check out roblox-ts, a tool that compiles typescript code into roblox lua. https://github.com/roblox-ts/roblox-ts
Python has become the most popular language for machine learning right now since almost all machine learning tools provide service for this language, and it is really to use since it has many build-in objects like Hashtable. In C, you need to implement everything by yourself.
C++ is one of the most popular programming languages in graphics. It has many fancy libraries like eigen to help us process matrix. I have many previous projects about graphics based on C++ and this time, we also need to deal with graphics since we need to analyze movements of the human body. C++ has much more advantages than Java. C++ uses only compiler, whereas Java uses compiler and interpreter in both. C++ supports both operator overloading and method overloading whereas Java only supports method overloading. C++ supports manual object management with the help of new and delete keywords whereas Java has built-in automatic garbage collection.
As a personal research project I wanted to add post-quantum crypto KEM (key encapsulation) algorithms and new symmetric crypto session algorithms to openssh. I found the openssh code and its channel/context management extremely complex.
Concurrently, I was learning Go. It occurred to me that Go's excellent standard library, including crypto libraries, plus its much safer memory model and string/buffer handling would be better suited to a secure remote shell solution. So I started from scratch, writing a clean-room Go-based solution, without regard for ssh compatibility. Interactive and token-based login, secure copy and tunnels.
Of course, it needs a proper security audit for side channel attacks, protocol vulnerabilities and so on -- but I was impressed by how much simpler a client-server application with crypto and complex terminal handling was in Go.
$ sloc openssh-portable Languages Files Code Comment Blank Total CodeLns Total 502 112982 14327 15705 143014 100.0% C 389 105938 13349 14416 133703 93.5% Shell 92 6118 937 1129 8184 5.7% Make 16 468 37 131 636 0.4% AWK 1 363 0 7 370 0.3% C++ 3 79 4 18 101 0.1% Conf 1 16 0 4 20 0.0% $ sloc xs Languages Files Code Comment Blank Total CodeLns Total 34 3658 1231 655 5544 100.0% Go 19 3230 1199 507 4936 89.0% Markdown 2 181 0 76 257 4.6% Make 7 148 4 50 202 3.6% YAML 1 39 0 5 44 0.8% Text 1 30 0 7 37 0.7% Modula 1 16 0 2 18 0.3% Shell 3 14 28 8 50 0.9%
Pros of C++
- Performance202
- Control over memory allocation107
- Cross-platform98
- Fast97
- Object oriented84
- Industry standard58
- Smart pointers47
- Templates37
- Gui toolkits16
- Raii16
- Generic programming13
- Control13
- Flexibility13
- Metaprogramming11
- Hardcore9
- Many large libraries5
- Simple5
- Full-fledged containers/collections API5
- Large number of Libraries4
- Performant multi-paradigm language4
- Way too complicated3
- Close to Reality1
- Plenty of useful features1
Pros of Lua
- Fast learning curve41
- Very easy to embed in C programs26
- Efficient memory usage26
- Open source20
- Good for game scripting19
- Pretty simple to learn9
- Quick to code8
- Simple Language8
- Syntax is amazing7
- Supported in most game engines7
- D6
- Coroutines2
- Can be used for a wide variety of development1
Sign up to add or upvote prosMake informed product decisions
Cons of C++
- Slow compilation8
- Unsafe8
- Over-complicated6
- Fragile ABI6
- No standard/mainstream dependency management5
- Templates mess with compilation units4
- Too low level for most tasks3
- Compile time features are a mess1
- Template metaprogramming is insane1
- Segfaults1
- Unreal engine1
Cons of Lua
- Nooby4
- Not widespread2
- D1
- Python0